ig
instant-grep
๐Ÿ“Š Power Level Chart โ€” Over 9000

Performance

From 18ms to 0.9ms โ€” the complete optimization saga across five versions. Each iteration a new form, each form more powerful than the last.

20ร—
Faster than V1
0.9ms
p50 latency
0.3ms
Daemon mode

โšก Benchmark Table

Measured on a 1,247 file Rust project. Pattern: "async fn". Hardware: AMD Ryzen 9, NVMe SSD, 32GB RAM. p50 latency (10 runs).

Version Tool / Mode Latency (p50)
V1 ig (V1 โ€” naive trigrams) 18ms
V2 ig (V2 โ€” index + verification) 8ms
V3 ig (V3 โ€” sparse n-grams) 3ms
V4 ig (V4 โ€” covering set + mmap) 1.4ms
V5 ig (V5 โ€” parallel verify) 0.9ms โœ“
daemon ig (daemon mode) 0.3ms โœ“
goku Goku (Instant Transmission) [easter egg] 0.00ms

* Goku row is a tribute. ig does not yet support ki-based teleportation.

๐Ÿ“ˆ Optimization Timeline

V1 โ€” Naive trigrams
18ms
V2 โ€” Index + verify
8ms
V3 โ€” Sparse n-grams
3ms
V4 โ€” Covering + mmap
1.4ms
V5 โ€” Parallel verify
0.9ms
Daemon mode
0.3ms

๐ŸŒ€ Why Sparse N-grams Beat Trigrams

Selectivity

Longer n-grams appear in fewer files. A 7-gram like "async f" eliminates 99% of files immediately. Trigrams are too common.

Index Size

Fewer, more selective n-grams per file โ†’ smaller posting lists โ†’ smaller index. ig's index is typically 2-3MB for a 1000+ file project.

Intersection

Fewer candidates to intersect means less time in the merge step. Shadow Clone Selection picks the most selective n-grams automatically.

Selectivity comparison for "async fn":
Trigrams (weak):   "asy"(3000 files) โˆฉ "syn"(2100 files) โˆฉ "ync"(1800 files) = 47 candidates
Sparse n-grams:   "async fn"(3 files) = 3 candidates  โ†’ 15x fewer candidates to verify

๐Ÿธ Sage Mode Latency Breakdown

Unix socket read (query) ~0.02ms
N-gram extraction from regex ~0.05ms
Hash table lookup (lexicon in memory) ~0.03ms
Posting list intersection ~0.05ms
Parallel regex verification ~0.10ms
Unix socket write (results) ~0.05ms
Total (p50) ~0.3ms