runtime: sysUsed often called on non-scavenged memory #36603
Labels
compiler/runtime
Issues related to the Go compiler and/or runtime.
NeedsFix
The path to resolution is known, but the work has not been done.
Performance
Milestone
In working on #36507, I noticed that one source of regression on Darwin was that
sysUsed
, as of Go 1.14, is now called on the whole memory allocation, even if just one page of that is actually scavenged. This behavior was already present in Go 1.11, went away in Go 1.12, and is now back.On systems where
sysUsed
is a no-op and we rely on the first access "unscavenging" the page, this has no effect, because we're already only unscavenging exactly what's needed. On systems like Darwin and Windows where the "recommit" step is explicit (i.e.sysUsed
is not a no-op) this can have a non-trivial impact on performance, since the kernel probably walks over the unscavenged pages for nothing.This contributed very slightly to the performance regression in #36218, but not enough to cause it to block the 1.14 release.
The fix here is straight-forward: we just need to lower the call of
sysUsed
in the page allocator where we have complete information over exactly which pages are scavenged. If a given allocation has >50% of its pages scavenged then we can probably justsysUsed
the whole thing to save a bit on syscall overheads. This change also makes sense because we already dosysUnused
at a fairly low-level part of the page allocator, so bringingsysUsed
down there makes sense.The text was updated successfully, but these errors were encountered: