Skip to content
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: instrument mpsc channels #4644

Closed
wants to merge 1 commit into from

Conversation

domodwyer
Copy link
Contributor

This PR adds instrumentation to bounded & unbounded mpsc channels, similar to the existing tracing for oneshot/mutexes/etc.

⚠️ potential deadlock ⚠️

Currently the primary consumer of this tracing would be the tokio-console (see feature request) however the console-subscriber crate will deadlock with this PR applied and potentially other tracing subscribers that also use an mpsc channel internally too. I'm not sure if this should be merged before the tracing/console-subscriber deadlock is fixed (I suspect not) but wanted to get a review on the changes, as well as sharing a reproducer. I'm more than happy to rebase this as needed until everything is ready to merge 👍

This PR copies the #[cfg(...)] approach of #4302, but I noticed the comment from @carllerche suggested cleaning this up - I'm more than happy to do this in a follow-up PR and clean up the existing tracing #[cfg(..)] too.

---

  • tracing: instrument mpsc channels (4526247)

    This commit adds tracing to both bounded and unbounded mpsc channels.
    
    Unbounded channels record the following state fields:
    
    	tx: number of items sent through the channel
    	rx: number of items received through the channel
    	values: number of items currently held in the channel
    	tx_handles: number of Sender handles for the channel
    	rx_dropped: true if the Receiver has dropped
    
    Bounded channels record the same fields as above, with the addition of the
    static "capacity" field set to the channel buffer size.
    

This commit adds tracing to both bounded and unbounded mpsc channels.

Unbounded channels record the following state fields:

	tx: number of items sent through the channel
	rx: number of items received through the channel
	values: number of items currently held in the channel
	tx_handles: number of Sender handles for the channel
	rx_dropped: true if the Receiver has dropped

Bounded channels record the same fields as above, with the addition of
the static "capacity" field set to the channel buffer size.
@github-actions github-actions bot added the R-loom Run loom tests on this PR label Apr 29, 2022
@Darksonn Darksonn added A-tokio Area: The main tokio crate M-sync Module: tokio/sync labels Apr 29, 2022
@Darksonn Darksonn requested a review from hawkw April 29, 2022 20:20
@Darksonn
Copy link
Contributor

Thank you for the PR. Unfortunately, it looks like got lost. Since it has been so long, I'm going to close this, even though this is still something that I think would make sense to do. I'm not sure how you could fix the deadlock issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-tokio Area: The main tokio crate M-sync Module: tokio/sync R-loom Run loom tests on this PR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants