-
Notifications
You must be signed in to change notification settings - Fork 38
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
Improve memory and cpu performance of restperf collector #2054
Labels
Comments
Steps to benchmark and analyzeBaselinegit clone https://github.com/NetApp/harvest.git
cd cmd/collectors/restperf
go test -run=XXX -bench . -benchmem -count 20 -cpuprofile cpu-baseline.prof -memprofile heap-baseline.prof Baseline ResultsLegend
Improvement Results
Compare baseline to improved versionEach column left to right
go install golang.org/x/perf/cmd/benchstat@latest
benchstat restperf_baseline.txt restperf_improve.txt
goos: darwin
goarch: amd64
pkg: github.com/netapp/harvest/v2/cmd/collectors/restperf
cpu: Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz
│ restperf_baseline.txt │ restperf_improve.txt │
│ sec/op │ sec/op vs base │
RestPerf_PollData-12 162.75m ± 1% 16.95m ± 2% -89.58% (p=0.000 n=20)
│ restperf_baseline.txt │ restperf_improve.txt │
│ B/op │ B/op vs base │
RestPerf_PollData-12 50.897Mi ± 0% 1.069Mi ± 0% -97.90% (p=0.000 n=20)
│ restperf_baseline.txt │ restperf_improve.txt │
│ allocs/op │ allocs/op vs base │
RestPerf_PollData-12 107.09k ± 0% 13.95k ± 0% -86.97% (p=0.000 n=20) Resources |
cgrinds
added a commit
that referenced
this issue
Nov 20, 2024
Using the gjson `String()` method will often cause the entire JSON string to be retained in memory. This PR copies gjson to the thirdparty package and adds a `ClonedString` method to `gjson.Result`. The `ClonedString` method returns a cloned copy of the Result string so that the larger JSON string is available for garbage collection. The Rest and RestPerf collectors were updated to use `gjson.ClonedString()`. A similar fix was made in #2054 for RestPerf.
cgrinds
added a commit
that referenced
this issue
Nov 20, 2024
Using the gjson `String()` method will often cause the entire JSON string to be retained in memory. This PR copies gjson to the thirdparty package and adds a `ClonedString` method to `gjson.Result`. The `ClonedString` method returns a cloned copy of the Result string so that the larger JSON string is available for garbage collection. The Rest and RestPerf collectors were updated to use `gjson.ClonedString()`. A similar fix was made in #2054 for RestPerf.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
No description provided.
The text was updated successfully, but these errors were encountered: