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

Add RUSTC_PROGRESS env var to show the current queries and their arguments #113888

Closed
wants to merge 1 commit into from

Conversation

oli-obk
Copy link
Contributor

@oli-obk oli-obk commented Jul 20, 2023

This should make debugging hangs much simpler, as you know in which query it's happening.

If compilation progresses, but slowly, this can also be used to actually follow that progress. Most of the time it's too fast and the displayed progress spinners disappear and get replaced by new ones.

The spinners look like the ones from the first example in https://crates.io/crates/indicatif

r? @bjorn3

cc @cjgillot

@rustbot
Copy link
Collaborator

rustbot commented Jul 20, 2023

Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @bjorn3 (or someone else) soon.

Please see the contribution instructions for more information. Namely, in order to ensure the minimum review times lag, PR authors and assigned reviewers should ensure that the review label (S-waiting-on-review and S-waiting-on-author) stays updated, invoking these commands when appropriate:

  • @rustbot author: the review is finished, PR author should check the comments and take action accordingly
  • @rustbot review: the author is ready for a review, this PR will be queued again in the reviewer's queue

@rustbot rustbot added A-query-system Area: The rustc query system (https://rustc-dev-guide.rust-lang.org/query.html) 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. labels Jul 20, 2023
@rustbot
Copy link
Collaborator

rustbot commented Jul 20, 2023

These commits modify the Cargo.lock file. Unintentional changes to Cargo.lock can be introduced when switching branches and rebasing PRs.

If this was unintentional then you should revert the changes before this PR is merged.
Otherwise, you can ignore this comment.

@rust-log-analyzer

This comment has been minimized.

@rustbot rustbot added A-testsuite Area: The testsuite used to check the correctness of rustc T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) labels Jul 20, 2023
@oli-obk
Copy link
Contributor Author

oli-obk commented Jul 20, 2023

@bors try @rust-timer queue

@rust-timer

This comment has been minimized.

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

bors commented Jul 20, 2023

⌛ Trying commit 8f467472de80fdebc0f2cc982ee4a15c8e0498dd with merge 25870bf3850ad5c029b807587de948c07a16612c...

@bors
Copy link
Contributor

bors commented Jul 20, 2023

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

@rust-timer

This comment has been minimized.

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (25870bf3850ad5c029b807587de948c07a16612c): comparison URL.

Overall result: ❌ regressions - 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-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.

mean range count
Regressions ❌
(primary)
7.9% [0.4%, 31.1%] 246
Regressions ❌
(secondary)
10.9% [0.6%, 37.8%] 170
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) 7.9% [0.4%, 31.1%] 246

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.

mean range count
Regressions ❌
(primary)
3.5% [3.3%, 3.6%] 2
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-1.2% [-1.2%, -1.2%] 1
All ❌✅ (primary) 3.5% [3.3%, 3.6%] 2

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.

mean range count
Regressions ❌
(primary)
5.1% [0.6%, 16.7%] 208
Regressions ❌
(secondary)
7.9% [1.0%, 25.1%] 141
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) 5.1% [0.6%, 16.7%] 208

Binary size

This benchmark run did not return any relevant results for this metric.

Bootstrap: 648.618s -> 666.964s (2.83%)

@rustbot rustbot added perf-regression Performance regression. and removed S-waiting-on-perf Status: Waiting on a perf run to be completed. labels Jul 20, 2023
@bjorn3
Copy link
Member

bjorn3 commented Jul 22, 2023

@rustbot author

The regressions will need to be fixed first. I do like the overall idea, but maybe it should be limited to queries that don't finish instantly and have some debouncing and a depth limit to prevent scrolling (which presumably messes up rendering). Also for queries that iterate over items maybe it could be an actual progress bar rather than a spinner.

@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jul 22, 2023
@oli-obk
Copy link
Contributor Author

oli-obk commented Jul 25, 2023

@bors try @rust-timer queue

@rust-timer

This comment has been minimized.

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

bors commented Jul 25, 2023

⌛ Trying commit 39e340c85fd764c56e287febf4f4e044e6fb92dc with merge bbcb061f5a43bcae315f546c35dd15c7f6db9b02...

@oli-obk
Copy link
Contributor Author

oli-obk commented Jul 25, 2023

which presumably messes up rendering

I am fixing this upstream: console-rs/indicatif#563

maybe it should be limited to queries that don't finish instantly and have some debouncing

yea, I'm working on this now.

Also for queries that iterate over items maybe it could be an actual progress bar rather than a spinner.

IMO what we should do is allow any part of rustc to add such progress bars, and have them automatically appear in the right spot (below the query that does the iteration, and above the queries that are called during the iteration)

@bjorn3
Copy link
Member

bjorn3 commented Jul 25, 2023

The try build seems to leave some artifacts behind:

$ echo 'fn main() {}' | RUSTC_PROGRESS=1 rustc +bbcb061f5a43bcae315f546c35dd15c7f6db9b02 -
⠁ analysis                                                                                                                                                                                   ⠁ analysis
⠁ collect_and_partition_mono_items
  └⠁ dep_kind                                                                                                                                                                                ⠁ fn_abi_of_instance                                                                                                                                                                         ⠁ fn_abi_of_instance                                                                                                                                                                         ⠁ fn_abi_of_instance
⠁ fn_abi_of_instance
⠁ fn_abi_of_instance
⠁ fn_abi_of_instance

image

@oli-obk
Copy link
Contributor Author

oli-obk commented Jul 25, 2023

yea, this is fixed in the latest version (not using the indicatif builtin spinner logic, but rolling our own that doesn't race with adding/removing entries).

@oli-obk
Copy link
Contributor Author

oli-obk commented Jul 25, 2023

@rustbot ready

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Jul 25, 2023
@rust-log-analyzer

This comment has been minimized.

@bjorn3
Copy link
Member

bjorn3 commented Jul 25, 2023

yea, this is fixed in the latest version (not using the indicatif builtin spinner logic, but rolling our own that doesn't race with adding/removing entries).

Great! Currently building it locally to play around with it a bit. Just a random thought I came up with: Could this reuse the self-profile infrastructure? So every time a start self-profile event is emitted a spinner is added and every time an end event is emitted a spinner is removed. Or is there a mismatch between the semantics of self-profile and this progress thing?

@@ -1506,6 +1511,8 @@ pub fn build_session(
let asm_arch =
if target_cfg.allow_asm { InlineAsmArch::from_str(&target_cfg.arch).ok() } else { None };

let progress_bars = std::env::var_os("RUSTC_PROGRESS").map(|_| Session::init_progress_bars());
Copy link
Member

Choose a reason for hiding this comment

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

Maybe check if the value is not 0 to allow disabling it using RUSTC_PROGRESS=0?

@bjorn3
Copy link
Member

bjorn3 commented Jul 25, 2023

Tried it on cranelift-codegen and almost all of the time it only shows analysis as only spinner and the spinner itself doesn't spin most of the time and at the end it leaves behind the ⠄ analysis of the spinner and for echo 'fn main() {}' | RUSTC_PROGRESS=1 rustc - it now doesn't show any spinner at all.

@oli-obk
Copy link
Contributor Author

oli-obk commented Jul 25, 2023

for echo 'fn main() {}' | RUSTC_PROGRESS=1 rustc - it now doesn't show any spinner at all.

probably because it finishes in under 100ms 😆 so it never gets rendered

@oli-obk
Copy link
Contributor Author

oli-obk commented Jul 25, 2023

Tried it on cranelift-codegen and almost all of the time it only shows analysis as only spinner and the spinner itself doesn't spin most of the time and at the end it leaves behind the ⠄ analysis of the spinner

I never tested it with cargo. There may be collisions with cargo's own output

@bjorn3
Copy link
Member

bjorn3 commented Jul 25, 2023

It doesn't seem to show up at all with cargo, so I had to manually run the command that cargo would run. It also seems to have some issues when diagnostics get printed.

@bjorn3
Copy link
Member

bjorn3 commented Jul 25, 2023

for echo 'fn main() {}' | RUSTC_PROGRESS=1 rustc - it now doesn't show any spinner at all.

probably because it finishes in under 100ms laughing so it never gets rendered

Maybe a snapshot of the current queries every 100ms would be more useful? Or showing repeated invocations of the same query if they add up to more than 100ms (so eg the typeck query will show up even if every every individual function gets typechecked in 99ms)

@oli-obk
Copy link
Contributor Author

oli-obk commented Jul 25, 2023

It doesn't seem to show up at all with cargo, so I had to manually run the command that cargo would run. It also seems to have some issues when diagnostics get printed.

yes, I'm refactoring some stuff to get rid of the issue around diagnostics and other rustc output: #114054

@oli-obk
Copy link
Contributor Author

oli-obk commented Jul 26, 2023

Maybe a snapshot of the current queries every 100ms would be more useful?

that's what happens

Or showing repeated invocations of the same query if they add up to more than 100ms (so eg the typeck query will show up even if every every individual function gets typechecked in 99ms)

That's a different territory that I want to do later. Basically accumulate -Ztime-passes style information live instead of printing the information later.

@bjorn3
Copy link
Member

bjorn3 commented Jul 26, 2023

Maybe a snapshot of the current queries every 100ms would be more useful?

that's what happens

Why does it not show any queries besides analysis then for the entire time? The odds of every single 100ms snapshot of a 10+ second compilation containing no queries besides analysis is extremely low, right?

@bjorn3
Copy link
Member

bjorn3 commented Jul 26, 2023

Or showing repeated invocations of the same query if they add up to more than 100ms (so eg the typeck query will show up even if every every individual function gets typechecked in 99ms)

That's a different territory that I want to do later. Basically accumulate -Ztime-passes style information live instead of printing the information later.

👍

@oli-obk
Copy link
Contributor Author

oli-obk commented Jul 26, 2023

Why does it not show any queries besides analysis then for the entire time? The odds of every single 100ms snapshot of a 10+ second compilation containing no queries besides analysis is extremely low, right?

Ah I missed something here. You should not really see anything for hello world, as it's too fast. Longer builds should show a nice stack where stuff spins. If the spinner isn't running at all, something is very wrong. I am seeing it work locally for a test with a long running const evaluation. Maybe your build is really fast in rustc and just takes a long time in codegen?

@bjorn3
Copy link
Member

bjorn3 commented Jul 26, 2023

Maybe your build is really fast in rustc and just takes a long time in codegen?

According to -Zself-profile analysis took 34s on cranelift_codegen. This time I did see proc_macro_decls_static as sub query, but that one only takes 1.4s according to -Zself-profile and I saw it for several seconds. Also the analysis spinner was still shown (and not spinning at that time) while it was doing codegen. I saw the cursor move a couple of times, so indicatif was still redrawing.

@bors
Copy link
Contributor

bors commented Aug 7, 2023

☔ The latest upstream changes (presumably #114565) made this pull request unmergeable. Please resolve the merge conflicts.

@apiraino
Copy link
Contributor

Switching to waiting on author for a rebase and (I think) to address Qs in the latest comments. Feel free to request a review with @rustbot ready, thanks!

@rustbot author

@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Aug 24, 2023
@rustbot
Copy link
Collaborator

rustbot commented Oct 5, 2023

Third-party dependency whitelist may have been modified! You must ensure that any new dependencies have compatible licenses before merging.

cc @davidtwco, @wesleywiser

@davidtwco
Copy link
Member

Third-party dependency whitelist may have been modified! You must ensure that any new dependencies have compatible licenses before merging.

cc @davidtwco, @wesleywiser

Licenses of all these dependencies seem good to me.

@bors
Copy link
Contributor

bors commented Feb 14, 2024

☔ The latest upstream changes (presumably #120454) made this pull request unmergeable. Please resolve the merge conflicts.

@oli-obk
Copy link
Contributor Author

oli-obk commented Mar 14, 2024

I haven't found the motivation to work on this in 6 months, gonna accept I won't be finding it again any time soon

@oli-obk oli-obk closed this Mar 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-query-system Area: The rustc query system (https://rustc-dev-guide.rust-lang.org/query.html) A-testsuite Area: The testsuite used to check the correctness of rustc perf-regression Performance regression. S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) 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.

8 participants