Skip to content

feat(subscriber): Record and send poll times with HdrHistogram #47

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

Merged
merged 22 commits into from
Jul 2, 2021

Conversation

oguzbilgener
Copy link
Contributor

@oguzbilgener oguzbilgener commented Jun 15, 2021

Closes #36

As suggested in the issue, this PR uses HdrHistogram to record task poll times as nanoseconds. The histogram is serialized into bytes using the V2Serializer.

The subscriber now offers a second RPC stream called TaskDetails for a given task ID.

The console app starts a details stream when you view the details of a task and stops the stream when you leave it.

To demonstrate that it works, I also added some stats and a small chart to the task view using the histogram data.
But I won't insist on merging this part, since you may have other plans for the task details view.

Screenshot from 2021-06-22 21-20-43

I've got one TODO left and I would appreciate your suggestions on it.

Copy link
Member

@hawkw hawkw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks for working on this, this is really cool!

i had some thoughts on how we could potentially save some data on the wire by only sending the complete histogram on-demand. although hdrhistogram is pretty space-efficient, sending one for each task is still potentially a lot of data in a production system, where there might be a very large number of tasks.

let me know what you think of my suggestions?

@oguzbilgener oguzbilgener marked this pull request as ready for review June 23, 2021 01:22
@seanmonstar
Copy link
Member

Thanks for the screenshot, that looks super cool! What exactly is the graph showing?

@oguzbilgener
Copy link
Contributor Author

oguzbilgener commented Jun 23, 2021

It should show... the entire histogram 😅 with the bucket count equal to the number of horizontal pixels in the render area.

It looks like tui's Sparkline omits relatively very small values, so that's why both ends of the graph are empty, otherwise the graph should fill the box horizontally. The sparkline should give a general idea of how the poll times are distributed.

I also played with BarChart but it requires more space and its value labels were sort of ugly when some buckets have so small values that the value label is taller than the bar:

Also, there may be better ways to visualize this since it's a latency histogram. So I'm okay with taking it out.

@jonhoo
Copy link

jonhoo commented Jun 23, 2021

Sideline comment — definitely provide an option to render a CDF if you can. It's a little harder to read than a histogram, but provides much more data (e.g., what is the 95th percentile latency) at a glance.

@oguzbilgener oguzbilgener requested a review from hawkw June 27, 2021 18:34
.map(|pairs| {
pairs.into_iter().map(|pair| {
format!(
"p{}: {:.prec$?}",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: it would be nice to bold the percentile label ("pNN") like we do for labels elsewhere?

Copy link
Contributor Author

@oguzbilgener oguzbilgener Jun 29, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated:
Screen Shot 2021-06-29 at 2 52 32 PM

To add more percentiles with different lengths like p5 or p99.9 I need to account for the spacing better, but not sure if we care about those at the moment? It would be nice to fill up those two columns of percentiles though 😄

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

alternatively, we could just make the poll times section a couple lines longer, and make one column of percentiles. then, the percentiles box wouldn't have to be 50% of the section, and we could make the histogram wider...and get more vertical space, which would (hopefully) allow us to draw the histogram with a little more vertical resolution.

but, we can tweak the layout and stuff in subsequent PRs. the important part for this branch, IMO, is getting the histogram wired through from the subscriber to the console, and having a basic setup for drawing it. which we've done! so, let's just merge this and keep working on making it look nice as a follow-up. :)

}
}
} else {
// TODO: handle connection error, print details somewhere? Related to Issue #30
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can make another small PR to address this after #57

@oguzbilgener oguzbilgener requested a review from hawkw July 1, 2021 18:54
Copy link
Member

@hawkw hawkw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this looks good to me! would be nice to get a 👍 from @seanmonstar as well, if you have a minute to look it over?

Copy link
Member

@seanmonstar seanmonstar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's goooooo 🚀

@seanmonstar seanmonstar merged commit 94e7834 into tokio-rs:main Jul 2, 2021
@hawkw
Copy link
Member

hawkw commented Jul 2, 2021

yay! thanks for all your hard work on this, @oguzbilgener!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

subscriber: record and send a histogram of Task poll times
4 participants