-
Notifications
You must be signed in to change notification settings - Fork 17.5k
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: TestMemStats is flaky #38712
Comments
What's particularly strange is the "bad sys value" since the way sys is set is very clear. In the darwin-amd64-10_12 builder, Sys is 256 KiB smaller than the sum of the values it's supposed to match. Maybe there's now an update to one of the values that goes into sys after sys is calculated but before the rest of the values are copied? |
I looked at a few more: all of them seem to be off by 256 KiB. |
Still happening, and even 32-bit builders are off by exactly 256 KiB. |
What this means for certain is that between the first few lines of
All the other stats are too small (<256 KiB) to be culprits operating under this assumption. Given all the evidence (the timing implicating |
Ah but hold up, this is happening on amd64/386 where regular loads are the same as atomic loads (in the runtime) because of TSO (and the increments are atomic). |
Figured it out. Consider the following chain of events:
The fix is to purge the |
Change https://golang.org/cl/230498 mentions this issue: |
@mknyszek when I discussed #24686 with @aclements ages ago he suggested it could let us eliminate mcache. If you encounter other mcache troubles, it might be worth exploring this other route. |
Currently mcaches are flushed to mcentral after a bunch of memstats have already been read. This is not safe (in the sense that it doesn't ensure consisent memstats) since memstats may in general change when mcentral data structures are manipulated. Note that prior to the new mcentral implementation this was not a problem because mcentral operations happened to never modify certain memstats. As of the new mcentral implementation, we might for example persistentalloc when uncaching a span, which would change memstats. This can cause a skew between the value of sys (which currently is calculated before mcaches are flushed) and the value of gc_sys and other_sys. Fix this by moving mcache flushing to the very top of updatememstats. Also leave a comment explaining that this must be done first, in general, because mcentrals make no guarantee that they will not influence memstats (and doing so would be unnecessarily restrictive). Fixes golang#38712. Change-Id: I15bacb313c54a46e380a945a71bb75db67169c1b Reviewed-on: https://go-review.googlesource.com/c/go/+/230498 Run-TryBot: Michael Knyszek <mknyszek@google.com> Reviewed-by: Russ Cox <rsc@golang.org>
TestMemStats
is currently flaking on several builders:The failure is
Given the timing, the most likely cause is the new
mcentral
implementation somehow. It's not clear to me yet how it's related, if that's the case.The text was updated successfully, but these errors were encountered: