Commit b053bbe
committed
perf(file): Fast-path the ignore-file predicate without per-path resolution
The isIgnored() predicate returned by buildIgnoreFileFilter routed every
tested path through createIgnoreMatcher, which performs ~5 path operations
per call (resolve, normalize, relative, isInsidePath check, slash
conversion) before reaching the `ignore` matcher — applied to every file
and directory the scans emit (~1,400 paths per search on this repo, plus
the empty-directory scans), this dominated the post-scan filter cost.
fast-glob only ever emits clean, slash-separated paths relative to the
scan root. For those, the baseDir-relative form the `ignore` package
expects is a constant prefix (the scan root's path below the git root;
empty when they coincide) plus the input string, so the fast path is now
one string concatenation + ig.ignores(). A single regex routes every
other input shape ('', '.'/'..' segments, backslashes, doubled or
trailing slashes, absolute paths) to the unchanged legacy matcher, so
edge-case semantics stay exactly as before.
decision(gitignore-filter): keep createIgnoreMatcher as the fallback for
non-fast-glob input shapes instead of replicating its normalization
inline — equivalence by construction, and the fallback never runs on the
hot path
rejected(double-sort): skipping the second sortOutputFiles inside
generateOutput — re-measured at ~0.12ms isolated; the change-7 round's
22ms figure was the git-log subprocess cost already eliminated by
prefetchSortData
rejected(xml-direct-builder): direct string builder replacing the
Handlebars xml render — noise-level on the current tip (t=-0.14 over 20
interleaved pairs); earlier ~19ms estimates came from builds without the
landed lazy render-context getters
rejected(md5-precompute): computing contentCacheKey during processFiles
to clear it from the tail — +7.6ms (noise, t=0.86) over 20 interleaved
pairs on the current tip
learned(bench): this container runs ~1.6-1.7x slower than the previous
rounds' quiet host (e2e baseline ~1615ms vs ~800-950ms); relative deltas
from interleaved pairs are the comparable metric
Benchmark (32 interleaved ABBA pairs, warm, default pack of this repo,
4-core Linux): e2e median 1615ms -> 1540ms, paired mean delta -82.0ms
(-5.1%), median delta -74ms (-4.6%), t = -7.68, 29/32 pairs improved.
Search phase ([globby] trace, --verbose): 749-778ms -> 643-684ms with
identical results (1099 files, 255 directories).
Output byte-identical (cmp) vs the previous build for: default pack,
subdirectory pack (website/client — exercises the git-root prefix
branch), multi-root (src website), and --no-gitignore. 1416/1416 tests
pass; lint clean (3 pre-existing warnings in unrelated files).
https://claude.ai/code/session_01N3uqykUShsrDKkyvjuKi131 parent 632bf8f commit b053bbe
2 files changed
Lines changed: 63 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
| 24 | + | |
24 | 25 | | |
25 | 26 | | |
26 | 27 | | |
| |||
202 | 203 | | |
203 | 204 | | |
204 | 205 | | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
205 | 223 | | |
206 | 224 | | |
207 | | - | |
208 | | - | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
209 | 235 | | |
210 | 236 | | |
211 | | - | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
212 | 240 | | |
213 | 241 | | |
214 | 242 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
96 | 96 | | |
97 | 97 | | |
98 | 98 | | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
99 | 131 | | |
100 | 132 | | |
101 | 133 | | |
| |||
0 commit comments