Skip to content

Add method_churn: type inference as a GC workload - #104

Open
gbaraldi wants to merge 1 commit into
mainfrom
add-method-churn-benchmark
Open

Add method_churn: type inference as a GC workload#104
gbaraldi wants to merge 1 commit into
mainfrom
add-method-churn-benchmark

Conversation

@gbaraldi

@gbaraldi gbaraldi commented Aug 4, 2026

Copy link
Copy Markdown
Member

Repeatedly defines call trees of fresh gensym-named methods (6 leaves of varying body shapes, 2 mids, 1 top per unit; 40 units × 5 iterations) and runs code_typed over each top, so every iteration re-runs inference and optimization from scratch.

Why this earns a slot next to inference_benchmarks.jl: both exercise the GC under the compiler's allocation profile, and they are about equally GC-bound — measured on Julia 1.12.6, this runs ~6 s with ~2.8 GB allocated at ~10% GC time, while inference_benchmarks.jl runs ~18 s with ~8.9 GB at ~10–11% GC time (near-identical allocation rates, ~0.47 vs ~0.49 GB/s, mark/sweep split ~60/40 in both). The differences are in benchmark quality rather than GC fraction:

  • No cache reuse. inference_benchmarks.jl runs a fixed target set against caches that fill as it goes (several of its targets specifically measure caching, e.g. CachedMethodTable, GlobalRef caching). Fresh gensym'd methods make every iteration identical work, so the GC load is steady and repeatable.
  • Scalable. UNITS_PER_ITER / NITER scale the workload linearly; the fixed suite does not.
  • ~3× shorter at the same allocation rate, which matters when the harness runs each benchmark 10 times per configuration.
  • Generic shapes, not the compiler-pathology stressers — for GC purposes the mainstream allocation behaviour is the signal.

Uses invokelatest for the post-eval binding lookups, so it is clean under 1.12's strict binding world-age semantics.

Disclosure: this PR was written with the assistance of generative AI (Claude).

🤖 Generated with Claude Code

Repeatedly define call trees of fresh gensym-named methods and run
code_typed over them, so every iteration re-runs inference and optimization
from scratch with no cache reuse. This exercises the GC under the compiler's
own allocation profile (Exprs, CodeInfos, IR, type objects) - the profile of
package loading and REPL work - rather than the uniform data structures of
the other benchmarks. Complements inference_benchmarks.jl, which measures
the compiler's speed rather than the GC underneath it.

Runs ~6s measured with ~2.8GB allocated and ~10% GC time on Julia 1.12.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@oscardssmith

Copy link
Copy Markdown
Collaborator

This seems pretty synthetic. Is it actually useful?

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.

2 participants