-
Notifications
You must be signed in to change notification settings - Fork 701
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
tracing: attempt to monomorphize is_enabled call #787
tracing: attempt to monomorphize is_enabled call #787
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks correct to me.
It looks like there are now a couple of dispatcher
imports in the macros that can be removed, if you like:
Line 542 in 445b41f
use $crate::{callsite, dispatcher, Event, field::{Value, ValueSet}}; |
and
Line 587 in 445b41f
use $crate::{callsite, dispatcher, Event, field::{Value, ValueSet}}; |
We have to allow unused imports in the macros because some imports are only needed if the span/event has fields and may sometimes be unused depending on user input, so the compiler can't warn about these.
Good news, this worked! Longer: I followed @matklad's steps to reproduce this issue:
|
Co-authored-by: Eliza Weisman <eliza@buoyant.io>
I've removed the unneeded |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Excellent, lgtm!
I'd love to hear from @matklad if this has a meaningful impact on rust-analyzer compile times, but I think the change is probably a good call regardless.
@@ -869,6 +869,14 @@ pub mod __macro_support { | |||
pub type Once = tracing_core::Once; | |||
} | |||
|
|||
#[doc(hidden)] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We may want to consider making this public API, but I think that should be considered separately from fixing the monomorphization issue, so let's save that for another PR.
I observe meaningful change in cargo-llvm lines:
wall-clock time compilation impact is harder to estimate -- variance within single setup is stupidly high, and each run takes about a minute, so using proper statistic will require too much time. So, "it didn't make compilation 50% faster or slower" is all I can say. Another thing I've noticed is that there's a bunch of calls to |
@matklad I'm glad you're able to observe a meaningful change in cargo-llvm lines! No worries about the compile times on your end. I've personally observed a (relatively) consistent 1-2 second change on my beefy MacBook Pro when compiling
That's interesting! Since Eliza wrote that code, I'll let her comment on it, but if you're correct, I'll open another issue + PR to fix that. |
Yeah, the |
Added - **attributes**: Support for arbitrary expressions as fields in `#[instrument]` (#672) - **attributes**: `#[instrument]` now emits a compiler warning when ignoring unrecognized input (#672, #786) - Improved documentation on using `tracing` in async code (#769) Changed - Updated `tracing-core` dependency to 0.1.11 Fixed - **macros**: Excessive monomorphization in macros, which could lead to longer compilation times (#787) - **log**: Compiler warnings in macros when `log` or `log-always` features are enabled (#753) - Compiler error when `tracing-core/std` feature is enabled but `tracing/std` is not (#760) Thanks to @nagisa for contributing to this release!
### Added - **attributes**: Support for arbitrary expressions as fields in `#[instrument]` (#672) - **attributes**: `#[instrument]` now emits a compiler warning when ignoring unrecognized input (#672, #786) - Improved documentation on using `tracing` in async code (#769) ### Changed - Updated `tracing-core` dependency to 0.1.11 ### Fixed - **macros**: Excessive monomorphization in macros, which could lead to longer compilation times (#787) - **log**: Compiler warnings in macros when `log` or `log-always` features are enabled (#753) - Compiler error when `tracing-core/std` feature is enabled but `tracing/std` is not (#760) Thanks to @nagisa, and everyone who contributed to the new `tracing-core` and `tracing-attributes` versions, for contributing to this release!
Resolves #783.