-
Notifications
You must be signed in to change notification settings - Fork 758
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
When using tracing-log, log::log_enabled!
is always true
#1249
Comments
I believe this issue will be resolved in #1248. |
@davidbarsky yeah, I'm going to keep this open until I get it backported and @pchickey can confirm that it resolves the problem. |
Depends on #1247. Since `tracing-subscriber`'s `init` and `try_init` functions set the global default collector, we can use the collector's max-level hint as the max level for the log crate, as well. This should significantly improve performance for skipping `log` records that fall below the collector's max level, as they will not have to call the `LogTracer::enabled` method. This will prevent issues like bytecodealliance/wasmtime#2662 from occurring in the future. See also #1249. In order to implement this, I also changed the `FmtCollector`'s `try_init` to just use `util::SubscriberInitExt`'s `try_init` function, so that the same code isn't duplicated in multiple places. I also added `AsLog` and `AsTrace` conversions for `LevelFilter`s in the `tracing-log` crate. Signed-off-by: Eliza Weisman <eliza@buoyant.io>
Depends on #1247. Since `tracing-subscriber`'s `init` and `try_init` functions set the global default subscriber, we can use the subscriber's max-level hint as the max level for the log crate, as well. This should significantly improve performance for skipping `log` records that fall below the collector's max level, as they will not have to call the `LogTracer::enabled` method. This will prevent issues like bytecodealliance/wasmtime#2662 from occurring in the future. See also #1249. In order to implement this, I also changed the `FmtSubscriber`'s `try_init` to just use `util::SubscriberInitExt`'s `try_init` function, so that the same code isn't duplicated in multiple places. I also added `AsLog` and `AsTrace` conversions for `LevelFilter`s in the `tracing-log` crate. Signed-off-by: Eliza Weisman <eliza@buoyant.io>
@pchickey okay, you should be able to test this out with a git dependency on this branch: #1250 I believe you will have to patch the |
Unfortunately the backport branch (#1250) isn't quite working yet. Alex put together this https://gist.github.com/alexcrichton/bfaa02d0833e1a95709e3432a1d18c46to reproduce it - |
Ah, looks like there's actually just two bugs here. I added some
It looks like the use tracing_subscriber::prelude::*;
tracing_subscriber::registry()
.with(tracing_subscriber::fmt::layer())
.with(tracing_subscriber::EnvFilter::from_default_env())
.init(); everything works correctly, and "log level enabled" is not printed. This should be pretty easy to fix: we just want to ensure that method is forwarded in the |
#1251 fixes the I'm going to go ahead and merge the backport branch, since it does in fact fix the issue, except when using the |
Depends on #1247. Since `tracing-subscriber`'s `init` and `try_init` functions set the global default subscriber, we can use the subscriber's max-level hint as the max level for the log crate, as well. This should significantly improve performance for skipping `log` records that fall below the collector's max level, as they will not have to call the `LogTracer::enabled` method. This will prevent issues like bytecodealliance/wasmtime#2662 from occurring in the future. See also #1249. In order to implement this, I also changed the `FmtSubscriber`'s `try_init` to just use `util::SubscriberInitExt`'s `try_init` function, so that the same code isn't duplicated in multiple places. I also added `AsLog` and `AsTrace` conversions for `LevelFilter`s in the `tracing-log` crate. Signed-off-by: Eliza Weisman <eliza@buoyant.io>
Yes, I checked that the merge of those branches fixes both the small repro case and the bigger issue over in wasmtime. |
One last PR: #1254 should ensure we handle |
closed by...the sum total of all the various PRs i mentioned here. |
Depends on tokio-rs#1247. Since `tracing-subscriber`'s `init` and `try_init` functions set the global default subscriber, we can use the subscriber's max-level hint as the max level for the log crate, as well. This should significantly improve performance for skipping `log` records that fall below the collector's max level, as they will not have to call the `LogTracer::enabled` method. This will prevent issues like bytecodealliance/wasmtime#2662 from occurring in the future. See also tokio-rs#1249. In order to implement this, I also changed the `FmtSubscriber`'s `try_init` to just use `util::SubscriberInitExt`'s `try_init` function, so that the same code isn't duplicated in multiple places. I also added `AsLog` and `AsTrace` conversions for `LevelFilter`s in the `tracing-log` crate. Signed-off-by: Eliza Weisman <eliza@buoyant.io>
Bug Report
Version
├── tracing-subscriber v0.2.15
│ ├── tracing v0.1.22 ()
│ ├── tracing-log v0.1.1
│ │ └── tracing-core v0.1.17 ()
Platform
Linux finknottle 5.8.0-43-generic #49~20.04.1-Ubuntu SMP Fri Feb 5 09:57:56 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux
Crates
tracing-log
Description
We use
tracing-log
(viatracing-subscriber
) in several executables in the Wasmtime project (https://github.com/bytecodealliance/wasmtime/), andlog
macros in many crates and dependencies of the project.We recently discovered that
tracing-log
was causing everylog_enabled!(LogLevel::Debug)
in the project to be true, which incurs some costly formatting of datastructures into strings, even when the log level is disabled (e.g. RUST_LOG is undefined).In our particular case this ended up being a 2x slowdown of our JIT compiler.
The text was updated successfully, but these errors were encountered: