-
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: frequent ReadMemStats will cause heap_live to exceed next_gc #50592
Comments
cc @mknyszek |
It's always true that the GC can overshoot by a little bit; (There is a "hard goal" that is 10% above the heap goal in Go 1.17 or earlier, and proportional to the discovered live heap in Go 1.18 and later, but even this can be broken in this way.) In this particular case, I suspect the frequent STW calls mean that dedicated and idle workers get interrupted in a way that ends up creating a greater opportunity for goroutines with assist credit to allocate beyond the goal, but it's hard to say. IMO the I'm just taking a guess on this so feel free to ignore me, but if your goal is to build a memory limit mechanism on top of |
@mknyszek
Aha, you are right. |
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Maybe, I am not sure, GC Pacer Redesign maybe reduce the probability of it
What operating system and processor architecture are you using (
go env
)?darwin/amd64
What did you do?
A test similar to https://go-review.googlesource.com/c/go/+/227767/3
What did you expect to see?
heap_live <= next_gc
What did you see instead?
probabilistic recurrence
and
While this example is extreme, does this result meet expectations?
There is only one user Goroutine running in the demo,
In this scenario, should the GC pacer mechanism ensure that heap_live <= next_gc ?
some brief analysis:
I guess it is related to this commit https://go-review.googlesource.com/c/go/+/216557 ,
Frequent ReadMemStats/STW causes GC mark goroutine to execute too slowly.
I also found some interesting phenomena in the positioning of this problem (maybe it is normal, but maybe some strategy adjustments can be made if necessary)
The text was updated successfully, but these errors were encountered: