-
-
Notifications
You must be signed in to change notification settings - Fork 14.1k
Deterministic query cycles for parallel front-end #149849
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
Open
zetanumbers
wants to merge
10
commits into
rust-lang:main
Choose a base branch
from
zetanumbers:deterministic_cycles
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+644
−526
Open
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
c4e51fa
Add BranchKey data structure
zetanumbers 6421df1
Use weak arc pointers to detect unused latches
zetanumbers b8c9b64
Format changes
zetanumbers fbec0ce
Move parallel interfaces to rustc_middle
zetanumbers 0d0f393
Integrate query_branch tracking into parallel interfaces
zetanumbers dd309f7
Parse query cycle
zetanumbers 3e9f52a
Parse thread's query stack start
zetanumbers 963343c
Finish draft impl of new cycle detection
zetanumbers ea43d8b
Clean up unused code for now
zetanumbers 0a5000f
Get rid of warnings for now
zetanumbers 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 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
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,50 @@ | ||
| use std::cmp; | ||
|
|
||
| #[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord)] | ||
| pub struct BranchKey(u128); | ||
|
|
||
| impl BranchKey { | ||
| pub const fn root() -> Self { | ||
| Self(0x80000000_00000000_00000000_00000000) | ||
| } | ||
|
|
||
| fn bits_branch(self, branch_num: u128, bits: u32) -> Result<Self, BranchNestingError> { | ||
| let trailing_zeros = self.0.trailing_zeros(); | ||
| let allocated_shift = trailing_zeros.checked_sub(bits).ok_or(BranchNestingError(()))?; | ||
| Ok(BranchKey( | ||
| self.0 & !(1 << trailing_zeros) | ||
| | (1 << allocated_shift) | ||
| | (branch_num << (allocated_shift + 1)), | ||
| )) | ||
| } | ||
|
|
||
| pub fn branch(self, branch_num: u128, branch_space: u128) -> BranchKey { | ||
| debug_assert!( | ||
| branch_num < branch_space, | ||
| "branch_num = {branch_num} should be less than branch_space = {branch_space}" | ||
| ); | ||
| // floor(log2(n - 1)) + 1 == ceil(log2(n)) | ||
| self.bits_branch(branch_num, (branch_space - 1).checked_ilog2().map_or(0, |b| b + 1)) | ||
| .expect("query branch space is exhausted") | ||
| } | ||
|
|
||
| pub fn disjoint_cmp(self, other: Self) -> cmp::Ordering { | ||
| self.0.cmp(&other.0) | ||
| } | ||
|
|
||
| pub fn nest(self, then: Self) -> Result<Self, BranchNestingError> { | ||
| let trailing_zeros = then.0.trailing_zeros(); | ||
| let branch_num = then.0.wrapping_shr(trailing_zeros + 1); | ||
| let bits = u128::BITS - trailing_zeros; | ||
| self.bits_branch(branch_num, bits) | ||
| } | ||
| } | ||
|
|
||
| #[derive(Debug)] | ||
| pub struct BranchNestingError(()); | ||
|
|
||
| impl Default for BranchKey { | ||
| fn default() -> Self { | ||
| BranchKey::root() | ||
| } | ||
| } |
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
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
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
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
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
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
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
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
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.
Hi, first of all, thank you for your work on this. I can see a lot has been done to address the issue!
Unable to speak about entire implementation since don't know much about this part, but one note on this particular file: the logic seems a bit unclear to me due to the magic numbers and bit manipulations. Even though the file isn't large, adding a few explanatory comments would be a big help for clarity
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.
Also, we'll need a regression test to check it doesn't ICE with these changes