Skip to content

NFC: Propagate global effects via strongly-connected components#8607

Merged
stevenfontanella merged 3 commits intomainfrom
effects-scc
Apr 16, 2026
Merged

NFC: Propagate global effects via strongly-connected components#8607
stevenfontanella merged 3 commits intomainfrom
effects-scc

Conversation

@stevenfontanella
Copy link
Copy Markdown
Member

@stevenfontanella stevenfontanella commented Apr 15, 2026

Helps prevent huge visited sets and work queues for edges when traversing large call graphs. After adding support for indirect call effects, the previous algorithm would OOM or timeout when computing global effects for large binaries like calcworker.

Yields a small runtime improvement when tested on calcworker: 0.13451015 -> 0.1328012 (1.3%, averaged from 20 tries with a release build).

Part of #8615.

@stevenfontanella stevenfontanella changed the title Cherrypick SCC changes NFC: Propagate global effects via strongly-connected components Apr 15, 2026
Copy link
Copy Markdown
Member

@tlively tlively left a comment

Choose a reason for hiding this comment

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

Nice, I hadn't even considered that you could just compute a single Effects for each SCC, then flow them along the edges between SCCs, completely avoiding any unbounded fixed point analysis.

@stevenfontanella stevenfontanella marked this pull request as ready for review April 16, 2026 16:22
@stevenfontanella stevenfontanella requested a review from a team as a code owner April 16, 2026 16:22
@stevenfontanella stevenfontanella requested review from tlively and removed request for a team April 16, 2026 16:22
Copy link
Copy Markdown
Member

@tlively tlively left a comment

Choose a reason for hiding this comment

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

What's the performance difference between the status quo and this solution?

Comment thread src/passes/GlobalEffects.cpp Outdated
Comment thread src/passes/GlobalEffects.cpp
Comment thread src/passes/GlobalEffects.cpp Outdated
Comment thread src/passes/GlobalEffects.cpp Outdated
Comment thread src/passes/GlobalEffects.cpp Outdated
@stevenfontanella
Copy link
Copy Markdown
Member Author

stevenfontanella commented Apr 16, 2026

What's the performance difference between the status quo and this solution?

Included that in the description, it's 0.13451015 -> 0.1328012 (1.3% improvement) on calcworker. Also after adding indirect effects (the next PR), the runtime is 0.146778 (+9% slower from main without this PR) (EDIT: after fixing some code, the runtime with indirect effects is about the same). All averaged across 20 runs with a release build.

@kripken
Copy link
Copy Markdown
Member

kripken commented Apr 16, 2026

Are the speedup numbers for this particular pass, or the total workload? (if the latter, which?)

@stevenfontanella
Copy link
Copy Markdown
Member Author

This is from running BINARYEN_PASS_DEBUG=2 bin/wasm-opt -tnh -all --generate-global-effects calcworker_wasm.wasm on the already-optimized calcworker binary from blaze. This is just the runtime for the pass. The number came from output like this:

...
[PassRunner]   running pass: generate-global-effects... [PassRunner] running nested passes
[PassRunner]   running pass: ... 0.132686 seconds.
[PassRunner] nested passes took 0.132686 seconds.

@kripken
Copy link
Copy Markdown
Member

kripken commented Apr 16, 2026

Sounds good about the numbers.

@stevenfontanella stevenfontanella enabled auto-merge (squash) April 16, 2026 22:13
@stevenfontanella stevenfontanella merged commit 2d093c2 into main Apr 16, 2026
16 checks passed
@stevenfontanella stevenfontanella deleted the effects-scc branch April 16, 2026 22:36
@stevenfontanella stevenfontanella linked an issue Apr 17, 2026 that may be closed by this pull request
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.

Improve effects analysis for indirect calls

3 participants