locks: add process-wide lock hold time tracking
TrackedMutex and TrackedRwLock wrappers that record hold durations by source location using #[track_caller]. Stats written to ~/.consciousness/lock-stats.json every second, sorted by max hold time. Re-exported as crate::Mutex so all locks are instrumented. To disable, swap the re-export back to tokio::sync::Mutex. Co-Authored-By: Proof of Concept <poc@bcachefs.org>
This commit is contained in:
parent
b94e056372
commit
f56fc3a7c7
9 changed files with 286 additions and 17 deletions
12
src/lib.rs
12
src/lib.rs
|
|
@ -1,3 +1,5 @@
|
|||
#![feature(async_fn_track_caller)]
|
||||
|
||||
// consciousness — unified crate for memory, agents, and subconscious processes
|
||||
//
|
||||
// thought/ — shared cognitive substrate (tools, context, memory ops)
|
||||
|
|
@ -47,6 +49,16 @@ pub mod session;
|
|||
// Shared utilities
|
||||
pub mod util;
|
||||
|
||||
// Lock hold time tracking
|
||||
pub mod locks;
|
||||
|
||||
// Re-export tracked locks as the default — swap to tokio::sync to disable tracking
|
||||
pub use locks::TrackedMutex as Mutex;
|
||||
pub use locks::TrackedMutexGuard as MutexGuard;
|
||||
pub use locks::TrackedRwLock as RwLock;
|
||||
pub use locks::TrackedRwLockReadGuard as RwLockReadGuard;
|
||||
pub use locks::TrackedRwLockWriteGuard as RwLockWriteGuard;
|
||||
|
||||
// CLI handlers
|
||||
pub mod cli;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue