-
Notifications
You must be signed in to change notification settings - Fork 844
registry exit: decrement local span ref only #3331
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
base: main
Are you sure you want to change the base?
Conversation
|
Note that changing |
|
FWIW I can also confirm this fixes the issue I've seen in real-world situations so this seems like a very simple fix that also improves performance. Great job! |
|
@jplatte are you able to review this change? |
|
Hey, I'm sorry but I don't actually have a good understanding of tracing internals at all. I've just been reviewing and merging PRs that do not need much knowledge of the internals. I'm afraid this will have to wait for @hds. |
|
Hey everyone. Just to let you know that I'm looking at this PR now. Hopefully get through it in the next couple of days. |
hds
left a comment
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.
Thank you very much for your PR! I think it makes sense, I a couple of comments on the test.
| new_count: Arc<AtomicUsize>, | ||
| clone_count: Arc<AtomicUsize>, | ||
| enter_count: Arc<AtomicUsize>, | ||
| exit_count: Arc<AtomicUsize>, | ||
| close_count: Arc<AtomicUsize>, |
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.
To reduce the code in the test a bit, I think we could put all the atomics into a single struct and put that in an Arc. Then the counts could be cloned into the subscriber and the layer and compared that way.
This is really with a mind to reducing the number of lines we have in this test so that it's easier to understand.
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.
I pushed c2f9f94 which had a go at this - I replaced the atomics with a struct behind a mutex, seems to have reduced the visual noise a bit. Let me know what you think.
|
Thanks will try to get feedback addressed later today 👍 |
Co-authored-by: Hayden Stainsby <hds@caffeineconcepts.com>
Motivation
Fixes #3223
Solution
From my understanding, it's sufficient for
Registry::exitjust to callself.try_close()and do local bookkeeping:try_closeon the wholeLayerstack at this point anyway, a span being exited is not yet ready to close. All that is needed is to decrement the reference count within the current registry.I've added a test which spawns a thread and enters (and exits, and drops) a span created on a dispatcher not registered to that thread.
Before this patch, the test fails with the span never being closed (because there is no thread dispatcher when the span is exited, and so a reference is leaked in
Registry::exit).With this patch, the bookkeeping demonstrated in the test seems correct to me.