-
Notifications
You must be signed in to change notification settings - Fork 690
refactor: Refactor discovery ModelManager to use parking_lot::RwLock
#2902
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
…ager to avoid unwrap Signed-off-by: Paul Hendricks <phendricks@nvidia.com>
ce31481 to
6709863
Compare
|
Caution Review failedFailed to post review comments. Configuration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro 💡 Knowledge Base configuration:
You can enable these sources in your CodeRabbit configuration. 📒 Files selected for processing (1)
🧰 Additional context used🧠 Learnings (2)📚 Learning: 2025-09-02T16:46:54.015ZApplied to files:
📚 Learning: 2025-07-16T12:41:12.543ZApplied to files:
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (4)
WalkthroughMigrates ModelManager’s locking from std::sync::RwLock to parking_lot::RwLock, updating read/write access patterns to drop unwraps. Adds two public methods to register chat-completions and embeddings models. Internal engine maps and retrieval paths are updated to use parking_lot guards. No signature changes to existing getters. Changes
Sequence Diagram(s)sequenceDiagram
autonumber
participant C as Caller
participant MM as ModelManager
participant CCM as Chat Models Map (RwLock)
participant EM as Embeddings Map (RwLock)
rect rgba(200,235,255,0.25)
note over C,MM: Add chat completions model (new)
C->>MM: add_chat_completions_model(model, engine)
MM->>CCM: write()
activate CCM
CCM-->>MM: write guard
MM->>CCM: insert(model, engine)
CCM-->>MM: drop guard
deactivate CCM
MM-->>C: Result<(), Error>
end
rect rgba(220,255,220,0.25)
note over C,MM: Get embeddings engine (existing, lock API changed)
C->>MM: get_embeddings_engine(model)
MM->>EM: read()
activate EM
EM-->>MM: read guard
MM->>EM: get(model)
EM-->>MM: drop guard
deactivate EM
MM-->>C: Option/Result<Engine>
end
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
Poem
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. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. CodeRabbit Commands (Invoked using PR/Issue comments)Type Other keywords and placeholders
Status, Documentation and Community
|
ai-dynamo#2902) Signed-off-by: Paul Hendricks <phendricks@nvidia.com> Signed-off-by: Gavin.Zhu <gavin.z@gmicloud.ai>
#2902) Signed-off-by: Paul Hendricks <phendricks@nvidia.com> Signed-off-by: nnshah1 <neelays@nvidia.com>
Overview:
Replaces
std::sync::RwLockwithparking_lot::RwLockin the discovery module.This change improves performance and consistency with the rest of the codebase, while removing the need for
.unwrap()calls on lock guards.Details:
parking_lot::{Mutex, RwLock}..unwrap()calls onRwLockguards.Where should the reviewer start?
lib/llm/src/discovery/model_manager.rsRelated Issues: (use one of the action keywords Closes / Fixes / Resolves / Relates to)
Relates to:
std::sync::Mutextoparking_lot::Mutex#2696Summary by CodeRabbit
New Features
Refactor