You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Fixes#103
This PR fixes an issue when a heap/mutex profile has a record with equal stack (by accumulating values for duplicate stacks before delta computation).
The issue was found in tests for mutex(golang started to produce two profile records for the same mutex ( see the linked issue for more info))
I'm not sure if it is possible to trigger the issue for heap.
The PR turned up big because of refactored test helpers for reuse. I can split PR into 2 or 3 smaller ones if needed.
This PR also drops support for go16, go17 as I wanted to use generics in prof/map.go
goos: darwin
goarch: arm64
pkg: github.com/grafana/pyroscope-go/godeltaprof/compat
│ old.txt │ new.txt │
│ sec/op │ sec/op vs base │
HeapCompression-8 691.1µ ± 0% 729.8µ ± 65% +5.59% (p=0.002 n=6)
MutexCompression/ScalerMutexProfile-8 640.6µ ± 1% 693.8µ ± 9% +8.30% (p=0.002 n=6)
MutexCompression/ScalerBlockProfile-8 643.2µ ± 1% 690.3µ ± 1% +7.33% (p=0.002 n=6)
HeapDelta-8 76.26µ ± 1% 113.92µ ± 2% +49.38% (p=0.002 n=6)
MutexDelta/ScalerMutexProfile-8 48.98µ ± 1% 81.11µ ± 2% +65.59% (p=0.002 n=6)
MutexDelta/ScalerBlockProfile-8 49.03µ ± 1% 81.14µ ± 1% +65.49% (p=0.002 n=6)
geomean 193.3µ 253.0µ +30.87%
│ old.txt │ new.txt │
│ B/op │ B/op vs base │
HeapCompression-8 974.1Ki ± 0% 973.9Ki ± 0% -0.03% (p=0.002 n=6)
MutexCompression/ScalerMutexProfile-8 974.6Ki ± 0% 974.3Ki ± 0% -0.02% (p=0.002 n=6)
MutexCompression/ScalerBlockProfile-8 974.6Ki ± 0% 974.3Ki ± 0% -0.03% (p=0.002 n=6)
HeapDelta-8 333.00 ± 0% 53.00 ± 0% -84.08% (p=0.002 n=6)
MutexDelta/ScalerMutexProfile-8 312.00 ± 0% 30.00 ± 0% -90.38% (p=0.002 n=6)
MutexDelta/ScalerBlockProfile-8 312.00 ± 0% 30.00 ± 0% -90.38% (p=0.002 n=6)
geomean 17.42Ki 5.874Ki -66.28%
│ old.txt │ new.txt │
│ allocs/op │ allocs/op vs base │
HeapCompression-8 788.0 ± 0% 787.0 ± 0% -0.13% (p=0.002 n=6)
MutexCompression/ScalerMutexProfile-8 788.0 ± 0% 787.0 ± 0% -0.13% (p=0.002 n=6)
MutexCompression/ScalerBlockProfile-8 788.0 ± 0% 787.0 ± 0% -0.13% (p=0.002 n=6)
HeapDelta-8 2.000 ± 0% 1.000 ± 0% -50.00% (p=0.002 n=6)
MutexDelta/ScalerMutexProfile-8 2.000 ± 0% 1.000 ± 0% -50.00% (p=0.002 n=6)
MutexDelta/ScalerBlockProfile-8 2.000 ± 0% 1.000 ± 0% -50.00% (p=0.002 n=6)
geomean 39.70 28.05 -29.33%
So it looks like the cost of deduplication is about 5% of overall time(including compression), which is not that bad.
funcWriteHeapProto(dp*pprof.DeltaHeapProfiler, opt*pprof.ProfileBuilderOptions, w io.Writer, p []runtime.MemProfileRecord, rateint64) error {
71
-
stc:=pprof.HeapProfileConfig(rate)
72
-
b:=pprof.NewProfileBuilder(w, opt, stc)
73
-
returndp.WriteHeapProto(b, p, rate)
74
-
}
75
-
76
-
funcPrintCountCycleProfile(d*pprof.DeltaMutexProfiler, opt*pprof.ProfileBuilderOptions, w io.Writer, scaler pprof.MutexProfileScaler, records []runtime.BlockProfileRecord) error {
0 commit comments