]> Cypherpunks repositories - gostls13.git/commit
runtime: make alloc count metrics truly monotonic
authorMichael Anthony Knyszek <mknyszek@google.com>
Mon, 10 Jan 2022 22:59:26 +0000 (22:59 +0000)
committerMichael Knyszek <mknyszek@google.com>
Tue, 26 Apr 2022 22:08:00 +0000 (22:08 +0000)
commit79db59ded9dab276507f3a045e42b76eef5a35b4
tree370067f9ae4dc36f151dc3410589dba6c6503b8e
parenta0f77e56b7a7ecb92dca3e2afdd56ee773c2cb07
runtime: make alloc count metrics truly monotonic

Right now we export alloc count metrics via the runtime/metrics package
and mark them as monotonic, but that's not actually true. As an
optimization, the runtime assumes a span is always fully allocated
before being uncached, and updates the accounting as such. In the rare
case that it's wrong, the span has enough information to back out what
did not get allocated.

This change uses 16 bits of padding in the mspan to house another field
that represents the amount of mspan slots filled just as the mspan is
cached. This is information is enough to get an exact count, allowing us
to make the metrics truly monotonic.

Change-Id: Iaff3ca43f8745dc1bbb0232372423e014b89b920
Reviewed-on: https://go-review.googlesource.com/c/go/+/377516
Reviewed-by: Michael Pratt <mpratt@google.com>
Run-TryBot: Michael Knyszek <mknyszek@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
src/runtime/mcache.go
src/runtime/metrics_test.go
src/runtime/mheap.go