-
-
Notifications
You must be signed in to change notification settings - Fork 16k
Parallel frontend: reproducible def ids for RPITITs #162555
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
susitsm
wants to merge
2
commits into
rust-lang:main
Choose a base branch
from
susitsm:parallel-frontend-162202
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.
+115
−0
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,62 @@ | ||
| //@ needs-target-std | ||
| //@ ignore-cross-compile | ||
| //@ ignore-windows-gnu | ||
| // GNU Linker for Windows is non-deterministic. (from `reproducible-build-2` test in this suite) | ||
|
|
||
| use std::rc::Rc; | ||
|
|
||
| use run_make_support::{rfs, run_in_tmpdir, rustc}; | ||
|
|
||
| /// Test that parallel compiler produces identical binaries. | ||
| fn main() { | ||
| const FILE_NAME: &str = "rpit-issue-162202"; | ||
| let rmeta_name = format!("{FILE_NAME}.rmeta"); | ||
|
|
||
| let mut reference = None; | ||
| let mut reference_stderr = None; | ||
|
|
||
| for _ in 0..10 { | ||
| // Tmp dir as previous runs affect output binary on windows. | ||
| run_in_tmpdir(|| { | ||
| let mut rustc = rustc(); | ||
| rustc | ||
| .input(format!("{FILE_NAME}.rs")) | ||
| .arg("--edition=2024") | ||
| .arg("-Zremap-cwd-prefix=reproducible_dir") | ||
| .arg("-Ccodegen-units=1") | ||
| .arg("-Zthreads=2") | ||
| .arg("--crate-type=lib") | ||
| .emit("metadata") | ||
| .output(&rmeta_name); | ||
|
|
||
| let current_stderr = rustc.run().stderr_utf8(); | ||
|
|
||
| let current = Rc::new(rfs::read(&rmeta_name)); | ||
| reference.get_or_insert(Rc::clone(¤t)); | ||
| let reference_stderr = reference_stderr.get_or_insert_with(|| current_stderr.clone()); | ||
|
|
||
| if Some(current.clone()) != reference { | ||
| let reference_bytes = reference.as_ref().unwrap(); | ||
| let (pos, (left_byte, right_byte)) = current | ||
| .iter() | ||
| .zip(reference_bytes.iter()) | ||
| .enumerate() | ||
| .find(|(_, (c, r))| c != r) | ||
| .unwrap(); | ||
| let range_start = pos.saturating_sub(1); | ||
| let range_end = (pos + 3).min(current.len()).min(reference_bytes.len()); | ||
| panic!( | ||
| "left: {current:x?}\nright: {reference:x?}\n \ | ||
| differs at byte {pos}: left = {left_byte:#x}, right = {right_byte:#x}\n\ | ||
| left range [{range_start}..{range_end}]: {:x?}\n\ | ||
| right range [{range_start}..{range_end}]: {:x?}\n\ | ||
| left stderr:\n{current_stderr}\n\ | ||
| right stderr:\n{reference_stderr}", | ||
| ¤t[range_start..range_end], | ||
| &reference_bytes[range_start..range_end], | ||
| ) | ||
| } | ||
| assert_eq!(Some(current), reference); | ||
| }); | ||
| } | ||
| } |
22 changes: 22 additions & 0 deletions
22
tests/run-make/parallel-reproducible-async-fn/rpit-issue-162202.rs
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,22 @@ | ||
| trait Foo { | ||
| fn test() -> impl IntoIterator<Item = ()> + Send; | ||
| } | ||
|
|
||
| struct A; | ||
| impl Foo for A { | ||
| fn test() -> impl IntoIterator<Item = ()> + Send { | ||
| [] | ||
| } | ||
| } | ||
|
|
||
| struct B; | ||
| impl Foo for B { | ||
| fn test() -> impl IntoIterator<Item = ()> + Send { | ||
| [] | ||
| } | ||
| } | ||
|
|
||
| async fn test1(_: &'_ u8) {} | ||
| async fn test2<'s>(_: &'s u8) {} | ||
|
|
||
| fn main() {} |
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.
Uh oh!
There was an error while loading. Please reload this page.
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.
These calls can be put under
if tcx.sess.opts.jobs.frontend.is_some()to avoid regressing single-threaded performance.View changes since the review
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.
Do
assign_anon_assoc_item_def_ids/remap_opaque_capturescreate the def ids in the same order as single-threadedcheck_type_wf?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.
Not sure, but likely not. The regression seems to come from calling
resolve_bound_varsfor everything.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.
Modified
remap_opaque_capturesto only runresolve_bound_varson the parents of opaques. It solved the problem locally on the biggest regression,typenumThere 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.
Ideally, changing
-j Nto-j Mshould not change the produced binaries (including when N or M is 1).