Skip to content

Perf/tiered compile once body retention - #3

Merged
darmie merged 3 commits into
mainfrom
perf/tiered-compile-once-body-retention
Sep 27, 2026
Merged

darmie merged 3 commits into
mainfrom
perf/tiered-compile-once-body-retention

Conversation

@darmie

@darmie darmie commented Sep 27, 2026

Copy link
Copy Markdown
Member

No description provided.

Each lazy function's optimised body lives in a once-cell, filled by the
first caller under the scratch lock, and every compile path (requester,
broker, optimize_function, record_call, late resume points, closure
promotion) reads it through tier_body. A region cut from a body already
through the pipeline takes only the finishing passes and the entry
cleanup; a region of a lowered body is outlined once per loop. The
LLVM tier gets the Arc it is handed, and a reload swaps the cells.

git-bug: 73e6e26fd19da79528b2bafffa99d1b4de019d1298246dbfd5afa52cd7621920
A frame of a function with loops holds the body the body source gave
while it runs, so a resume point it asks for is made from that body
whatever the runtime keeps. Bytecode whose body nobody holds is made
again. The runtime is told when the first frame returns and may let
the body, and the bytecode, go.
The scratch module copies in only the bodies an optimisation reaches
through direct calls and is dropped once no optimisation is under way
and no compile waits. An interp body goes once its function has native
code, or when a large body's first frame returns; an optimised body
goes after the ladder's last compile unless it is small enough to be
inlined. A frame still running a body finds it, and a body asked for
again is made again, once per cell.

git-bug: 08988fa9d5b1d1f4ef42a0f9281172a42e87167a460a92dadc84c5972840ebee
@darmie
darmie merged commit 5341399 into main Sep 27, 2026
1 of 11 checks passed
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