]> Cypherpunks repositories - gostls13.git/commit
runtime: add traceallocfree GODEBUG for alloc/free events in traces
authorMichael Anthony Knyszek <mknyszek@google.com>
Wed, 24 Apr 2024 16:26:39 +0000 (16:26 +0000)
committerGopher Robot <gobot@golang.org>
Wed, 8 May 2024 17:47:01 +0000 (17:47 +0000)
commit724bab150541efefa4b3ea27bf3d4a064e9fab8c
treea15bfa520133d4d038013bd4ee285f1bcbb4608a
parent11047345f53fb1484e76fd59d6e044c219d204e5
runtime: add traceallocfree GODEBUG for alloc/free events in traces

This change adds expensive alloc/free events to traces, guarded by a
GODEBUG that can be set at run time by mutating the GODEBUG environment
variable. This supersedes the alloc/free trace deleted in a previous CL.

There are two parts to this CL.

The first part is adding a mechanism for exposing experimental events
through the tracer and trace parser. This boils down to a new
ExperimentalEvent event type in the parser API which simply reveals the
raw event data for the event. Each experimental event can also be
associated with "experimental data" which is associated with a
particular generation. This experimental data is just exposed as a bag
of bytes that supplements the experimental events.

In the runtime, this CL organizes experimental events by experiment.
An experiment is defined by a set of experimental events and a single
special batch type. Batches of this special type are exposed through the
parser's API as the aforementioned "experimental data".

The second part of this CL is defining the AllocFree experiment, which
defines 9 new experimental events covering heap object alloc/frees, span
alloc/frees, and goroutine stack alloc/frees. It also generates special
batches that contain a type table: a mapping of IDs to type information.

Change-Id: I965c00e3dcfdf5570f365ff89d0f70d8aeca219c
Reviewed-on: https://go-review.googlesource.com/c/go/+/583377
Reviewed-by: Michael Pratt <mpratt@google.com>
Auto-Submit: Michael Knyszek <mknyszek@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
23 files changed:
src/internal/trace/v2/base.go
src/internal/trace/v2/batch.go
src/internal/trace/v2/event.go
src/internal/trace/v2/event/event.go
src/internal/trace/v2/event/go122/event.go
src/internal/trace/v2/generation.go
src/internal/trace/v2/order.go
src/internal/trace/v2/trace_test.go
src/runtime/lockrank.go
src/runtime/malloc.go
src/runtime/mgcsweep.go
src/runtime/mheap.go
src/runtime/mklockrank.go
src/runtime/runtime1.go
src/runtime/stack.go
src/runtime/trace.go
src/runtime/traceallocfree.go [new file with mode: 0644]
src/runtime/tracebuf.go
src/runtime/traceevent.go
src/runtime/traceexp.go [new file with mode: 0644]
src/runtime/traceregion.go
src/runtime/traceruntime.go
src/runtime/tracetype.go [new file with mode: 0644]