expvar: default "memstats" key causes STW #63423
Labels
compiler/runtime
Issues related to the Go compiler and/or runtime.
NeedsInvestigation
Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Performance
Milestone
What version of Go are you using (
go version
)?go1.21.2
Does this issue reproduce with the latest release?
Yes
What operating system and processor architecture are you using (
go env
)?N/A
What did you do?
Import
expvar
, consume all registered keys.What did you expect to see?
No application-wide impact.
What did you see instead?
The "memstats" key calls the old
runtime.ReadMemStats
API, which involves an application-wide stop-the-world while it collects the most up-to-date possible data.https://cs.opensource.google/go/go/+/refs/tags/go1.21.2:src/expvar/expvar.go;l=365
The
expvar
package doesn't guarantee the most up-to-date data. Users who need that (test code that wants to measure single allocations) would useruntime.ReadMemStats
directly. We should be able to get a version of the data that's sufficient forexpvar
's use without the app-wide STW; most of it is available inruntime/metrics
already.I intend to tackle this over the next several weeks.
CC @golang/runtime , and @mknyszek in particular
The text was updated successfully, but these errors were encountered: