Performance profiling of session query, search, highlight, and cross-reference operations
| Operation | Min (ms) | Median (ms) | Max (ms) | Stdev | Distribution | Detail |
|---|---|---|---|---|---|---|
| session_tool list (alive, json) | 769 | 787 | 1266 | 217 | 17 lines output | |
| session_tool cleanup (dry-run) | 378 | 383 | 392 | 6 | 45 lines output | |
| rg -c 'model' (-Users-tchklovski-all-code-rivus/) | 53 | 53 | 452 | 178 | 2008 lines output | |
| it2api get-buffer (single) | 288 | 299 | 310 | 8 | 41 lines output | |
| tab color set+unset cycle | 911 | 916 | 943 | 16 | ||
| highlight flow (1 panes) | 1224 | 1235 | 1431 | 88 | ||
| cross-ref sessions.yaml ↔ it2api | 308 | 310 | 392 | 36 | 1 alive, 43 stale of 44 |
| Operation | Sequential (ms) | Concurrent (ms) | Speedup | Visual |
|---|---|---|---|---|
| buffer reads x1 | 299 | 306 | 0.98x |
|
| tab color x1 | 1015 | 1012 | 1.00x |
|
| rg x4 patterns | 296 | 180 | 1.65x |
|
Each component of get_enriched_sessions() measured independently.
The total explains the ~14s wall time of session_tool list.
| Component | Median (ms) | % of Total | Waterfall |
|---|---|---|---|
| claude --version | 53 | 4.9% | |
| it2api list-sessions | 302 | 28.1% | |
| JSONL rglob+version (1 session) | 13 | 1.2% | |
| JSONL rglob+version (43 sessions) | 705 | 65.6% | |
| it2api get-buffer x0 seq (all alive) | 0 | 0.0% | |
| Hub DB badge load | 2 | 0.2% | |
| JSONL wait state detect (1 session) | 0 | 0.0% | |
| SUM (estimated) | 1076 | 100% |
| Operation | Category | Min | Median | Mean | Max | Stdev | Trials |
|---|---|---|---|---|---|---|---|
| session_tool list (alive, json) | sequential | 769 | 787 | 879 | 1266 | 217 | 5 |
| session_tool cleanup (dry-run) | sequential | 378 | 383 | 384 | 392 | 6 | 5 |
| rg -c 'model' (-Users-tchklovski-all-code-rivus/) | sequential | 53 | 53 | 133 | 452 | 178 | 5 |
| it2api get-buffer (single) | sequential | 288 | 299 | 299 | 310 | 8 | 5 |
| tab color set+unset cycle | sequential | 911 | 916 | 925 | 943 | 16 | 5 |
| highlight flow (1 panes) | sequential | 1224 | 1235 | 1277 | 1431 | 88 | 5 |
| cross-ref sessions.yaml ↔ it2api | sequential | 308 | 310 | 327 | 392 | 36 | 5 |
| buffer reads x1 (sequential) | sequential | 297 | 299 | 304 | 317 | 8 | 5 |
| buffer reads x1 (concurrent) | concurrent | 292 | 306 | 309 | 335 | 16 | 5 |
| tab color x1 (sequential) | sequential | 952 | 1015 | 1005 | 1053 | 50 | 5 |
| tab color x1 (concurrent) | concurrent | 952 | 1012 | 1005 | 1052 | 47 | 5 |
| rg x4 patterns (sequential) | sequential | 207 | 296 | 268 | 316 | 49 | 5 |
| rg x4 patterns (concurrent) | concurrent | 172 | 180 | 179 | 185 | 6 | 5 |
Each it2api call spawns a Python process. With 15+ alive panes needing buffer reads,
that's 15 × 305ms = 4.5s just in process startup overhead.
| Scenario | Buffer Reads | JSONL Version | list-sessions | Other | Total | vs Current |
|---|---|---|---|---|---|---|
| Current (it2api, sequential) | 0ms | 705ms | 302ms | 63ms | 1071ms | baseline |
| + ThreadPool parallelism | 0ms | 705ms | 302ms | 63ms | 1071ms | 1.0x |
| + MCPretentious (255x buffer) | 0ms | 705ms | 151ms | 63ms | 920ms | 1.2x |
| + direct JSONL path (no rglob) | 0ms | 50ms | 151ms | 63ms | 264ms | 4x |
| # | Change | Saves | Effort |
|---|---|---|---|
| 1 | MCPretentious for get-buffer + send-text Replace it2api subprocess calls in supervisor/adapters/iterm2.py with persistent WebSocket |
~0ms (255x) | medium |
| 2 | Direct JSONL path instead of rglobJSONL_DIR / f"{sid}.jsonl" instead of rglob(f"{sid}.jsonl") |
~655ms | trivial |
| 3 | ThreadPool for remaining it2api calls Parallelize badge/title/profile property calls that can't use MCPretentious |
~0ms (if no MCP) | easy |
| 4 | Cache claude --version Version doesn't change within a session — cache for 5 min |
~53ms | trivial |
Primary bottleneck: it2api calls