-
Notifications
You must be signed in to change notification settings - Fork 721
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
debug!
statements still codegen despite release_max_level_off
#1174
Comments
Thanks for the bug report. It looks like the culprit is the However, the code for also emitting If you can disable It looks like we also ought to move the |
I can confirm that disabling the |
Great, thanks for checking! I'll go ahead and move the log max level check outside of the I'll also make sure the docs explain clearly that some code may be generated if |
Currently, when the `log` feature is enabled but the `log-always` feature is not, we check the (dynamic, but inexpensive) `dispatch::has_been_set` variable **before** checking if the event's level would be enabled by `log`'s static max level features. Although this check is not terribly costly in terms of performance, it *does* result in code being generated even when the `log` crate disables some levels statically. This means that we will always generate *some* code when the `log` feature is disabled. This isn't ideal --- the static max level features should result in us generating *no* code whatsoever for disabled trace points. This commit moves the static max level check outside of the dispatch check. Now, we should generate 0 bytes of assembly when both `log` and `tracing` disable an event with their static filtering features. I've also updated the docs to explain the relationship between `tracing` and `log`'s separate static filtering. Fixes #1174 Signed-off-by: Eliza Weisman <eliza@buoyant.io>
Currently, when the `log` feature is enabled but the `log-always` feature is not, we check the (dynamic, but inexpensive) `dispatch::has_been_set` variable **before** checking if the event's level would be enabled by `log`'s static max level features. Although this check is not terribly costly in terms of performance, it *does* result in code being generated even when the `log` crate disables some levels statically. This means that we will always generate *some* code when the `log` feature is disabled. This isn't ideal --- the static max level features should result in us generating *no* code whatsoever for disabled trace points. This commit moves the static max level check outside of the dispatch check. Now, we should generate 0 bytes of assembly when both `log` and `tracing` disable an event with their static filtering features. I've also updated the docs to explain the relationship between `tracing` and `log`'s separate static filtering. Fixes #1174 Signed-off-by: Eliza Weisman <eliza@buoyant.io>
Currently, when the `log` feature is enabled but the `log-always` feature is not, we check the (dynamic, but inexpensive) `dispatch::has_been_set` variable **before** checking if the event's level would be enabled by `log`'s static max level features. Although this check is not terribly costly in terms of performance, it *does* result in code being generated even when the `log` crate disables some levels statically. This means that we will always generate *some* code when the `log` feature is disabled. This isn't ideal --- the static max level features should result in us generating *no* code whatsoever for disabled trace points. This commit moves the static max level check outside of the dispatch check. Now, we should generate 0 bytes of assembly when both `log` and `tracing` disable an event with their static filtering features. I've also updated the docs to explain the relationship between `tracing` and `log`'s separate static filtering. Fixes #1174 Signed-off-by: Eliza Weisman <eliza@buoyant.io>
Bug Report
Hello, I'm investigating binary bloat in an application and I noticed that there seems to be a lot from log statements, even if I try to statically compile them away.
Version
tracing: 0.1.22
Rust: rustc 1.51.0-nightly (da305a2b0 2021-01-05)
Platform
Darwin mark 20.2.0 Darwin Kernel Version 20.2.0: Wed Dec 2 20:39:59 PST 2020; root:xnu-7195.60.75~1/RELEASE_X86_64 x86_64
Crates
tracing, tracing-log?
Description
features:
context:
This was most noticeable in this trait where the empty default methods log and then return without doing anything. This trait is implemented on a number of types and many of the types use the default implementations.
note that
set_last_accessed
has been commented out as a baseline to compare against.Running
cargo bloat
without therelease_max_level_off
andmax_level_off
features in release mode, we get:with multiple entries.
Running
cargo bloat
withrelease_max_level_off
andmax_level_off
features in release mode, we get:So we get a reduction of about half in terms of bytes of generated code by enabling these features. I'd expect these features to be equivalent to commenting out the log statement.
cargo expanding it, we get:
and
Expected behavior is:
Extra context
It probably doesn't matter but the release profile was tweaked when running this:
Thanks!
The text was updated successfully, but these errors were encountered: