Commit d691054
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
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
38 | 38 | | |
39 | 39 | | |
40 | 40 | | |
| 41 | + | |
41 | 42 | | |
42 | 43 | | |
43 | 44 | | |
| |||
0 commit comments