Skip to content

Commit d691054

Browse files
svarlamovclaude
andcommitted
perf(daemon): shard TraceIngressState with DashMap, per-root normalizers, bounded connection pool
Three architectural improvements to the trace2 ingestion pipeline: 1. Replace Mutex<TraceIngressState> with 15 independent DashMap/DashSet fields - Each field (root_worktrees, root_families, root_argv, root_mutating, etc.) is now a dashmap::DashMap<String, V> or dashmap::DashSet<String> - Per-root events no longer serialize on a single global mutex; concurrent connections to different roots run without blocking each other - Readonly fast path is now fully lock-free: DashMap shard lookups replace global Mutex acquisition for the 40+/sec readonly events from IDEs like Zed - Fold `mark_trace_root_activity` into the existing lock acquisition in the mutating path, eliminating one full Mutex cycle per mutating event - Add `dashmap = "6"` dependency 2. Per-root normalizer instances (dashmap::DashMap<String, Arc<AsyncMutex<...>>>) - Replace single global AsyncMutex<TraceNormalizer> with a per-root map - Normalizer state is now scoped to each root SID; entries are cleaned up when clear_trace_root_tracking removes the root - Enables future concurrent ingest workers per root without further refactor 3. Bounded trace connection thread pool - Add a hard ceiling (MAX_CONCURRENT_TRACE_CONNECTIONS=512) on simultaneous connection handler threads - Excess connections are dropped with a log message rather than spawning unbounded OS threads (prevents memory exhaustion and scheduler overload) - Active count tracked with a shared AtomicUsize; thread spawn/exit are O(1) atomic operations All 1420 tests pass. Benchmarks: readonly_flood/zed_mixed_1000_events unchanged (p=0.99; concurrency benefit not captured by single-threaded microbenchmark). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 17e4ac5 commit d691054

3 files changed

Lines changed: 291 additions & 239 deletions

File tree

Cargo.lock

Lines changed: 15 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ gix-index = "0.48.0"
3838
regex = "1.12"
3939
toml = "0.9"
4040
unicode-normalization = "0.1"
41+
dashmap = "6"
4142

4243
[target.'cfg(windows)'.dependencies]
4344
named_pipe = "0.4.1"

0 commit comments

Comments
 (0)