mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
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>
This commit is contained in:
parent
11047345f5
commit
724bab1505
23 changed files with 695 additions and 27 deletions
|
|
@ -415,6 +415,13 @@ func stackalloc(n uint32) stack {
|
|||
v = unsafe.Pointer(s.base())
|
||||
}
|
||||
|
||||
if traceAllocFreeEnabled() {
|
||||
trace := traceAcquire()
|
||||
if trace.ok() {
|
||||
trace.GoroutineStackAlloc(uintptr(v), uintptr(n))
|
||||
traceRelease(trace)
|
||||
}
|
||||
}
|
||||
if raceenabled {
|
||||
racemalloc(v, uintptr(n))
|
||||
}
|
||||
|
|
@ -458,6 +465,13 @@ func stackfree(stk stack) {
|
|||
}
|
||||
return
|
||||
}
|
||||
if traceAllocFreeEnabled() {
|
||||
trace := traceAcquire()
|
||||
if trace.ok() {
|
||||
trace.GoroutineStackFree(uintptr(v))
|
||||
traceRelease(trace)
|
||||
}
|
||||
}
|
||||
if msanenabled {
|
||||
msanfree(v, n)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue