Skip to content

perf(gen_srcs): transparent JVM AOT caching via Project Leyden#96

Open
english wants to merge 1 commit into
griffinbank:mainfrom
english:series/gen-srcs-aot-cache
Open

perf(gen_srcs): transparent JVM AOT caching via Project Leyden#96
english wants to merge 1 commit into
griffinbank:mainfrom
english:series/gen-srcs-aot-cache

Conversation

@english

@english english commented Apr 4, 2026

Copy link
Copy Markdown
Contributor

On JDK 24+, gen_srcs now automatically creates and uses a JVM AOT cache (.gen_srcs.aot) in the
workspace root via JEP 483 (AOT class loading/linking) and JEP 514 (AOT method profiling/compilation).

The first bazel run //:gen_srcs pays a one-time cost (~5s) to do a training run and create the
cache. Subsequent runs memory-map the cache instead of loading/linking/compiling from scratch, saving
~300-400ms per invocation.

Falls back gracefully on older JDKs or when the cache is stale (classpath change). Delete
.gen_srcs.aot to force re-creation.

Implementation

  • Single java_binary (gen_srcs_bin) with no AOT flags
  • clojure_gen_srcs generates an sh_binary wrapper that transparently handles cache creation and
    passes --wrapper_script_flag=--jvm_flag=-XX:AOTCache=... at runtime
  • Args are baked into the wrapper at repository rule time

Benchmark (banksy, Hyperfine, 10 runs, warm)

  • without cache: 2.506s ± 0.030s
  • with cache: 2.155s ± 0.036s
  • change: -14%

(written by Claude)

@english english marked this pull request as ready for review April 4, 2026 22:22
@english english requested a review from a team April 4, 2026 22:22
…83/514)

On JDK 24+, gen_srcs now automatically creates and uses a JVM AOT
cache (.gen_srcs.aot) in the workspace root. The first run pays a
one-time cost (~5s) to record class loading and create the cache;
subsequent runs memory-map the cache instead of loading/linking/
compiling from scratch.

Falls back gracefully on older JDKs or when the cache is stale.
Delete .gen_srcs.aot to force re-creation.

### Benchmark (banksy, Hyperfine, 10 runs, warm)
- without cache: 2.506s ± 0.030s
- with cache:    2.155s ± 0.036s
- change: **-14%**

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@english english force-pushed the series/gen-srcs-aot-cache branch from 26fd6c6 to efebb1f Compare April 5, 2026 14:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant