-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
Constify {Mutex, Notify, OnceCell, RwLock, Semaphore}::new
#5897
Conversation
By removing the tracing log in these functions. Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
This comment was marked as outdated.
This comment was marked as outdated.
The CI failure is already reported in #5888 and is probably spurious. |
This PR needs a restart of the failed CI tests. |
@hawkw What purpose does the tracing span have? Do we lose something by dropping it like this? If they do serve a purpose, we could decide to keep the |
Also @carllerche since they are the one who suggested this change. |
I think its important to ask the question, because once it is const, we can't add back the tracing span. |
I wonder if storing the tracing span is really necessary or have any use. I think it could be only used for tracking where the It also adds quite some space to |
I believe that the spans are used for tokio-console to keep track of which synchronization primitives are used, but I don't know the details. |
The pr like task: add Tracing instrumentation to spawned tasks about resource instrument add those code. |
Thanks! I think we would have to wait for @hawkw to review this PR. |
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.
While a definitive answer would come from Eliza, I can confirm that as well as tasks, many resources in Tokio are instrumented, including Mutex
, RwLock
, Semaphore
, and BatchSemaphore
which are touched in this PR.
For example, for a Semaphore
, the instrumentation tracks the number of permits belonging to a semaphore as well as the aquire operations performed by tasks. This instrumentation is also available when Semaphore
is used by another sync resource, such as RwLock
.
The changes to remove that instrumentation would break support for these resources in tokio-console. I would kindly ask that it isn't removed.
I'm guessing that initializing this instrumentation is not possible in const
context and that's why it's being removed. I'm not sure there is currently a way around that.
|
||
#[cfg(all(tokio_unstable, feature = "tracing"))] | ||
let resource_span = { | ||
let resource_span = tracing::trace_span!( |
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.
Removing this will break support for tracking batch semaphores in tokio-console.
let resource_span = { | ||
let location = std::panic::Location::caller(); | ||
|
||
tracing::trace_span!( |
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.
Removing this will break support for tracking mutxes in tokio-console.
#[cfg(all(tokio_unstable, feature = "tracing"))] | ||
let resource_span = { | ||
let location = std::panic::Location::caller(); | ||
let resource_span = tracing::trace_span!( |
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.
Removing this will break support for tracking RwLocks in tokio-console.
let resource_span = { | ||
let location = std::panic::Location::caller(); | ||
|
||
let resource_span = tracing::trace_span!( |
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.
Removing this will break support for tracking RwLocks in tokio-console.
let resource_span = { | ||
let location = std::panic::Location::caller(); | ||
|
||
tracing::trace_span!( |
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.
Removing this will break support for tracking semaphores in tokio-console.
@hds Thanks for the response, if these spanning is used in
I am willing to close this PR since there are already You could, workaround this, by wrapping the |
Yeah, lets drop this for now. It's acceptable that |
@hds BTW, since |
@NobodyXu There are higher level attributes which are captured in the higher level resources. It is true that the performance impact of the tracing feature isn't well quantified, but as it is optional, that is something that is still pending to be measured. |
Thanks for the quick response! Problem with this is that after it gets stablised, if one of the dependency enables |
Because of this, I think that the It should only be possible for the top level binary to enable tracing. Unfortunately the current |
I think having its own Having a |
Motivation
With MSRV bumped to 1.63, we can now make
{Mutex, Notify, OnceCell, RwLock, Semaphore}::new
available in const context.Solution
Removed the tracing log in these functions and makes these function usable in const context when
cfg(not(all(loom, test)))
.