Skip to content

Refactor graph traversal in GlobalEffects#8593

Open
stevenfontanella wants to merge 3 commits intomainfrom
refactor-global-effects-with-traversal
Open

Refactor graph traversal in GlobalEffects#8593
stevenfontanella wants to merge 3 commits intomainfrom
refactor-global-effects-with-traversal

Conversation

@stevenfontanella
Copy link
Copy Markdown
Member

@stevenfontanella stevenfontanella commented Apr 10, 2026

Refactor GlobalEffects to not compute the transitive call graph explicitly but instead aggregate effects as we go. This improves the runtime of the pass by 4.3% on calcworker (1.21792 s -> 1.16586 s averaged over 20 compilations). It also helps prepare the code for future changes to support effects for indirect calls.

Another potential future improvement here is to use SCC, which would let us stop processing children early in cases where there are no effects to update. Currently we can't do this because we add trap effects to potentially-recursive call loops, so even if no effects were updated, we need to keep going to find potential cycles.

@stevenfontanella stevenfontanella force-pushed the refactor-global-effects-with-traversal branch from 113c475 to a0ec0cf Compare April 10, 2026 22:50
@stevenfontanella stevenfontanella changed the title Refactor to use graph traversal Refactor graph traversal in GlobalEffects Apr 10, 2026
@stevenfontanella stevenfontanella force-pushed the refactor-global-effects-with-traversal branch from a0ec0cf to e7e6e33 Compare April 10, 2026 23:14
@stevenfontanella stevenfontanella marked this pull request as ready for review April 10, 2026 23:17
@stevenfontanella stevenfontanella requested a review from a team as a code owner April 10, 2026 23:17
@stevenfontanella stevenfontanella requested review from tlively and removed request for a team April 10, 2026 23:17
@tlively
Copy link
Copy Markdown
Member

tlively commented Apr 10, 2026

Interesting idea about using the SCCs to further optimize the propagation. We already have a SCC utility that would hopefully make this fairly easy to experiment with. And if we need to detect cycles to add an extra trapping effect, then we could just look for self-edges and nontrivial SCCs. But let's not do that here!

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! Glad to see that this approach speeds things up.

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.

2 participants