Skip to content

[Cranelift] rule restore from #13081#13119

Open
myunbin wants to merge 1 commit intobytecodealliance:mainfrom
myunbin:compare-three-restored
Open

[Cranelift] rule restore from #13081#13119
myunbin wants to merge 1 commit intobytecodealliance:mainfrom
myunbin:compare-three-restored

Conversation

@myunbin
Copy link
Copy Markdown
Contributor

@myunbin myunbin commented Apr 16, 2026

This PR restores the rules that were reverted in #13081.

Those rules were reverted because #13068 reported a significant compile-time slowdown. However, after commit f2807a1 (#13063), that severe slowdown no longer reproduces.

On the current commit, d5f1b973, the median real time is 0.17s on plain main and 0.14s on the restored version. For comparison, the historical slow configuration took about 29.89s median real time on the same input. Full benchmark results are included below.

One likely factor is the vector-heavy section of foo.clif, especially around lines 199-242. The original slowdown was observed before vector constant support landed in #13063, so vector self-subtraction patterns such as x - x -> 0, as well as related rewrite rules like (x - z) - (x - y) -> y - z, may have interacted poorly in the earlier configuration. This does not fully explain the entire e-graph blowup, and we're working on to figure it out.

At least from the current measurements, restoring the rules on top of the current codebase does not bring back the compile-time regression. Based on that result, this PR proposes restoring the deleted rules.

Benchmark results

Environments

  • plain_current: commit d5f1b973
  • restored_current: d5f1b973 plus the rules / expected outputs removed by #13081
  • historical_1578325: historical commit 1578325, where the rules were originally present

real Time Comparison

scenario commit / branch runs (s) median mean min max stdev stalled slow vs plain
plain_current d5f1b973 0.18, 0.14, 0.17, 0.15, 0.17 0.17 0.162 0.14 0.18 0.016 0 0 1.00x
restored_current d5f1b973+restored-13081 0.14, 0.16, 0.14, 0.13, 0.13 0.14 0.140 0.13 0.16 0.012 0 0 0.82x
historical_1578325 1578325 29.59, 29.89, 29.71, 30.65, 30.08 29.89 29.984 29.59 30.65 0.416 5 5 175.82x

user Time Comparison

scenario commit / branch runs (s) median mean min max stdev
plain_current d5f1b973 0.17, 0.14, 0.17, 0.13, 0.16 0.16 0.154 0.13 0.17 0.018
restored_current d5f1b973+restored-13081 0.13, 0.15, 0.14, 0.13, 0.14 0.14 0.138 0.13 0.15 0.008
historical_1578325 1578325 28.87, 29.08, 29.00, 29.90, 29.33 29.08 29.236 28.87 29.90 0.407

sys Time Comparison

scenario commit / branch runs (s) median mean min max stdev
plain_current d5f1b973 0.01, 0.00, 0.00, 0.02, 0.01 0.01 0.008 0.00 0.02 0.008
restored_current d5f1b973+restored-13081 0.01, 0.01, 0.00, 0.00, 0.00 0.00 0.004 0.00 0.01 0.005
historical_1578325 1578325 0.72, 0.81, 0.71, 0.76, 0.76 0.76 0.752 0.71 0.81 0.040

@myunbin myunbin requested review from a team as code owners April 16, 2026 01:11
@myunbin myunbin requested review from cfallin and removed request for a team April 16, 2026 01:11
@cfallin
Copy link
Copy Markdown
Member

cfallin commented Apr 16, 2026

Thanks! As mentioned in the revert, I think I'd like to see us understand fully what blew up before putting the rules back in -- in general we prefer affirmative understanding of bugs (to make sure we've fixed them) rather than no-longer-reproduces. (We can fall back on the latter eventually if needed, but in this case, since the blowup is deterministic at a certain commit, it should be possible to work out what rule interaction is happening). Once you've got that, I'm happy to put these back in!

@github-actions github-actions bot added cranelift Issues related to the Cranelift code generator isle Related to the ISLE domain-specific language labels Apr 16, 2026
@github-actions
Copy link
Copy Markdown

Subscribe to Label Action

cc @cfallin, @fitzgen

Details This issue or pull request has been labeled: "cranelift", "isle"

Thus the following users have been cc'd because of the following labels:

  • cfallin: isle
  • fitzgen: isle

To subscribe or unsubscribe from this label, edit the .github/subscribe-to-label.json configuration file.

Learn more.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cranelift Issues related to the Cranelift code generator isle Related to the ISLE domain-specific language

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants