-
Notifications
You must be signed in to change notification settings - Fork 676
feat: Restructure kv manager block registration #1093
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
ryanolson
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @jthomson04
Please evaluate my concerns about the potential for multiple registrations under the None condition of existing handles across pools.
Also, since it took me a bit to grok the new Arc<()> usage, let's tick of one more documentation task and give registry.rs a proper top-level (//!) set of docstrings.
48ab610 to
d77ef79
Compare
d77ef79 to
fb1a6c3
Compare
|
Blocked on #1134 for async runtime fixes |
4972eba to
4f2ab80
Compare
b90cee4 to
fcedaa3
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (1)
lib/llm/src/block_manager/block/registry.rs (1)
161-199: Consider documenting lock acquisition order for thread safety.The nested lock acquisition pattern acquires
blocksfirst (line 161), thenglobal_registry(line 177). While this appears safe in the current implementation, consider adding a comment documenting this ordering to prevent future deadlock issues if other code paths acquire these locks in different orders.+ // Lock acquisition order: blocks -> global_registry (maintain this order to prevent deadlocks) let mut blocks = self.blocks.lock().unwrap();
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (9)
lib/llm/src/block_manager/block.rs(3 hunks)lib/llm/src/block_manager/block/registry.rs(5 hunks)lib/llm/src/block_manager/block/state.rs(5 hunks)lib/llm/src/block_manager/offload.rs(4 hunks)lib/llm/src/block_manager/offload/pending.rs(1 hunks)lib/llm/src/block_manager/pool.rs(7 hunks)lib/llm/src/block_manager/pool/inactive.rs(9 hunks)lib/llm/src/block_manager/pool/state.rs(6 hunks)lib/llm/src/block_manager/state.rs(8 hunks)
🚧 Files skipped from review as they are similar to previous changes (8)
- lib/llm/src/block_manager/offload/pending.rs
- lib/llm/src/block_manager/block/state.rs
- lib/llm/src/block_manager/offload.rs
- lib/llm/src/block_manager/state.rs
- lib/llm/src/block_manager/pool/state.rs
- lib/llm/src/block_manager/pool/inactive.rs
- lib/llm/src/block_manager/pool.rs
- lib/llm/src/block_manager/block.rs
🧰 Additional context used
🧠 Learnings (1)
lib/llm/src/block_manager/block/registry.rs (1)
Learnt from: ryanolson
PR: ai-dynamo/dynamo#1093
File: lib/llm/src/block_manager/block/registry.rs:98-122
Timestamp: 2025-05-29T06:20:12.894Z
Learning: In lib/llm/src/block_manager/block/registry.rs, the background task spawned for handling unregister notifications uses detached concurrency by design. The JoinHandle is intentionally not stored as this represents a reasonable architectural tradeoff for a long-running cleanup task.
⏰ Context from checks skipped due to timeout of 90000ms (4)
- GitHub Check: pre-merge-rust (lib/runtime/examples)
- GitHub Check: pre-merge-rust (.)
- GitHub Check: pre-merge-rust (lib/bindings/python)
- GitHub Check: Build and Test - vllm
🔇 Additional comments (5)
lib/llm/src/block_manager/block/registry.rs (5)
16-33: Excellent module documentation addressing previous feedback.The comprehensive module-level documentation clearly explains the dual-layer registry design with global and per-pool components, the workflow, and the relationship between block handles and registration handles. This directly addresses the previous review comment requesting better documentation.
58-83: Well-designedBlockHandlefor asynchronous cleanup.The
BlockHandlestruct correctly implements the drop-based unregistration pattern. The use ofmpsc::UnboundedSenderfor async notification ensures that the drop operation is non-blocking, and thelet _ =pattern appropriately handles potential send failures when the receiver is dropped.
105-127: Background task implementation follows established pattern.The detached async task for cleanup is correctly implemented and follows the established architectural pattern for this codebase. The task properly handles cleanup of expired weak references from both registries and will naturally terminate when the channel is closed.
175-197: Robust global registry logic with proper handle sharing.The global registry logic correctly handles sharing of registration handles across pools. The use of weak references in the global registry and the upgrade check ensures that expired handles are properly detected. The creation of new registration handles only when needed optimizes memory usage.
202-205: Clean state transition with proper handle ownership.The block state transition correctly packages both the registration handle and block handle into the
Registeredvariant, maintaining proper ownership semantics for the dual-layer registry system.
Summary by CodeRabbit
New Features
Enhancements
Bug Fixes
Documentation