Skip to content

Comments

Cranelift/Wasmtime: disable fastalloc (single-pass) allocator for now.#10554

Merged
cfallin merged 1 commit intobytecodealliance:mainfrom
cfallin:fastalloc-not-compatible-with-exceptions
Apr 9, 2025
Merged

Cranelift/Wasmtime: disable fastalloc (single-pass) allocator for now.#10554
cfallin merged 1 commit intobytecodealliance:mainfrom
cfallin:fastalloc-not-compatible-with-exceptions

Conversation

@cfallin
Copy link
Member

@cfallin cfallin commented Apr 8, 2025

Unfortunately, as discovered by a recent fuzzbug 1, the single-pass register allocator is not compatible with the approach to callsite defs that exception-handling support has forced us to take. In particular, we needed to move all call return-value defs onto the call instruction itself, so calls could be terminators; this unbounded number of defs is made to be a solvable allocation problem by using any constraints, which allow allocation directly into spillslots; but fastalloc appears to error out if it runs out of registers, regardless of this constraint.

Long-term, we should fix this, but unfortunately I don't have cycles to dive into fastalloc's internals at the moment, and it's (I think) a tier-3 feature. As such, this PR disables its use for now. I've filed a tracking issue in RA2 2, and referenced this in the Cranelift configuration option docs at least.

To keep from shifting all fuzzbugs / fuzzing corpii by altering the arbitrary interpretation, I opted to keep the enum the same in the fuzzing crate, and remap SinglePass to Backtracking there. I'm happy to take the other approach and remove the option (thus invalidating all fuzzbugs) if we'd prefer that instead.

@cfallin cfallin requested review from a team as code owners April 8, 2025 22:09
@cfallin cfallin requested review from alexcrichton and fitzgen and removed request for a team April 8, 2025 22:09
@cfallin cfallin force-pushed the fastalloc-not-compatible-with-exceptions branch from c2a4900 to c1ff5b1 Compare April 8, 2025 22:45
@cfallin cfallin enabled auto-merge April 8, 2025 22:45
@cfallin cfallin added this pull request to the merge queue Apr 8, 2025
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Apr 8, 2025
Unfortunately, as discovered by a recent fuzzbug [1], the single-pass
register allocator is not compatible with the approach to callsite
defs that exception-handling support has forced us to take. In
particular, we needed to move all call return-value defs onto the call
instruction itself, so calls could be terminators; this unbounded
number of defs is made to be a solvable allocation problem by using
`any` constraints, which allow allocation directly into spillslots;
but fastalloc appears to error out if it runs out of registers,
regardless of this constraint.

Long-term, we should fix this, but unfortunately I don't have cycles
to dive into fastalloc's internals at the moment, and it's (I think) a
tier-3 feature. As such, this PR disables its use for now. I've
filed a tracking issue in RA2 [2], and referenced this in the
Cranelift configuration option docs at least.

To keep from shifting all fuzzbugs / fuzzing corpii by altering the
`arbitrary` interpretation, I opted to keep the enum the same in the
fuzzing crate, and remap `SinglePass` to `Backtracking` there. I'm
happy to take the other approach and remove the option (thus
invalidating all fuzzbugs) if we'd prefer that instead.

[1]: https://oss-fuzz.com/testcase-detail/5433312476987392
[2]: bytecodealliance/regalloc2#217
@cfallin cfallin force-pushed the fastalloc-not-compatible-with-exceptions branch from c1ff5b1 to 2eeaa2a Compare April 9, 2025 00:01
@cfallin cfallin enabled auto-merge April 9, 2025 00:01
@cfallin cfallin added this pull request to the merge queue Apr 9, 2025
Merged via the queue into bytecodealliance:main with commit d52e23b Apr 9, 2025
41 checks passed
@cfallin cfallin deleted the fastalloc-not-compatible-with-exceptions branch April 9, 2025 00:35
@Robbepop
Copy link
Contributor

@cfallin are there plans to re-introduce Singlepass register allocator back into Wasmtime? I am using Wasmtime in differential fuzzing in Wasmi and was using this register allocator due to very annoying time-out issues during fuzzing.

@cfallin
Copy link
Member Author

cfallin commented Jul 20, 2025

@Robbepop the issue at bytecodealliance/regalloc2#217 describes the issue that is preventing us from re-enabling it. As of right now, I have no time to investigate or fix this; I am oversubscribed on too many other things that are higher-priority and that is unlikely to change for the rest of the year. If you or anyone else are willing to dig in and fix this, it would be very much appreciated!

cfallin added a commit to cfallin/wasmtime that referenced this pull request Aug 25, 2025
github-merge-queue bot pushed a commit that referenced this pull request Aug 25, 2025
…ble and add to testing. (#11533)

* Revert "Cranelift/Wasmtime: disable fastalloc (single-pass) allocator for now. (#10554)"

This reverts commit d52e23b.

* Upgrade to regalloc2 0.13.1.

Pulls in bytecodealliance/regalloc2#233 to update fastalloc to support
the looser constraints needed by exception-related changes.

* cargo-vet update.
bongjunj pushed a commit to prosyslab/wasmtime that referenced this pull request Oct 20, 2025
…ble and add to testing. (bytecodealliance#11533)

* Revert "Cranelift/Wasmtime: disable fastalloc (single-pass) allocator for now. (bytecodealliance#10554)"

This reverts commit d52e23b.

* Upgrade to regalloc2 0.13.1.

Pulls in bytecodealliance/regalloc2#233 to update fastalloc to support
the looser constraints needed by exception-related changes.

* cargo-vet update.
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.

3 participants