mirror of
https://github.com/yamadashy/repomix.git
synced 2026-10-05 15:35:35 +02:00
Cap security worker threads at (cpus - 2) when running in parallel with main-thread token counting. On a 4-core machine, this prevents 5 threads (4 workers + main) from competing for 4 cores, reducing context switching and cache thrashing. Add maxConcurrency option to WorkerOptions to allow callers to cap the thread count independently of the system's CPU count. ## Isolated parallel phase benchmark (security + token counting, 10 runs): | Workers | Median | vs Default | |---|---|---| | 4 (default) | 525ms | — | | 3 workers | 481ms | -8.4% | | 2 workers (cpus-2) | 465ms | **-11.4%** | | 1 worker | 496ms | -5.5% | | Sequential | 572ms | +9.0% | ## pack() benchmark (30 runs each, packing repomix repo ~974 files): | | Trimmed Median | p25 | p75 | |---|---|---|---| | Before (4 workers) | 714ms | 700ms | 736ms | | After (cpus-2 workers) | 688ms | 677ms | 705ms | | **Improvement** | **-26ms (-3.6%)** | | | https://claude.ai/code/session_01Ld8pAqs5fdHvC5XwvbAytF