]> Cypherpunks repositories - gostls13.git/commit
runtime/pprof: consume tag for first CPU record
authorMichael Pratt <mpratt@google.com>
Mon, 6 Dec 2021 21:05:55 +0000 (16:05 -0500)
committerMichael Pratt <mpratt@google.com>
Tue, 7 Dec 2021 22:33:33 +0000 (22:33 +0000)
commita3ae45ebe1b3576428f5eb27347704b2d099eab0
tree7e3ce3a082c920164924b5a36ae34922e387fc55
parentcf1ec173603f950aaccb549602ed0fee57e6b709
runtime/pprof: consume tag for first CPU record

profBuf.write uses an index in b.tags for each entry, even if that entry
has no tag (that slice entry just remains 0). profBuf.read similarly
returns a tags slice with exactly as many entries as there are records
in data.

profileBuilder.addCPUData iterates through the tags in lockstep with the
data records. Except in the special case of the first record, where it
forgets to increment tags. Thus the first read of profiling data has all
tags off-by-one.

To help avoid regressions, addCPUData is changed to assert that tags
contains exactly the correct number of tags.

For #50007.

Change-Id: I5f32f93003297be8d6e33ad472c185d924a63256
Reviewed-on: https://go-review.googlesource.com/c/go/+/369741
Reviewed-by: Austin Clements <austin@google.com>
Trust: Michael Pratt <mpratt@google.com>
Run-TryBot: Michael Pratt <mpratt@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
src/runtime/cpuprof.go
src/runtime/pprof/pprof_test.go
src/runtime/pprof/proto.go
src/runtime/pprof/proto_test.go