cfallin opened PR #13390 from cfallin:egraph-fuel to bytecodealliance:main:
This addresses the kind of blowup seen in #13068 (and analyzed in #13204). Specifically, even though we limit the rewrite depth, and size of eclasses, one can still get into situations where the Cartesian product of match possibilities on the left-hand side blows up.
The ISLE rules in the mid-end are compiled to Rust that loops over iterators over each eclass, so if we limit what those iterators can return, we can limit the only dynamic factor in the runtime of the ruleset. This PR implements "fuel" that imposes a hard cutoff of 500 LHS matches per top-level rewrite invocation, with iterators returning
Noneafterward. The mid-end failing to find a match is always OK -- it just means that we don't rewrite/optimize -- so cutting off early is always a correct/valid choice.The cutoff limit of 500 might seem a little high at first glance, but note that this is every LHS match; including e.g. in sub-matchers; 50 turned out to miss a few rewrites in our tests, so I turned the knob up to 500. This is still sufficient to limit the blowup case shown in #13068 from 2.31s to 0.01s, with RSS decreasing from 855 MiB to 17 MiB, which is a significant win.
Fixes #13204.
<!--
Please make sure you include the following information:
If this work has been discussed elsewhere, please include a link to that
conversation. If it was discussed in an issue, just mention "issue #...".Explain why this change is needed. If the details are in an issue already,
this can be brief.Our development process is documented in the Wasmtime book:
https://docs.wasmtime.dev/contributing-development-process.htmlPlease ensure all communication follows the code of conduct:
https://github.com/bytecodealliance/wasmtime/blob/main/CODE_OF_CONDUCT.md
-->
cfallin requested fitzgen for a review on PR #13390.
cfallin requested wasmtime-compiler-reviewers for a review on PR #13390.
github-actions[bot] added the label cranelift on PR #13390.
:thumbs_up: fitzgen submitted PR review:
Thanks!
:speech_balloon: fitzgen created PR review comment:
Maybe call this
EXTRACTOR_FUEL? I think that makes the underlying mechanism more clear.
cfallin updated PR #13390.
:memo: cfallin submitted PR review.
:speech_balloon: cfallin created PR review comment:
Done!
cfallin has enabled auto merge for PR #13390.
cfallin added PR #13390 Cranelift: add "fuel" to egraph rewrites. to the merge queue
:check: cfallin merged PR #13390.
cfallin removed PR #13390 Cranelift: add "fuel" to egraph rewrites. from the merge queue
Last updated: Jun 01 2026 at 09:49 UTC