-
Notifications
You must be signed in to change notification settings - Fork 17.9k
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: GC behavior in non-steady mode #10064
Comments
I believe this is also true for 1.4 so it isn't a problem we are That said I do believe that constrained memory GC is an important part of On Tue, Mar 3, 2015 at 2:29 AM, Dmitry Vyukov notifications@github.com
|
As Rick mentioned, I think my GC scheduler design should help with this.
|
Not for Go 1.5 at least. |
@aclements, you happy with Go 1.8's behavior here? |
Currently GC allows heap to grow to 2x of live memory during the previous GC. This can play badly with spiky memory usage. Consider that in steady state program has live set X. GC will allow heap to grow to 2X and then collect it back to X, and so on. Now consider that there is a 1.5X spike in memory usage. If GC happens after the spike (when live set is again X), then GC will collect X memory (garbage generated during the spike) and set heap limit to 2X as before. Now if GC happens to happen during the spike (when live set is 1.5X), then GC will collect only 0.5X and set heap limit to 3X.
Basically bad timing can increase maximum heap (RSS) by up to 2x.
Memory-constrained environments, like browsers, pay a great deal of attention to this problem. The idea is to set smarter GC threshold when heap grows/shrinks.
I did not work out a solution. But what I have in mind is: if heap grows, and especially if the next threshold (next_gc) will be larger than the current RSS (heap_sys - heap_released), then set next_gc to, say, heap_inuse * (1 + GOGC/100) * 0.75.
Since heap cannot grow all the time, this throttling is only temporal.
@rsc @RLH @aclements @randall77
The text was updated successfully, but these errors were encountered: