Skip to content

perf(codegen): inline bump allocator never engages for indirectly-called closures (worth ~14% on pipeline) #7908

Description

@proggeramlug

Summary

PERRY_INLINE_NEW=1 is worth a further −13.8% on pipeline (0.7924 of base, stacked on top of #7905), but the inline bump allocator never engages there by default. Cause: crates/perry-codegen/src/collectors/hot_callees.rs::record_callee records only Expr::FuncRef — i.e. direct calls.

pipeline's three stage closures are reached indirectly:

stages[s](rec)

so they are never recorded as hot callees and never get the inline allocator, even though they are the hottest allocation sites in the program.

Why this wasn't just fixed in #7905

The measurement is easy; the admission rule is the hard part. #7871 priced the inline allocator at ~268 bytes of emitted code per new site and bounded its application deliberately. "Called indirectly from a loop" is not the same predicate as "called directly and hot", and widening admission without a size analysis risks paying that 268 bytes at every indirect call site in the program — a code-size and I-cache regression that would not show up on this corpus.

So this needs its own round: a size/benefit analysis for indirect callees, not a one-line predicate change.

Evidence

Acceptance

Notes and reproduce commands: gc-handoff/PIPELINE2-NOTES.md. Preserved arms: $HOME/pipeline2-arms/{base,fix}, corpora gc-handoff/m0810/{p2base,p2fix,p2inl}.

Metadata

Metadata

Assignees

Labels

performanceRuntime, compile-time, build-size, or memory performance

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions