perf: shard pool guard to improve performance - #964
Conversation
📝 WalkthroughWalkthroughThe change replaces implicit pool-guard creation with explicit base and session guard roots. It propagates guards through readonly access, file operations, catalog checkpoints, table persistence, recovery, indexes, and transaction paths. Tests verify guard identity and lifecycle behavior. ChangesPool-guard ownership and propagation
Estimated code review effort: 4 (Complex) | ~60 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Up to standards ✅🟢 Issues
|
| Category | Results |
|---|---|
| Complexity | 2 medium |
🟢 Metrics 0 complexity · 22 duplication
Metric Results Complexity 0 Duplication 22
NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.
Greptile SummaryThis PR shards buffer-pool guard roots by session to remove cross-session
Confidence Score: 5/5The PR appears safe to merge; no concrete correctness, lifecycle, security, or build failure was established. Session-local roots are released through existing session lifecycle handling, idle sessions are removed before component teardown, and checked storage paths retain and pass matching pool guards across synchronous and detached work.
|
| Filename | Overview |
|---|---|
| doradb-storage/src/session.rs | Stores one independent four-pool guard bundle per session and consistently exposes it through session runtime and transaction attachments. |
| doradb-storage/src/component.rs | Separates canonical engine-owned pool roots from newly created session-local roots while retaining identical pool identities. |
| doradb-storage/src/buffer/arena.rs | Renames base-guard construction and tests that independent roots share pool identity without sharing the outer reference-count root. |
| doradb-storage/src/buffer/readonly.rs | Propagates caller-owned guards through invalidation, misses, write barriers, and detached I/O while retaining owned keepalives where work may outlive a borrow. |
| doradb-storage/src/engine.rs | Removes canonical guard access from EngineCore and preserves shutdown ordering that releases idle session-owned roots before component teardown. |
| doradb-storage/src/file/cow_file.rs | Extends CoW write barriers and active-root loading to use the caller’s readonly-pool guard. |
| doradb-storage/src/recovery/mod.rs | Propagates recovery-owned pool guards through catalog and table-file reconstruction paths. |
| doradb-storage/src/quiescent.rs | Adds test support for distinguishing shared SyncQuiescentGuard roots without changing production lifetime semantics. |
Reviews (1): Last reviewed commit: "shard pool guard to improve performance" | Re-trigger Greptile
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #964 +/- ##
==========================================
+ Coverage 93.54% 93.55% +0.01%
==========================================
Files 154 154
Lines 132893 133296 +403
==========================================
+ Hits 124317 124709 +392
- Misses 8576 8587 +11 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
🧹 Nitpick comments (1)
doradb-storage/src/buffer/readonly.rs (1)
1285-1327: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winAdd a foreign-guard test for
begin_write_barrier.
begin_write_barriernow validates the caller-supplied guard throughpool.validate_guard(guard). The read path hastest_global_readonly_pool_panics_on_foreign_guardto cover the identity-mismatch panic. No equivalent test exists for the write-barrier path. Add a test that callsbegin_write_barrierwith a guard from a different pool and asserts the panic.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@doradb-storage/src/buffer/readonly.rs` around lines 1285 - 1327, Add a test in the existing readonly buffer tests module covering begin_write_barrier with a PoolGuard created by a different ReadonlyBufferPool. Assert that the call panics due to pool.validate_guard(guard), following the pattern of test_global_readonly_pool_panics_on_foreign_guard.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@doradb-storage/src/buffer/readonly.rs`:
- Around line 1285-1327: Add a test in the existing readonly buffer tests module
covering begin_write_barrier with a PoolGuard created by a different
ReadonlyBufferPool. Assert that the call panics due to
pool.validate_guard(guard), following the pattern of
test_global_readonly_pool_panics_on_foreign_guard.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yml
Review profile: CHILL
Plan: Pro Plus
Run ID: fdd17b79-ce80-4f5b-b06a-8b8cf5771b5d
⛔ Files ignored due to path filters (9)
docs/backlogs/closed/000175-scalable-shared-resource-lifetime-management.mdis excluded by none and included by nonedocs/engine-component-lifetime.mdis excluded by none and included by nonedocs/rfcs/0025-session-coordinated-cancellation-cleanup-ownership.mdis excluded by none and included by nonedocs/tasks/000102-separate-readonly-pool-interface-and-simplify-ownership.mdis excluded by none and included by nonedocs/tasks/000247-statement-public-transaction-cancellation-ownership.mdis excluded by none and included by nonedocs/tasks/000248-mandatory-operation-driver-and-concurrent-cleanup-executor.mdis excluded by none and included by nonedocs/tasks/000254-remove-engine-runtime-reference-accounting.mdis excluded by none and included by nonedocs/tasks/000255-session-local-runtime-reachability.mdis excluded by none and included by nonedocs/transaction-system.mdis excluded by none and included by none
📒 Files selected for processing (42)
doradb-storage/src/buffer/arena.rsdoradb-storage/src/buffer/evict.rsdoradb-storage/src/buffer/evictor.rsdoradb-storage/src/buffer/fixed.rsdoradb-storage/src/buffer/guard.rsdoradb-storage/src/buffer/mod.rsdoradb-storage/src/buffer/pool_guard.rsdoradb-storage/src/buffer/readonly.rsdoradb-storage/src/catalog/checkpoint.rsdoradb-storage/src/catalog/index.rsdoradb-storage/src/catalog/mod.rsdoradb-storage/src/catalog/storage/mod.rsdoradb-storage/src/catalog/storage/tables.rsdoradb-storage/src/catalog/table.rsdoradb-storage/src/component.rsdoradb-storage/src/engine.rsdoradb-storage/src/file/cow_file.rsdoradb-storage/src/file/fs.rsdoradb-storage/src/file/multi_table_file.rsdoradb-storage/src/file/table_file.rsdoradb-storage/src/index/block_index.rsdoradb-storage/src/index/btree/cursor.rsdoradb-storage/src/index/btree/mod.rsdoradb-storage/src/index/btree/node.rsdoradb-storage/src/index/column_block_index.rsdoradb-storage/src/index/column_deletion_blob.rsdoradb-storage/src/index/disk_tree.rsdoradb-storage/src/index/non_unique_index.rsdoradb-storage/src/index/row_page_index.rsdoradb-storage/src/index/secondary_index.rsdoradb-storage/src/index/unique_index.rsdoradb-storage/src/quiescent.rsdoradb-storage/src/recovery/mod.rsdoradb-storage/src/session.rsdoradb-storage/src/table/access.rsdoradb-storage/src/table/gc.rsdoradb-storage/src/table/layout.rsdoradb-storage/src/table/mem_table.rsdoradb-storage/src/table/persistence.rsdoradb-storage/src/trx/mod.rsdoradb-storage/src/trx/purge.rsdoradb-storage/src/trx/retention.rs
Summary by CodeRabbit