Skip to content

perf: Iterate dataflow blocks in traversal order [pathological loop/await CFGs -52%/-82%; primary ~neutral] - #76

Draft
xmakro wants to merge 1 commit into
perf/base-0713from
perf/dataflow-traversal-order
Draft

perf: Iterate dataflow blocks in traversal order [pathological loop/await CFGs -52%/-82%; primary ~neutral]#76
xmakro wants to merge 1 commit into
perf/base-0713from
perf/dataflow-traversal-order

Conversation

@xmakro

@xmakro xmakro commented Jul 31, 2026

Copy link
Copy Markdown
Owner

The dataflow fixpoint seeds its work queue in reverse postorder, but the queue itself is a plain FIFO, so on loop-heavy control flow graphs it degenerates into breadth-first iteration and revisits blocks many more times than it needs to. This replaces it with a queue that yields dirty blocks in traversal-order sweeps, tracking dirtiness in a bitset keyed by traversal position and walking it with a cursor instead of pushing and popping a deque. Blocks with no traversal position, which only backward analyses reach via predecessors of unreachable blocks, are drained separately after the ordered sweep.

A strict "always take the lowest position" rule was tried first and rejected. It is considerably worse than the current FIFO on a block joined from many back edges, such as a coroutine resume dispatch, because it returns to the join once per back edge rather than once per sweep.

The fixpoint result is unchanged: a monotone dataflow fixpoint does not depend on iteration order, and this was checked against the old queue over randomly generated control flow graphs in both directions. tests/ui and tests/incremental both pass.

@xmakro xmakro changed the title perf: Iterate dataflow blocks in traversal order perf: Iterate dataflow blocks in traversal order [pathological loop/await CFGs -52%/-82%; primary ~neutral] Aug 1, 2026
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.

1 participant