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

Delay all sized checks #100971

Closed

Conversation

compiler-errors
Copy link
Member

@compiler-errors compiler-errors commented Aug 24, 2022

Delays all sized checks until we're done with most of typechecking. This is essentially the complete opposite of #100652, motivated by the perf regression that it discovered.

There are changes in diagnostics related to checking all of the sized predicates at once, and due to having far fewer inference vars left over due to this happening near the end of typecheck.

  1. We only report one instance of (e.g.) "the size for values of type [u8] cannot be known at compilation time" per function body. I don't think this is a regression, but instead an improvement, since inference can mean that the same unsized type can show up in multiple places in a body leading to a lot of redundant errors.
  2. Some diagnostics are reordered, but I think that's not a big deal, since a Sized bound failure isn't typically the root cause when other diagnostics are also present in a compilation session.
  3. Some E0282 turned into E0283 and E0284. Some of them didn't get worse but also didn't necessarily get better.
  4. We got a perf win!

@rustbot rustbot added the T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. label Aug 24, 2022
@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 Aug 24, 2022
@rust-log-analyzer

This comment has been minimized.

@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

@bors
Copy link
Contributor

bors commented Aug 24, 2022

⌛ Trying commit 3d5a65274a7dc44d9dfe5e7a98b6b4673a3ee843 with merge 8653b5592eb78d968691adc6922362ff8fd91c7f...

@bors
Copy link
Contributor

bors commented Aug 25, 2022

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

@rust-timer
Copy link
Collaborator

Queued 8653b5592eb78d968691adc6922362ff8fd91c7f with parent ebfc7aa, future comparison URL.

@rust-timer

This comment was marked as outdated.

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-perf Status: Waiting on a perf run to be completed. labels Aug 25, 2022
@compiler-errors
Copy link
Member Author

compiler-errors commented Aug 25, 2022

Hm, I'm suspicious that the bulk of this perf improvement is due to the is_trivially_sized check I added in 919083772bdf63c600b8f68dbbd928cb4be47c09.

That's possibly not sound... so let's try a perf run without it.

@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 Aug 25, 2022
@bors
Copy link
Contributor

bors commented Aug 25, 2022

⌛ Trying commit 655d94af89787fd8a64dfd28687901ed366cfcbe with merge fe579345f67ea488620509c40485b22b387f2ea8...

@rust-log-analyzer

This comment has been minimized.

@bors
Copy link
Contributor

bors commented Aug 25, 2022

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

@rust-timer
Copy link
Collaborator

Queued fe579345f67ea488620509c40485b22b387f2ea8 with parent addacb5, future comparison URL.

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (fe579345f67ea488620509c40485b22b387f2ea8): comparison URL.

Overall result: ❌✅ regressions and improvements - ACTION NEEDED

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

Instruction count

This is a highly reliable metric that was used to determine the overall result at the top of this comment.

mean1 range count2
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
0.5% [0.5%, 0.6%] 4
Improvements ✅
(primary)
-2.6% [-29.0%, -0.3%] 49
Improvements ✅
(secondary)
-17.2% [-65.9%, -0.4%] 21
All ❌✅ (primary) -2.6% [-29.0%, -0.3%] 49

Max RSS (memory usage)

Results

This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.

mean1 range count2
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
4.8% [4.2%, 6.8%] 4
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-3.4% [-3.4%, -3.4%] 1
All ❌✅ (primary) - - 0

Cycles

Results

This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.

mean1 range count2
Regressions ❌
(primary)
2.4% [2.2%, 2.5%] 2
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
-4.8% [-18.5%, -1.6%] 13
Improvements ✅
(secondary)
-28.4% [-52.6%, -2.5%] 10
All ❌✅ (primary) -3.9% [-18.5%, 2.5%] 15

Footnotes

  1. the arithmetic mean of the percent change 2 3

  2. number of relevant changes 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 Aug 25, 2022
@@ -1,3 +1,3 @@
fn main() {
let x = "hello".chars().rev().collect(); //~ ERROR E0282
let x: _ = "hello".chars().rev().collect(); //~ ERROR E0282
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This turned into E0283 for some reason, unless I add this : _ annotation...?

@compiler-errors compiler-errors marked this pull request as ready for review August 25, 2022 20:12
@compiler-errors
Copy link
Member Author

@rustbot ready
r? compiler

@rust-log-analyzer
Copy link
Collaborator

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

Click to see the possible cause of the failure (guessed by this bot)
Testing error-index stage2
doc tests for: /checkout/obj/build/x86_64-unknown-linux-gnu/test/error-index.md


command did not execute successfully: "/checkout/obj/build/bootstrap/debug/rustdoc" "-Wrustdoc::invalid_codeblock_attributes" "-Dwarnings" "-Znormalize-docs" "-Z" "unstable-options" "--test" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/error-index.md" "--test-args" ""

stdout ----

running 1042 tests
---
---- /checkout/obj/build/x86_64-unknown-linux-gnu/test/error-index.md - Rust_Compiler_Error_Index::E0282 (line 5055) stdout ----
error[E0283]: type annotations needed
    --> /checkout/obj/build/x86_64-unknown-linux-gnu/test/error-index.md:5056:5
     |
3    | let x = "hello".chars().rev().collect();
     |     ^                         ------- type must be known at this point
     = note: cannot satisfy `_: FromIterator<char>`
note: required by a bound in `collect`
    --> /checkout/library/core/src/iter/traits/iterator.rs:1832:19
     |
     |
1832 |     fn collect<B: FromIterator<Self::Item>>(self) -> B
help: consider specifying the type argument in the function call
     |
     |
3    | let x = "hello".chars().rev().collect::<B>();

error: aborting due to previous error

For more information about this error, try `rustc --explain E0283`.
For more information about this error, try `rustc --explain E0283`.
Some expected error codes were not found: ["E0282"]
failures:
    /checkout/obj/build/x86_64-unknown-linux-gnu/test/error-index.md - Rust_Compiler_Error_Index::E0282 (line 5055)

test result: FAILED. 1007 passed; 1 failed; 34 ignored; 0 measured; 0 filtered out; finished in 9.00s

@compiler-errors
Copy link
Member Author

Ugh, this causes a weird E0282 regression, because this weird code specific to Sized obligations no longer triggers: https://github.com/rust-lang/rust/blob/master/compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs#L2032-L2043

I think I'm actually fine with this regression, because the difference between E0282 and E0283 is somewhat ambiguous, except for where it gets triggered (during writeback and during trait selection, respectively).

But I think I need to rewrite the E0283 docs to come up with a better example now.

@compiler-errors
Copy link
Member Author

Also, changing when the sized checks are registered apparently changes coercion semantics in the program in surprising ways. I'm gonna crater this for good measure.

@bors try

@bors
Copy link
Contributor

bors commented Aug 27, 2022

⌛ Trying commit 4c8ffb7 with merge 560667b800e34f03ac9f520f299d077c249dd301...

@bors
Copy link
Contributor

bors commented Aug 27, 2022

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

@compiler-errors
Copy link
Member Author

@craterbot check

@craterbot
Copy link
Collaborator

👌 Experiment pr-100971 created and queued.
🤖 Automatically detected try build 560667b800e34f03ac9f520f299d077c249dd301
🔍 You can check out the queue and this experiment's details.

ℹ️ Crater is a tool to run experiments across parts of the Rust ecosystem. Learn more

@craterbot craterbot added S-waiting-on-crater Status: Waiting on a crater run to be completed. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Aug 27, 2022
@craterbot
Copy link
Collaborator

🚧 Experiment pr-100971 is now running

ℹ️ Crater is a tool to run experiments across parts of the Rust ecosystem. Learn more

@craterbot
Copy link
Collaborator

🎉 Experiment pr-100971 is completed!
📊 76 regressed and 5 fixed (242128 total)
📰 Open the full report.

⚠️ If you notice any spurious failure please add them to the blacklist!
ℹ️ Crater is a tool to run experiments across parts of the Rust ecosystem. Learn more

@craterbot craterbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-crater Status: Waiting on a crater run to be completed. labels Aug 28, 2022
@compiler-errors compiler-errors deleted the delay-all-sized-checks branch November 2, 2022 03:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
perf-regression Performance regression. S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. 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.

7 participants