server: implement delta profiling for allocs/heap/block/mutex profiles #160608
+73
−0
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Previously, when requesting profiles like allocs, heap, block, or mutex through the pprof UI endpoint (/debug/pprof/ui/allocs/?seconds=10), the seconds parameter was ignored and an immediate snapshot was returned. This differed from the behavior of Go's standard pprof handler at /debug/pprof/allocs?seconds=10, which correctly collected a delta profile over the specified duration.
The issue was in profileLocal() which handled these profile types in the default case without respecting req.Seconds. Now, when Seconds > 0 is specified, we collect two profile snapshots separated by the requested duration and compute their difference (delta profile) using the same algorithm as Go's net/http/pprof: scale the first profile by -1 and merge with the second.
This enables the pprof UI to show "recent allocations" over a specific time window rather than cumulative allocations since process start.
Release note (bug fix): Fixed a bug where the pprof UI endpoints for allocs, heap, block, and mutex profiles ignored the seconds parameter and returned immediate snapshots instead of delta profiles.
TODO: fix lint error: server/status_local_file_retrieval.go:165: ts := time.Now().UnixNano() <- forbidden; use 'timeutil' instead
Epic: none