Skip to content

Stop at the first conflict when retrying a spilled bundle - #282

Open
kestred wants to merge 1 commit into
bytecodealliance:mainfrom
kestred:retrying-spilled-bundles
Open

kestred wants to merge 1 commit into
bytecodealliance:mainfrom
kestred:retrying-spilled-bundles

Conversation

@kestred

@kestred kestred commented Nov 17, 2026

Copy link
Copy Markdown
Contributor

Fixes #278.

try_allocating_regs_for_spilled_bundles takes a register only when it has no conflict, but it passes
max_allowable_cost: None, so each attempt collects every conflicting bundle and then discards them. Passing
Some(0) stops the scan at the first conflict with a nonzero spill weight.

My ordinary test corpus (~20 programs of various shapes) compile with 0.14% fewer instructions.

For pathological programs, Context::compile with n values live across most of its blocks:

n Before After
4,000 120 ms 18 ms
16,000 3.24 s 85 ms

@fitzgen

fitzgen commented Nov 17, 2026

Copy link
Copy Markdown
Member

Can you do a Sightglass run comparing compilation and benchmark performance with and without this commit, and posting the full output here? Thanks!

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.

perf: retrying spilled bundles for a register is quadratic in the bundles allocated over their range

2 participants