Skip to content

perf(construction): reuse candidate buffers across placements - #225

Merged
blackopsrepl merged 1 commit into
mainfrom
feature/222-construction-buffers
Nov 8, 2026
Merged

blackopsrepl merged 1 commit into
mainfrom
feature/222-construction-buffers

Conversation

@blackopsrepl

Copy link
Copy Markdown
Collaborator

Closes #222.

Scalar construction allocated about ten short-lived buffers per placement. A placement cursor now takes finished placements back (EntityPlacerCursor::recycle, called by the construction phase after each step) and reuses their candidate store and value buffer; static scalar slots visit candidate values without collecting them, and buffer fillers copy them in one bulk call. The __bench placement cursor gains recycle so the gate's construction_full case drives placements as the phase does.

Descriptor-placement scalar construction allocated about ten short-lived
buffers per placement: a fresh candidate store, the candidate value list
(plus an index vector and a second collected vector under ascending-key
value order), and the slot's candidate values collected into a Vec before
they were visited. Construction time then depended on where glibc placed
those buffers.

A placement cursor now takes finished placements back
(EntityPlacerCursor::recycle, called by the construction phase after each
step) and reuses their candidate store and value buffer. Ascending-key
value order sorts the buffer in place, keeping offered order between equal
keys. Static scalar slots visit candidate values without collecting them,
and buffer fillers copy them in one bulk call. The __bench placement cursor
gains recycle, so the gate's construction_full case drives placements the
way the phase does.

Against v0.24.0 on the isolated zero-regression gate: construction first
fit -48% instructions, construction full -12%, ruin -43%, with every case
producing identical results.

Closes #222
@blackopsrepl
blackopsrepl merged commit 721f5e6 into main Nov 8, 2026
14 checks passed
@blackopsrepl
blackopsrepl deleted the feature/222-construction-buffers branch November 8, 2026 22:23
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.

Scalar construction allocates its candidate buffers per placement

1 participant