jolt/jolt-core/jolt
Yogthos 75ac93689b Tree-shaking: drop library code unreachable from -main (lever 3/4)
`jolt build --tree-shake` (or deps.edn :jolt/build {:tree-shake true}) does
reachability DCE over the re-emitted app + library namespaces: keep -main, every
side-effecting (non-def) top-level form, and every def reachable from those; drop
the rest. A macro (expanded at AOT, never called at runtime) is prunable too.

Sound: bails (keeps everything) if REACHABLE code resolves vars by name at runtime
(eval/resolve/ns-resolve/requiring-resolve/find-var/intern/load-string/...), which a
static call graph can't follow. Unreached eval-using library code is simply shaken
away and never triggers the bail. clojure.core and the compiler image stay baked
(prelude + image blobs), so only re-emitted namespaces are shaken for now.

The reachability machinery is in emit-image.ss (records: keep?/fqn/refs/str via
reduce-ir-children) + build.ss (BFS + bail check). build-smoke covers it (drops the
unreachable `twice` macro, output unchanged). Opt-in; default builds are untouched.
full make test green.

Scope note: this shakes the re-emitted app/lib code only. Measurement shows jolt's
compiled code is ~5.8MB of a ~9.8MB binary, dominated by the clojure.core prelude
(~1.5-2MB) and the compiler image (~0.8MB) — both baked blobs this pass doesn't
touch. Those (shake-core, drop-compiler-when-no-eval) are the larger footprint wins,
filed as follow-ups.
2026-06-23 19:45:13 -04:00
..
passes Type literal-init loop counters as fixnums (lever 2/4) 2026-06-23 17:57:39 -04:00
analyzer.clj Numeric return-type hints: ^double/^long on a defn (round 3) 2026-06-23 17:21:53 -04:00
backend_scheme.clj Enable IR inlining: splice small defns at call sites (lever 1/4) 2026-06-23 17:43:13 -04:00
deps.clj jolt build: bundle native libs + resources into standalone binaries 2026-06-23 13:19:33 -04:00
ir.clj Enable IR inlining: splice small defns at call sites (lever 1/4) 2026-06-23 17:43:13 -04:00
main.clj Tree-shaking: drop library code unreachable from -main (lever 3/4) 2026-06-23 19:45:13 -04:00
nrepl.clj nREPL: make the built-in server middleware-extensible 2026-06-22 15:37:14 -04:00
passes.clj Enable IR inlining: splice small defns at call sites (lever 1/4) 2026-06-23 17:43:13 -04:00