Commit eaa0288
committed
server: implement delta profiling for allocs/heap/block/mutex profiles
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.1 parent e654896 commit eaa0288
1 file changed
+72
-0
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
22 | 22 | | |
23 | 23 | | |
24 | 24 | | |
| 25 | + | |
25 | 26 | | |
26 | 27 | | |
27 | 28 | | |
| |||
91 | 92 | | |
92 | 93 | | |
93 | 94 | | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
94 | 103 | | |
95 | 104 | | |
96 | 105 | | |
| |||
99 | 108 | | |
100 | 109 | | |
101 | 110 | | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
102 | 174 | | |
103 | 175 | | |
104 | 176 | | |
| |||
0 commit comments