Skip to content

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

Merged
cfallin merged 1 commit into
bytecodealliance:mainfrom
kestred:retrying-spilled-bundles
Nov 23, 2026
Merged

cfallin merged 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!

@kestred

kestred commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor Author

@fitzgen runs for #282


MacBook Pro, Apple M5 Pro, 18 cores, 64 GB, macOS 26.6.2, arm64

Default suite (29 programs), 100 iterations, significance level 0.01

* Compilation, instructions retired: geomean -0.46% (99% confidence); total counts -0.53%
  * Programs reported faster (22 out of 29)
    * shootout-keccak      -8.00%
    * tinygo-regex         -2.10%
    * libsodium-siphashx24 -1.25%
    * libsodium-hash3      -1.22%
    * libsodium-keygen     -0.87%
    * libsodium-core5      -0.77%
* Execution, instructions retired: geomean +0.01% (not significant);
* Compilation, cycles: -0.7% (99% confidence)

These two are the most significant per-program change,
but are still reported as "No difference in performance." at p < 0.01.

    * splay                +1.96%
    * shootout-heapsort    +1.50%

AMD EPYC-Genoa, 16 vCPUs, 30 GB, Ubuntu 26.04.1 LTS, x86_64

Default suite (29 programs), 10 iterations, significance level 0.01, parallel compilation off

* Compilation, instructions retired: geomean -1.34% (99% confidence); total counts -1.16%
  * Programs reported faster (29 out of 29)
     * shootout-keccak -12.33%
     * tinygo-regex -2.25%
     * libsodium-hash3 -2.16%
     * libsodium-siphashx24 -1.73%
     * libsodium-core5 -1.73%
     * libsodium-keygen -1.64%
     * shootout-xchacha20 -1.54%
     * starlingmonkey-markdown -1.18%
* Execution, instructions retired: geomean -0.0004% (not significant)
* Compilation, cycles: -3.0% geomean (99% confidence; shared box, load ~1)

@cfallin cfallin left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! The change makes sense in theory, and 1.18% compilation speedup on SpiderMonkey is nothing to sneeze at.

@cfallin
cfallin merged commit 94bbb29 into bytecodealliance:main Nov 23, 2026
6 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.

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

3 participants