Repository navigation
Do not restart the blockparam_ins walk for every block of a range - #287
Open
bytemaster wants to merge 1 commit into
Open
bytemaster wants to merge 1 commit into
bytemaster wants to merge 1 commit into
Conversation
apply_allocations_and_insert_moves walks blockparam_ins, sorted by (to_vreg, to_block), once for every block whose entry a live range covers, and each of those walks started again from the cursor buffered for the range. Ranges of one vreg can overlap, so the cursor must be re-read per range, but within one range blocks are visited in increasing order: everything a walk steps over is below the key of every later block and cannot match it. Restarting per block therefore only repeated work: a block parameter with T predecessors that stays live across B later blocks cost T * B steps, and L such parameters L * T * B. With two merge points of T edges in one function, B is T for the parameters of the first. Carry the walk's position from block to block within a range. The entries collected and the cursor value handed to PrevBuffer are the same in every case, including the case in which the buffered cursor has already passed a block's entries, so the output is unchanged. bytecodealliance#281 removed the other half of the problem, the cursor that a vreg with a single range left behind for all later vregs. With both, the walk is linear in the number of entries plus the number of (range, block) pairs. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #286, which has the reproduction, the measurements and the argument that the output is unchanged.
apply_allocations_and_insert_movesrestarted its walk ofblockparam_insfrom the buffered cursor for every block a live range covers, so a block parameter with T predecessors that stays live across B later blocks cost T × B steps. This is the part of #274 that remains after #281. The change moves the walk's index out of the per-block loop so that it starts once per range and continues from block to block; within a range blocks are visited in increasing order and the entries are sorted by(vreg, block), so each block's walk collects the same entries and ends at the same index as before.cargo test --all --all-featurespasses.fuzzing::funcgenerator against main: 184,157 functions, equalOutputor the same error for every one, checker accepts.br_tabletargets, two merges: 8.11 s → 1.03 s.🤖 Generated with Claude Code