perf(gen_build): memoize classpath-files for is-aoted?#91
Conversation
arohner
left a comment
There was a problem hiding this comment.
I'm surprised this works. AFAICT jar-classes is only called in one place, ->class->jar, and ->class->jar is only called in one place, srcs. Are there duplicate jars on the classpath?
Benchmark (examples/gen_srcs_bench, hyperfine, 10 runs, prepare: delete src/**/BUILD.bazel):\n- before median: 10.113s (mean 11.905s ± 6.529s)\n- after median: 9.017s (mean 9.399s ± 1.827s)\n- change (median): -10.84%
The previous memoize approach cached the file listing per path but still did O(n) linear scans via `some` on every call. Restructure to build a set once per classpath entry and pass it through should-compile-namespace?/is-aoted?, replacing the linear scan with O(1) `contains?` lookups. Benchmark (examples/gen_srcs_bench, hyperfine, 5 runs): - baseline median: 13.155s - memoize median: 10.899s (-17%) - restructured median: 6.636s (-50%) (written by Claude) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
not duplicate jars — it's the same jar/directory scanned once per namespace within it. I've pushed a commit that restructures instead of memoising: build the file listing as a set once per classpath entry, pass it through. also replaces the benchmark (examples/gen_srcs_bench, hyperfine, 5 runs): with
without prepare (no-op, BUILD files already exist):
(written by Claude) |
bdd6b16 to
22a7b97
Compare
Memoises classpath file listing in the
is-aoted?path to avoid repeated scans of the same classpathentries.
Change
classpath-filesis-aoted?Benchmark
examples/gen_srcs_bench(Hyperfine, 10 runs, prepare: deletesrc/**/BUILD.bazel)