adr/003-search-parallelization.md
Date: 2025-01-22
Accepted
We investigated optimizing cheat's search performance through parallelization. Initial assumptions suggested that I/O operations (reading multiple cheatsheet files) would be the primary bottleneck, making parallel processing beneficial.
Performance benchmarks were implemented to measure search operations, and a parallel search implementation using goroutines was created and tested.
We will not implement parallel search. The sequential implementation will remain unchanged.
CPU profiling revealed that search performance is dominated by:
os/exec.(*Cmd).Run)syscall.Syscall6)The actual search logic (regex matching, file reading) was negligible in the profile, indicating our optimization efforts were targeting the wrong bottleneck.
Parallel implementation showed minimal improvements:
The best case saved only ~5ms in absolute terms.
Costs of parallelization:
Benefits:
For a command-line tool:
Rejected: Complexity outweighs negligible performance gains.
Rejected: Process creation overhead is inherent to CLI tools and cannot be avoided without fundamental architecture changes.
If performance becomes critical, consider:
However, these would fundamentally change the tool's architecture and usage model.
This decision reinforces important principles:
The parallelization attempt was valuable as a learning exercise and definitively answered whether this optimization path was worthwhile.