-
Notifications
You must be signed in to change notification settings - Fork 17.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
runtime/pprof: "bytes" tag value may fluctuate between runs as it's computed off unsampled values #26638
Comments
Change https://golang.org/cl/126336 mentions this issue: |
/cc @hyangah @aclements |
This computed block size is used for the value for the 'bytes' tag. Wouldn't it be confusing if the (scaled total bytes / scaled total object count) != the blockSize? The utility of the 'bytes' tag is still questionable - the proposed change relies on the entire history of the allocation, but still sampled. So the value of the 'bytes' tag is still an approximate and may fluctuate over time unless the allocation object size is fixed at the call site. Wouldn't this fluctuation cause negative values in diff if the diff takes the unstable 'bytes' tag values into account? |
I think it's more confusing if the value of the "bytes" tag does not match the actual allocation size, or if doing "pprof -tags -alloc_space profile2.pb.gz -base profile1.pb.gz" produces negative values for some "bytes" tags. Note that pprof itself does use the sampled values to compute the "bytes" tag when reading legacy profiles, so it seems that the behavior has changed when the runtime started producing proto output, not sure if this was intentional.
I believe the allocation size is a part of the bucket key when tracking allocations - Line 221 in db810b6
|
Thanks @aalexand for reminding me that runtime maintains a separate bucket for each allocation block size. (the size here is not the user-perceived object size, but the runtime-perceived allocation size). |
Thanks @hyangah
Curious: when those would differ? For allocations of size that is not a multiple of something? E.g. user asks for 5 bytes but 8 bytes get allocated? Or something else? |
it's complicated - see how size is changed in func mallocgc (e.g., Line 983 in 4cc09cd
|
@hyangah I think the exact accuracy of size should be discussed separately and we should get the fix https://go-review.googlesource.com/c/go/+/126336 in. WDYT? |
@bradfitz should we wait till 1.12? this is a minor change but fixes the bug that leads to confusion when using tags. |
See a test program and test output below. The block size allocated by the program is 32768 bytes, but the profiles contain values like 32778, 32885 and 32868. This is not quite expected - I would expect to see as the block size the exact block size I know I am allocating in the program. Looking at how the legacy profiles are handled in github.com/google/pprof (which come in sampled, so pprof has to unsample them), it looks like the block size is computed prior to unsampling the values, see https://github.com/google/pprof/blob/403a828189bee34b4b9fea51ece1af8400ccef30/profile/legacy_profile.go#L606 and https://github.com/google/pprof/blob/403a828189bee34b4b9fea51ece1af8400ccef30/profile/legacy_java_profile.go#L218.
So it looks like
go/src/runtime/pprof/protomem.go
Line 60 in bd98a81
The text was updated successfully, but these errors were encountered: