-
Notifications
You must be signed in to change notification settings - Fork 4.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
JIT: Implement greedy RPO-based block layout #101473
Merged
Merged
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
f58556d
WIP: Start greedy RPO layout
amanasifkhalid de7a43a
Implement RPO layout for methods with EH
amanasifkhalid 17fbe7c
Cleanup
amanasifkhalid 1084d7e
Style
amanasifkhalid d1bf04a
Only reorder blocks within same EH region
amanasifkhalid 662258e
Merge branch 'main' into greedy-rpo
amanasifkhalid 98b4bd9
Style
amanasifkhalid 587b5bf
Use full RPO
amanasifkhalid 23c6840
Style
amanasifkhalid ffdf8ad
Fix comment
amanasifkhalid 1d267cd
Add fgMoveColdBlocks
amanasifkhalid 9b08c4e
fgDoReversePostOrderLayout feedback
amanasifkhalid 9dfe4dc
fgMoveColdBlocks feedback
amanasifkhalid 04cecca
Reduce code dup
amanasifkhalid fbea160
Renumber blocks
amanasifkhalid 2abe1a2
Disable by default
amanasifkhalid d2f5ad6
Feedback
amanasifkhalid File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Am I confused, or is this visiting the less likely successor first?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks unintuitive, but I think we need to flip the comparison so the DFS is in the order we want. Consider the following block list, pre-ordering:
When processing
BB02
, if we visitBB03
beforeBB04
, then we end up with an RPO that looks something like[<BB03's successors>, BB03, BB04, BB02, ...]
, so after layout, we get this:If we instead visit the less likely successor (
BB04
) first, we push the more likely successorBB03
up toBB02
in the RPO, and get this layout:There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I think because we're going to form an RPO then visiting the less-likely successor first is correct. If we wanted to view the depth-first spanning tree as a pseudo maximum weight tree then we'd do it the other way around.
Can you add a comment here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure thing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This logic seems very specialized to block layout and tied into how the DFS traversal works to end up with the result it wants. It makes it seem a bit odd for it to live in this very general utility function.
I'm ok with this for now, but if we end up with even more logic to handle other cases (like
BBJ_SWITCH
) then I'd suggest we introduce a separate version of the visitor that lives next to the block layout code. It would save a bit on throughput as well since now everyone is paying for thisuseProfile
check.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed, I'll fix this in a follow-up PR. As for what the new abstraction should look like, would you prefer we move the
useProfile
check intoAllSuccessorEnumerator
, or even introduce a new enumerator likeProfileGuidedSuccessorEnumerator
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps introduce two instance initializer methods on
AllSuccessorEnumerator
and then pass some factory method tofgRunDfs
? E.g. the normal use would be:and the block layout use could be