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

Always register a tracing subscriber, even if no env var is set #89623

Closed
wants to merge 1 commit into from

Conversation

oli-obk
Copy link
Contributor

@oli-obk oli-obk commented Oct 7, 2021

If nothing is specified, the log crate emits at least error! messages, tracing would, too, but if we skip the subscriber, it can't do that.

fixes #76824

cc @hawkw @eddyb

@oli-obk
Copy link
Contributor Author

oli-obk commented Oct 7, 2021

@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 Oct 7, 2021
@bors
Copy link
Contributor

bors commented Oct 7, 2021

⌛ Trying commit 79eed33 with merge 7c00e2ea53db975b00c9c2eba31f0e522ec5c284...

@bors
Copy link
Contributor

bors commented Oct 7, 2021

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

1 similar comment
@bors
Copy link
Contributor

bors commented Oct 7, 2021

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

@rust-timer
Copy link
Collaborator

Queued 7c00e2ea53db975b00c9c2eba31f0e522ec5c284 with parent ca8078d, future comparison URL.

@jyn514
Copy link
Member

jyn514 commented Oct 7, 2021

Why register a subscriber that won't emit anything? Are you trying to emit logs programmatically or something?

@oli-obk
Copy link
Contributor Author

oli-obk commented Oct 7, 2021

Sorry, should have written something in the main post, even if I just wanted to gauge the effect of this.

If nothing is specified, the log crate emits at least error! messages, tracing should probably, too, but if we skip the subscriber, it can't do that. This was discovered in #76824

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (7c00e2ea53db975b00c9c2eba31f0e522ec5c284): comparison url.

Summary: This benchmark run did not return any relevant changes.

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 led to changes in compiler perf.

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

@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 Oct 7, 2021
@oli-obk
Copy link
Contributor Author

oli-obk commented Oct 7, 2021

r? rust-lang/compiler

Copy link
Contributor

@hawkw hawkw left a comment

Choose a reason for hiding this comment

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

looks good to me!

Comment on lines -1256 to -1261
// Don't register a dispatcher if there's no filter to print anything
match std::env::var(env) {
Err(_) => return,
Ok(s) if s.is_empty() => return,
Ok(_) => {}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

if we wanted to have a way to completely disable logging, we could consider special-casing RUSTC_LOG=off, instead of "no value", but, since the perf run indicates that the performance difference between "no subscriber" and "levels disabled" is negligable, it's probably not worth messing with...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

it may be more noticeable if debug assertions are turned on, but I have to test that locally. Since I often run with RUSTC_LOG and without, and don't notice something, it can't be too bad though.

@hawkw
Copy link
Contributor

hawkw commented Oct 7, 2021

As a side note, this does not actually fix #76824; only the ERROR level will be enabled by default after this change.

@oli-obk
Copy link
Contributor Author

oli-obk commented Oct 7, 2021

Thanks for actually fixing it

@oli-obk oli-obk closed this Oct 7, 2021
bors pushed a commit to rust-lang-ci/rust that referenced this pull request Oct 8, 2021
This commit changes the `tracing_subscriber` initialization in
`rustc_driver` so that the `WARN` verbosity level is enabled by default
when the `RUSTC_LOG` env variable is empty. If the `RUSTC_LOG` env
variable is set, the filter string in the environment variable is
honored, instead.

Fixes rust-lang#76824
Closes rust-lang#89623

cc @eddyb, @oli-obk
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Oct 9, 2021
rustc_driver: Enable the `WARN` log level by default

This commit changes the `tracing_subscriber` initialization in
`rustc_driver` so that the `WARN` verbosity level is enabled by default
when the `RUSTC_LOG` env variable is empty. If the `RUSTC_LOG` env
variable is set, the filter string in the environment variable is
honored, instead.

Fixes rust-lang#76824
Closes rust-lang#89623

cc `@eddyb,` `@oli-obk`
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Oct 9, 2021
rustc_driver: Enable the `WARN` log level by default

This commit changes the `tracing_subscriber` initialization in
`rustc_driver` so that the `WARN` verbosity level is enabled by default
when the `RUSTC_LOG` env variable is empty. If the `RUSTC_LOG` env
variable is set, the filter string in the environment variable is
honored, instead.

Fixes rust-lang#76824
Closes rust-lang#89623

cc ``@eddyb,`` ``@oli-obk``
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-review Status: Awaiting review from the assignee but also interested parties.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Consider making RUSTC_LOG=warn the default (instead of just error).
7 participants