-
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: default to MADV_DONTNEED on Linux #42330
Comments
Change https://golang.org/cl/267100 mentions this issue: |
Just gonna throw my 2c in that I write a lot of performance critical software in Go and I set them all to use |
I think the monitoring problem is much more severe, and so I support changing the default on Linux. I've responded to a number of these issues and I don't see an end to them. Furthermore, I don't really even see a use in supporting |
Definitely agree with this proposal, as before I was even aware of the existence of MADV_DONTNEED and MADV_FREE, it was quite troublesome to find out why this behavior happened in the first place. That said, I am a bit curious about the performance implications between the two; I might run some benchmarks later. |
@TwinProduction Feel free to try out benchmarks, but unless your benchmark involves periodic heap spikes (and even then, I'd only expect |
Change https://golang.org/cl/267137 mentions this issue: |
Updates #42330. Change-Id: Ifda10a5c3dca30acf1258e9e0af202e9beffc68e Reviewed-on: https://go-review.googlesource.com/c/go/+/267137 Trust: Austin Clements <austin@google.com> Reviewed-by: Michael Knyszek <mknyszek@google.com>
MADV_FREE会导致很多问题的存在, 一台主机往往不可能只放一个go应用程序跑,还会跑其它很多应用。 |
你可以 GODEBUG=madvdontneed=1强制使用_MADV_DONTNEED就行了。 |
@franklwel1990 , I'm reading an automatic translation of your message, so forgive me if I misunderstand anything. Go has used MADV_FREE since Go 1.12. It should not cause other applications to fail, but you're right that it can make the system hard to measure. Go 1.16 will use MADV_DONTNEED. |
How about to backport it to go 1.15? |
In Go 1.12, we changed the runtime to use
MADV_FREE
when available on Linux (falling back toMADV_DONTNEED
) in CL 135395 to address issue #23687. WhileMADV_FREE
is somewhat faster thanMADV_DONTNEED
, it doesn't affect many of the statistics thatMADV_DONTNEED
does until the memory is actually reclaimed. This generally leads to poor user experience, like confusing stats intop
and other monitoring tools; and bad integration with management systems that respond to memory usage.We've seen numerous issues about this user experience, including #41818, #39295, #37585, #33376, and #30904, many questions on Go mailing lists, and requests for mechanisms to change this behavior at run-time, such as #40870. There are also issues that may be a result of this, but root-causing it can be difficult, such as #41444 and #39174. And there's some evidence it may even be incompatible with Android's process management in #37569.
I propose we change the default to prefer
MADV_DONTNEED
overMADV_FREE
, to favor user-friendliness and minimal surprise over performance. I think it's become clear that Linux's implementation ofMADV_FREE
ultimately doesn't meet our needs. We've also made many improvements to the scavenger since Go 1.12. In particular, it is now far more prompt and it is self-paced, so it will simply trickle memory back to the system a little more slowly with this change./cc @mknyszek @rsc
The text was updated successfully, but these errors were encountered: