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
EnvFilter lockfree implementation #2951
Comments
Something like this, perhaps we can have a code path when the registry has this trait, not sure. |
This sounds like specialization, so I'm afraid this will not be possible anytime soon. Or rather there would need to be two filter inplementations, one general and one with lookup and the user would have to choose which one to use. That is if we want to avoid breaking changes which adding a bound there is. |
Is it possible to use the slab storage directly in the env_filter rather than using a rwlock? |
I also think at a minimum its worth considering only doing anything with the 2 mutexs if there is at least 1 dynamic directive. |
I have done a benchmark using https://docs.rs/scc/2.1.0/scc/hash_map/struct.HashMap.html as the hash map rather then the tracing/tracing-subscriber/src/filter/env/mod.rs Lines 201 to 202 in 36bf063
normal env filter
env filter with scc hash map
level filter
From looking at these results it seems that env filter now adds no overhead and still works the exact same way. In the env filter i can still filter by spans and variables. The only difference is there is no mutex. The reason its a big difference is because i am using a 128 core machine. Repeating the test but only using 4 cores. normal env filter
env filter with scc hash map
level filter
|
What do you mean by "level filter"? It seems completely reasonable to me to replace the locked hashmap with a concurrent variant. I'd just like to check if we don't already (transitively) depend on another one (flurry maybe?) so that we wouldn't have to add different dependency. |
https://docs.rs/tracing/latest/tracing/level_filters/struct.LevelFilter.html
That sounds good, the scc crate is 2 deps i believe, scc itself and the backer crate |
Feature Request
Crates
tracing_subscriber
Motivation
Having a lock free implementation would be very nice performance boost.
Proposal
We can already do something like this if we use the registry lookup span and extensions. however env filter currently does not require that trait.
Alternatives
Perhaps disable the lock code paths if there are no dynamic filters.
The text was updated successfully, but these errors were encountered: