runtime/pprof: line directive filename changes results in incorrect and nondeterministic filenames in pprof samples #56135
Labels
compiler/runtime
Issues related to the Go compiler and/or runtime.
NeedsDecision
Feedback is required from experts, contributors, and/or the community before a change can be made.
Milestone
When running this program, all samples in
add()
will have the same filename, regardless of location. e.g.,Notice that all Locations in
main.add
reportc.go
, even though all of the increments are represented (line numbers 10, 20, 30, 40 are a, b, c, d, respectively).This is primarily a deficiency in the pprof format itself [1], which encodes the filename at the Function level, thus assuming that a function is entirely in a single file. This is true in the Go language, but
//line
directives allow specifying multiple fake filenames per function.This is also nondeterministic because the Go runtime sets Function.filename to the filename of the first frame containing that function. So multiple runs produce profiles with different filenames for
add
.This is an unfortunate situation, but I don't think it is currently important enough to do anything about (which would likely involve changing pprof to support multiple filenames per function. (Add an optional
filename
field toLine
, which overrides the value inFunction
?))[1] In theory we could use a different Function for samples with different filenames. I suspect this would break some of the grouping/aggregation functionality in pprof though.
cc @golang/runtime @mdempsky @cherrymui
The text was updated successfully, but these errors were encountered: