-
Notifications
You must be signed in to change notification settings - Fork 18k
runtime: cheaper alternative to runtime.ReadMemStats #13613
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
Comments
What parts of MemStats are you interested in? |
This particular package uses Alloc, PauseNs and NumGC to graph memory usage and GC pauses. |
hack go src code? |
I took an execution trace from an application with a 15-30GB heap, and a call to runtime.ReadMemStats() paused it for about 40 ms. We don't want to give up monitoring memory usage and GC performance, but we also don't want to pause to do it. So some improvement in this area would be appreciated. If it helps, a non-STW version of ReadMemStats that only provided roughly accurate numbers, or left out the more fine-grained information entirely, might still be fine for most purposes. |
I haven't thought deeply about this, but I suspect ReadMemStats can be made dramatically more efficient without sacrificing accuracy. It may still have to stop the world very briefly to collect distributed statistics, but that would be much better than the current STW walk it does over the entire heap. |
Hello, I'm very interested as well. I use runtime.ReadMemStats in two places:
I've seen some cpu profiles where runtime.ReadMemStats shows up as >=10% (cumulatively), but also sometimes it's completely absent from the profile. I haven't figured out yet why or what workloads trigger this function to take more time. Either way, very interested in having this one optimized 👍 |
CL https://golang.org/cl/34937 mentions this issue. |
CL https://golang.org/cl/34936 mentions this issue. |
The gcstats structure is no longer consumed by anything and no longer tracks statistics that are particularly relevant to the concurrent garbage collector. Remove it. (Having statistics is probably a good idea, but these aren't the stats we need these days and we don't have a way to get them out of the runtime.) In preparation for #13613. Change-Id: Ib63e2f9067850668f9dcbfd4ed89aab4a6622c3f Reviewed-on: https://go-review.googlesource.com/34936 Run-TryBot: Austin Clements <austin@google.com> Reviewed-by: Rick Hudson <rlh@golang.org>
Hi.
runtime.ReadMemStats() calls stopTheWorld inside(), so it is very expensive to call it often (see https://github.com/mkevac/debugcharts). Especially in a production system.
I would like to see cheaper but maybe not so accurate alternative if it's possible.
Thanks.
The text was updated successfully, but these errors were encountered: