]> Cypherpunks repositories - gostls13.git/commit
runtime: make ReadMemStats STW for < 25µs
authorAustin Clements <austin@google.com>
Tue, 3 Jan 2017 17:15:55 +0000 (10:15 -0700)
committerAustin Clements <austin@google.com>
Sat, 4 Mar 2017 02:56:37 +0000 (02:56 +0000)
commit4a7cf960c38d72e9f0c6f00e46e013be2a35d56e
tree1e47293cf8e12313d8ea713ed7b35ee8b157a787
parent3399fd254dcdf4e8a9be8c327076de5f9efe1b3a
runtime: make ReadMemStats STW for < 25µs

Currently ReadMemStats stops the world for ~1.7 ms/GB of heap because
it collects statistics from every single span. For large heaps, this
can be quite costly. This is particularly unfortunate because many
production infrastructures call this function regularly to collect and
report statistics.

Fix this by tracking the necessary cumulative statistics in the
mcaches. ReadMemStats still has to stop the world to stabilize these
statistics, but there are only O(GOMAXPROCS) mcaches to collect
statistics from, so this pause is only 25µs even at GOMAXPROCS=100.

Fixes #13613.

Change-Id: I3c0a4e14833f4760dab675efc1916e73b4c0032a
Reviewed-on: https://go-review.googlesource.com/34937
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rick Hudson <rlh@golang.org>
src/runtime/export_test.go
src/runtime/gc_test.go
src/runtime/mcentral.go
src/runtime/mheap.go
src/runtime/mstats.go