console
console copied to clipboard
Report when a task doesn't / hasn't yielded in a while.
While using tokio-console for debugging some weird behavior -- by the way, tokio-console has been great so far! -- I ended up discovering that my original issue was related to a task that never yielded. While tokio-console helped me figure this out by displaying that a companion task hadn't yet been woken up (because of the other task not yielding), it would have saved me a step or two if instead I was able to see that the non-yielding task hadn't yielded in a while/at all.
Not sure if this is simple to surface or not, but figured I'd file an issue for it regardless. :)
This should be pretty easy. I think the only difficult part is that we'll have to determine how long a task should have run before yielding before adding a warning.
@tobz if you're interested in working on this, the way we'd do it is adding a new type implementing the Warn trait: https://github.com/tokio-rs/console/blob/7d16eadc5c254f21b0f4fba31f2fdf758808a8f4/console/src/warnings.rs#L4-L47
This would be pretty similar to existing warnings, like SelfWakePercent: https://github.com/tokio-rs/console/blob/7d16eadc5c254f21b0f4fba31f2fdf758808a8f4/console/src/warnings.rs#L118-L135
I think that in the check method for this, we'd want to flag a task for the warning if all of the following are true:
- it is currently active (so the warning doesn't fire for tasks that are waiting to run)
- it has never yielded
- it has been running for a period of time >= some threshold (configurable?)
we probably want to be fairly generous with the threshold, to avoid false positives...it could be something like 5-10 ms? I don't think we want the lint to fire on particularly short-lived tasks; if a task only has two or three await points in it, it's entirely possible that one instance of that task might just be lucky enough that they're all ready, and that's fine if it runs for like, 1ms or less!
@tobz still planning on working on this?
As interesting as it may be, I think my spare time is a bit too small at the moment to take this. :(
On Wed, Jan 12, 2022, 2:04 PM Eliza Weisman @.***> wrote:
@tobz https://github.com/tobz still planning on working on this?
— Reply to this email directly, view it on GitHub https://github.com/tokio-rs/console/issues/203#issuecomment-1011361515, or unsubscribe https://github.com/notifications/unsubscribe-auth/AABWLF6BTMA4HXXECUSPLWDUVXGFDANCNFSM5KERGL6Q . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.
You are receiving this because you were mentioned.Message ID: @.***>
Hi there, I'm learning Tokio and Rust and I think this issue could be interesting for me, if no one else is working on that I could give it a try
@fbrv sorry i didn't reply sooner --- are you still interested in working on this issue? If so, please feel free to open a PR, or let me know if you have any questions!
Hi @hawkw, I'm considering working on this if I can, but have a question, my assumptions may be wrong so forgive me if that's the case.
I think that in the check method for this, we'd want to flag a task for the warning if all of the following are true: it is currently active (so the warning doesn't fire for tasks that are waiting to run) it has never yielded it has been running for a period of time >= some threshold (configurable?)
Does checking if a task is running and for longer than the threshold check all 3?
My assumptions being:
- It is currently active - Meaning it is not awakened nor completed. Is an idle task considered active?
- It has never yielded - Meaning it is still running
Hi! I saw that this went a little stale so I opened up a PR, happy to take feedback on it! Thanks
Since https://github.com/tokio-rs/console/pull/439 got merged, should this issue be closed?
Yes. I think we can close it now. Thank you!