-
-
Notifications
You must be signed in to change notification settings - Fork 14.4k
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
20
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.
Open
Changes from all commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
6bbb18f
Add BranchKey data structure
zetanumbers a946463
Use weak arc pointers to detect unused latches
zetanumbers ce96dee
Format changes
zetanumbers 5cedb3e
Move parallel interfaces to rustc_middle
zetanumbers 4f2548f
Integrate query_branch tracking into parallel interfaces
zetanumbers 3b0f118
Parse query cycle
zetanumbers bc41e68
Parse thread's query stack start
zetanumbers 4b376b7
Finish draft impl of new cycle detection
zetanumbers a7b7743
Clean up unused code for now
zetanumbers dd76578
Get rid of warnings for now
zetanumbers 25bbf74
Simplify query cycle breakage
zetanumbers 4acb93e
Reduce branch precision down to 64 bits
zetanumbers e30613a
Formatting
zetanumbers ad6d117
Fix rustc_codegen_gcc
zetanumbers d0b7e69
Remove commented out code
zetanumbers a4f76cb
Fix miri
zetanumbers 79c2980
Replace scope with join to guarantee task execution order
zetanumbers 21052d0
Fix clippy
zetanumbers 8d090dd
Revert "Replace scope with join to guarantee task execution order"
zetanumbers 0485e5b
Be irresponcible and just check other latch mutex usages
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(u64); | ||
|
|
||
| impl BranchKey { | ||
| pub const fn root() -> Self { | ||
| Self(0x80000000_00000000) | ||
| } | ||
|
|
||
| fn bits_branch(self, branch_num: u64, 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: u64, branch_space: u64) -> 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 = u64::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