-
Notifications
You must be signed in to change notification settings - Fork 17.8k
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
runtime/metrics: CPU metrics update at a relatively low rate #59749
Comments
Change https://go.dev/cl/487215 mentions this issue: |
Currently the CPU stats are only updated once every mark termination, but for writing robust tests, it's often useful to force this update. Refactor the CPU stats accumulation out of gcMarkTermination and into its own function. This is also a step toward real-time CPU stats. While we're here, fix some incorrect documentation about dedicated GC CPU time. For #59749. For #60276. Change-Id: I8c1a9aca45fcce6ce7999702ae4e082853a69711 Reviewed-on: https://go-review.googlesource.com/c/go/+/487215 Run-TryBot: Michael Knyszek <mknyszek@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Michael Pratt <mpratt@google.com> Auto-Submit: Michael Knyszek <mknyszek@google.com>
What's still needed to have on-demand CPU stats, after the refactoring? |
The main problem I ran into is monotonicity issues with It's complicated, but we'd need something like https://cs.opensource.google/go/go/+/master:src/runtime/mgclimit.go;l=208;drc=70fbc88288143c218fde9f905a38d55505adfb2b;bpv=1;bpt=1 that's even more complete. Not impossible, but probably a substantial amount of work. |
Thanks for the explanation. Before the ideal solution is implemented, which would be complicated as you say, what about an intermediate solution that gets us most of the way there?
In this way, the metric wouldn't be perfectly on-demand, but retain its monotonicity (which is important for metrics) and be less stale than it currently is. |
To be clear, the mark assist example was just an example (and maybe a bad one; that one we could actually already handle today...). There are several other cases, like the GC workers actively running. It's not super useful to wait until they finish running because that's equivalent to waiting until the end of the GC mark phase. |
I wouldn't advocate for that. My suggestion was to provide the last snapshot if this is the case:
Where there is a bar ( |
In practice, we try really hard to have the dedicated GC workers stick to their P and their thread. I think it would be unlikely that we'd be able to find any quiescence. Also again, it's not just the GC workers. We'd need to make sure there would be no outstanding events at all to make it work properly. That's basically a STW. |
I bumped into this again (*) while attempting to compare Go's idea of processing time with the kernel's. Essentially:
I know that the metrics package recommends against comparing kernel and Go metrics for various, but in this case I'd like to observe significant divergence between the two. To answer the question: when does Go believe it is consuming X s/s but the kernel is giving it (much) less? While most of the time the ratio is only slightly higher than 1, I've observed significant outliers (e.g. a 15x ratio) at times. I'd like to rule out the possibility that this is due to the time delay inherent in waiting for a GC cycle to complete before updating the metrics. I don't mean to say this is absolutely necessary, one can get similar information via other means, but it gets messier. It's just another use case. (*) At least, I think I did. |
Currently they update every GC cycle. It should be straightforward to make them "continuously" updating, since most (all?) of them are accumulated in real time.
The text was updated successfully, but these errors were encountered: