Skip to content
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

Split out the various responsibilities of rustc_metadata::Lazy #97291

Merged

Conversation

compiler-errors
Copy link
Member

Lazy<T> actually acts like three different types -- a pointer in the crate metadata to a single value, a pointer to a list/array of values, and an indexable pointer of a list of values (a table).

We currently overload Lazy<T> to work differently than Lazy<[T]> and the same for Lazy<Table<I, T>>. All is well with some helper adapter traits such as LazyQueryDecodable and EncodeContentsForLazy.

Well, changes in #97287 that make Lazy work with the now invariant lifetime 'tcx make these adapters fall apart because of coherence reasons. So we split out these three types and rework some of the helper traits so it's both 1. more clear to understand, and 2. compatible with the changes later in that PR.

Split out from #97287 so it can be reviewed separately, since this PR stands on its own.

@rustbot rustbot added the T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. label May 22, 2022
@rust-highfive
Copy link
Collaborator

r? @wesleywiser

(rust-highfive has picked a reviewer for you, use r? to override)

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label May 22, 2022
@compiler-errors compiler-errors force-pushed the lazy-is-actually-3-types-in-a-trenchcoat branch from 791765c to 30323cc Compare May 22, 2022 23:48
@cjgillot
Copy link
Contributor

@bors try @rust-timer queue

@rust-timer
Copy link
Collaborator

Awaiting bors try build completion.

@rustbot label: +S-waiting-on-perf

@rustbot rustbot added the S-waiting-on-perf Status: Waiting on a perf run to be completed. label May 23, 2022
@bors
Copy link
Contributor

bors commented May 23, 2022

⌛ Trying commit 30323cc40d0af9bd158a823d2a8818b26f8d269f with merge 48a331d69e217e5bec16e805669ffe759820ba8d...

@bors
Copy link
Contributor

bors commented May 23, 2022

☀️ Try build successful - checks-actions
Build commit: 48a331d69e217e5bec16e805669ffe759820ba8d (48a331d69e217e5bec16e805669ffe759820ba8d)

@rust-timer
Copy link
Collaborator

Queued 48a331d69e217e5bec16e805669ffe759820ba8d with parent 32c8c5d, future comparison URL.

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (48a331d69e217e5bec16e805669ffe759820ba8d): comparison url.

Instruction count

  • Primary benchmarks: 😿 relevant regressions found
  • Secondary benchmarks: mixed results
Regressions 😿
(primary)
Regressions 😿
(secondary)
Improvements 🎉
(primary)
Improvements 🎉
(secondary)
All 😿 🎉
(primary)
count1 19 21 0 1 19
mean2 0.5% 1.1% N/A -0.3% 0.5%
max 1.6% 1.6% N/A -0.3% 1.6%

Max RSS (memory usage)

Results
  • Primary benchmarks: mixed results
  • Secondary benchmarks: mixed results
Regressions 😿
(primary)
Regressions 😿
(secondary)
Improvements 🎉
(primary)
Improvements 🎉
(secondary)
All 😿 🎉
(primary)
count1 1 6 1 5 2
mean2 1.9% 1.4% -1.0% -1.5% 0.4%
max 1.9% 2.5% -1.0% -2.0% 1.9%

Cycles

Results
  • Primary benchmarks: no relevant changes found
  • Secondary benchmarks: 😿 relevant regressions found
Regressions 😿
(primary)
Regressions 😿
(secondary)
Improvements 🎉
(primary)
Improvements 🎉
(secondary)
All 😿 🎉
(primary)
count1 0 7 0 0 0
mean2 N/A 2.0% N/A N/A N/A
max N/A 2.2% N/A N/A N/A

If you disagree with this performance assessment, please file an issue in rust-lang/rustc-perf.

Benchmarking this pull request likely means that it is perf-sensitive, so we're automatically marking it as not fit for rolling up. While you can manually mark this PR as fit for rollup, we strongly recommend not doing so since this PR may lead to changes in compiler perf.

Next Steps: If you can justify the regressions found in this try perf run, please indicate this with @rustbot label: +perf-regression-triaged along with sufficient written justification. If you cannot justify the regressions please fix the regressions and do another perf run. If the next run shows neutral or positive results, the label will be automatically removed.

@bors rollup=never
@rustbot label: +S-waiting-on-review -S-waiting-on-perf +perf-regression

Footnotes

  1. number of relevant changes 2 3

  2. the arithmetic mean of the percent change 2 3

@rustbot rustbot added perf-regression Performance regression. and removed S-waiting-on-perf Status: Waiting on a perf run to be completed. labels May 23, 2022
@jackh726
Copy link
Member

Slight regression, but I think it's mild enough. Combined with the clarity wins and unblocking of future work, I think we just land.

@compiler-errors
Copy link
Member Author

I'm gonna try to slap some inline(always) onto the new query post-decode trait I introduced, but if that yields no benefit, then I'll chalk it up to noise.

@compiler-errors compiler-errors force-pushed the lazy-is-actually-3-types-in-a-trenchcoat branch from 30323cc to 2b5e592 Compare May 24, 2022 02:50
@compiler-errors
Copy link
Member Author

@bors try @rust-timer queue

@rust-timer
Copy link
Collaborator

Awaiting bors try build completion.

@rustbot label: +S-waiting-on-perf

@rustbot rustbot added the S-waiting-on-perf Status: Waiting on a perf run to be completed. label May 24, 2022
@bors
Copy link
Contributor

bors commented May 24, 2022

⌛ Trying commit 2b5e592 with merge a9dc794e2e93c93fb228ae43a6ca17eb4192ff7d...

@bors
Copy link
Contributor

bors commented May 24, 2022

☀️ Try build successful - checks-actions
Build commit: a9dc794e2e93c93fb228ae43a6ca17eb4192ff7d (a9dc794e2e93c93fb228ae43a6ca17eb4192ff7d)

@rust-timer
Copy link
Collaborator

Queued a9dc794e2e93c93fb228ae43a6ca17eb4192ff7d with parent ee160f2, future comparison URL.

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (a9dc794e2e93c93fb228ae43a6ca17eb4192ff7d): comparison url.

Instruction count

  • Primary benchmarks: 🎉 relevant improvement found
  • Secondary benchmarks: mixed results
Regressions 😿
(primary)
Regressions 😿
(secondary)
Improvements 🎉
(primary)
Improvements 🎉
(secondary)
All 😿 🎉
(primary)
count1 0 4 1 11 1
mean2 N/A 0.8% -0.3% -0.3% -0.3%
max N/A 1.0% -0.3% -0.3% -0.3%

Max RSS (memory usage)

Results
  • Primary benchmarks: mixed results
  • Secondary benchmarks: mixed results
Regressions 😿
(primary)
Regressions 😿
(secondary)
Improvements 🎉
(primary)
Improvements 🎉
(secondary)
All 😿 🎉
(primary)
count1 2 4 1 2 3
mean2 5.2% 2.1% -3.3% -1.8% 2.4%
max 7.1% 3.1% -3.3% -2.1% 7.1%

Cycles

Results
  • Primary benchmarks: mixed results
  • Secondary benchmarks: 🎉 relevant improvements found
Regressions 😿
(primary)
Regressions 😿
(secondary)
Improvements 🎉
(primary)
Improvements 🎉
(secondary)
All 😿 🎉
(primary)
count1 8 0 6 7 14
mean2 3.2% N/A -1.8% -2.1% 1.0%
max 7.1% N/A -2.6% -3.1% 7.1%

If you disagree with this performance assessment, please file an issue in rust-lang/rustc-perf.

Benchmarking this pull request likely means that it is perf-sensitive, so we're automatically marking it as not fit for rolling up. While you can manually mark this PR as fit for rollup, we strongly recommend not doing so since this PR may lead to changes in compiler perf.

@bors rollup=never
@rustbot label: +S-waiting-on-review -S-waiting-on-perf -perf-regression

Footnotes

  1. number of relevant changes 2 3

  2. the arithmetic mean of the percent change 2 3

@rustbot rustbot removed S-waiting-on-perf Status: Waiting on a perf run to be completed. perf-regression Performance regression. labels May 24, 2022
@compiler-errors
Copy link
Member Author

compiler-errors commented May 24, 2022

Okay, well fixing the incorrect size_hint implementation and adding some inlines did the trick I guess.

@cjgillot
Copy link
Contributor

@bors r+

@bors
Copy link
Contributor

bors commented May 24, 2022

📌 Commit 2b5e592 has been approved by cjgillot

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels May 24, 2022
@bors
Copy link
Contributor

bors commented May 24, 2022

⌛ Testing commit 2b5e592 with merge ee9726c...

@bors
Copy link
Contributor

bors commented May 24, 2022

☀️ Test successful - checks-actions
Approved by: cjgillot
Pushing ee9726c to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label May 24, 2022
@bors bors merged commit ee9726c into rust-lang:master May 24, 2022
@rustbot rustbot added this to the 1.63.0 milestone May 24, 2022
@rust-log-analyzer
Copy link
Collaborator

The job x86_64-gnu-llvm-12 failed! Check out the build log: (web) (plain)

Click to see the possible cause of the failure (guessed by this bot)
...i....F.............................................i................................
Some tests failed in compiletest suite=mir-opt mode=mir-opt host=x86_64-unknown-linux-gnu target=x86_64-unknown-linux-gnu
failures:

---- [mir-opt] src/test/mir-opt/inline/inline-generator.rs stdout ----
30 +         let mut _10: bool;               // in scope 6 at $DIR/inline-generator.rs:15:9: 15:9
31 +         let _11: bool;                   // in scope 6 at $DIR/inline-generator.rs:15:6: 15:7
32 +         let mut _12: u32;                // in scope 6 at $DIR/inline-generator.rs:15:5: 15:41
- +         let mut _13: &mut [generator@$DIR/inline-generator.rs:15:5: 15:41]; // in scope 6 at $DIR/inline-generator.rs:15:5: 15:41
- +         let mut _14: &mut [generator@$DIR/inline-generator.rs:15:5: 15:41]; // in scope 6 at $DIR/inline-generator.rs:15:5: 15:41
- +         let mut _15: &mut [generator@$DIR/inline-generator.rs:15:5: 15:41]; // in scope 6 at $DIR/inline-generator.rs:15:5: 15:41
37   
38       bb0: {


76 +         StorageLive(_10);                // scope 0 at $DIR/inline-generator.rs:9:14: 9:46
77 +         StorageLive(_11);                // scope 0 at $DIR/inline-generator.rs:9:14: 9:46
78 +         StorageLive(_12);                // scope 0 at $DIR/inline-generator.rs:9:14: 9:46
- +         StorageLive(_13);                // scope 6 at $DIR/inline-generator.rs:15:5: 15:41
- +         _13 = move (_2.0: &mut [generator@$DIR/inline-generator.rs:15:5: 15:41]); // scope 6 at $DIR/inline-generator.rs:15:5: 15:41
- +         _12 = discriminant((*_13));      // scope 6 at $DIR/inline-generator.rs:15:5: 15:41
- +         StorageDead(_13);                // scope 6 at $DIR/inline-generator.rs:15:5: 15:41
+ +         _12 = discriminant((*(_2.0: &mut [generator@$DIR/inline-generator.rs:15:5: 15:41]))); // scope 6 at $DIR/inline-generator.rs:15:5: 15:41
83 +         switchInt(move _12) -> [0_u32: bb3, 1_u32: bb8, 3_u32: bb7, otherwise: bb9]; // scope 6 at $DIR/inline-generator.rs:15:5: 15:41
85   


124 +         Deinit(_1);                      // scope 6 at $DIR/inline-generator.rs:15:11: 15:39
125 +         ((_1 as Yielded).0: i32) = move _8; // scope 6 at $DIR/inline-generator.rs:15:11: 15:39
126 +         discriminant(_1) = 0;            // scope 6 at $DIR/inline-generator.rs:15:11: 15:39
- +         StorageLive(_14);                // scope 6 at $DIR/inline-generator.rs:15:11: 15:39
- +         _14 = move (_2.0: &mut [generator@$DIR/inline-generator.rs:15:5: 15:41]); // scope 6 at $DIR/inline-generator.rs:15:11: 15:39
- +         discriminant((*_14)) = 3;        // scope 6 at $DIR/inline-generator.rs:15:11: 15:39
- +         StorageDead(_14);                // scope 6 at $DIR/inline-generator.rs:15:11: 15:39
+ +         discriminant((*(_2.0: &mut [generator@$DIR/inline-generator.rs:15:5: 15:41]))) = 3; // scope 6 at $DIR/inline-generator.rs:15:11: 15:39
131 +         goto -> bb1;                     // scope 0 at $DIR/inline-generator.rs:15:11: 15:39
133 + 


138 +         Deinit(_1);                      // scope 6 at $DIR/inline-generator.rs:15:41: 15:41
139 +         ((_1 as Complete).0: bool) = move _10; // scope 6 at $DIR/inline-generator.rs:15:41: 15:41
140 +         discriminant(_1) = 1;            // scope 6 at $DIR/inline-generator.rs:15:41: 15:41
- +         StorageLive(_15);                // scope 6 at $DIR/inline-generator.rs:15:41: 15:41
- +         _15 = move (_2.0: &mut [generator@$DIR/inline-generator.rs:15:5: 15:41]); // scope 6 at $DIR/inline-generator.rs:15:41: 15:41
- +         discriminant((*_15)) = 1;        // scope 6 at $DIR/inline-generator.rs:15:41: 15:41
- +         StorageDead(_15);                // scope 6 at $DIR/inline-generator.rs:15:41: 15:41
+ +         discriminant((*(_2.0: &mut [generator@$DIR/inline-generator.rs:15:5: 15:41]))) = 1; // scope 6 at $DIR/inline-generator.rs:15:41: 15:41
145 +         goto -> bb1;                     // scope 0 at $DIR/inline-generator.rs:15:41: 15:41
147 + 


thread '[mir-opt] src/test/mir-opt/inline/inline-generator.rs' panicked at 'Actual MIR output differs from expected MIR output /checkout/src/test/mir-opt/inline/inline_generator.main.Inline.diff', src/tools/compiletest/src/runtest.rs:3410:25


failures:
    [mir-opt] src/test/mir-opt/inline/inline-generator.rs

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (ee9726c): comparison url.

Instruction count

  • Primary benchmarks: no relevant changes found
  • Secondary benchmarks: 😿 relevant regressions found
Regressions 😿
(primary)
Regressions 😿
(secondary)
Improvements 🎉
(primary)
Improvements 🎉
(secondary)
All 😿 🎉
(primary)
count1 0 7 0 0 0
mean2 N/A 1.0% N/A N/A N/A
max N/A 1.1% N/A N/A N/A

Max RSS (memory usage)

Results
  • Primary benchmarks: no relevant changes found
  • Secondary benchmarks: mixed results
Regressions 😿
(primary)
Regressions 😿
(secondary)
Improvements 🎉
(primary)
Improvements 🎉
(secondary)
All 😿 🎉
(primary)
count1 0 3 0 1 0
mean2 N/A 1.6% N/A -1.5% N/A
max N/A 2.5% N/A -1.5% N/A

Cycles

Results
  • Primary benchmarks: 🎉 relevant improvement found
  • Secondary benchmarks: 🎉 relevant improvement found
Regressions 😿
(primary)
Regressions 😿
(secondary)
Improvements 🎉
(primary)
Improvements 🎉
(secondary)
All 😿 🎉
(primary)
count1 0 0 1 1 1
mean2 N/A N/A -2.3% -6.3% -2.3%
max N/A N/A -2.3% -6.3% -2.3%

If you disagree with this performance assessment, please file an issue in rust-lang/rustc-perf.

@rustbot label: -perf-regression

Footnotes

  1. number of relevant changes 2 3

  2. the arithmetic mean of the percent change 2 3

@compiler-errors compiler-errors deleted the lazy-is-actually-3-types-in-a-trenchcoat branch August 11, 2023 20:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
merged-by-bors This PR was explicitly merged by bors. S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants