Improve performance of inactive tracing spans #157
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Improve performance of log/tracing harness access
std::sync::{OnceLock, LazyLock}for better storageefficiency and std's futex-based backend. These are available since
Rust 1.80.
NOOP_HARNESSif aproper harness is configured. Previously,
.unwrap_or(&NOOP_HARNESS)would cause the Deref impl to be called even if the reference was
never used. (Due to Deref's side effects.)
CachePaddedto avoid false sharingwith other global variables. This is important to ensure OnceLock's
initialization check is not slowed down by dirty cache lines.
Remove globally-shared INACTIVE_SPAN RwLock
This RwLock was a heavy contention point in applications that generate a
lot of spans, as every span operation must lock and unlock the RwLock.
Each lock/unlock is an atomic RMW and thus dirties the cache line for
all other cores.
We can avoid the global singleton
INACTIVE_SPANentirely with somechanges to our internal
SharedSpanHandleAPI.Remove internal once_cell usages
There are two spots left where we can't remove once-cell yet:
memory_profiler.rs, we useOnceCell::get_or_try_init. Thisfunction is not stabilized in std yet.
foundations::security::allow_listmacro generates OnceCellinstances in user code. Changing this requires a major bump.