feat: replace custom sysctl implementation with stdlib#135
Merged
kruskall merged 7 commits intoelastic:mainfrom Sep 15, 2022
Merged
feat: replace custom sysctl implementation with stdlib#135kruskall merged 7 commits intoelastic:mainfrom
kruskall merged 7 commits intoelastic:mainfrom
Conversation
Remove custom string->mib conversion code and sysctl implementation. Reduce code complexity and cgo dependency
Collaborator
andrewkroh
reviewed
Sep 14, 2022
Member
There was a problem hiding this comment.
The one concern I had was with performance. The only difference is that the unix package makes two sysctl calls (one to determine buf size and one to get the data). The old implementation in this package made one call with a max size buffer.
This does make it a bit slower, but it's not significant.
func BenchmarkKernProcargs(b *testing.B) {
pid := os.Getpid()
var p process
for i := 0; i < b.N; i++ {
kern_procargs(pid, &p)
}
}% benchcmp before-self.txt after-self.txt
benchcmp is deprecated in favor of benchstat: https://pkg.go.dev/golang.org/x/perf/cmd/benchstat
benchmark old ns/op new ns/op delta
BenchmarkKernProcargs-10 13783 15075 +9.37%
benchmark old allocs new allocs delta
BenchmarkKernProcargs-10 106 109 +2.83%
benchmark old bytes new bytes delta
BenchmarkKernProcargs-10 31931 34104 +6.81%
% benchstat before-self.txt after-self.txt
name old time/op new time/op delta
KernProcargs-10 13.8µs ± 0% 15.1µs ± 0% ~ (p=1.000 n=1+1)
name old alloc/op new alloc/op delta
KernProcargs-10 31.9kB ± 0% 34.1kB ± 0% ~ (p=1.000 n=1+1)
name old allocs/op new allocs/op delta
KernProcargs-10 106 ± 0% 109 ± 0% ~ (p=1.000 n=1+1)
Member
|
And can you please add changelog entries for this and the other recent changes. |
Member
Author
|
Removed unused methods and added the changelog entry 👍 |
andrewkroh
approved these changes
Sep 14, 2022
This was referenced May 16, 2023
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Remove custom string->mib conversion code and sysctl implementation.
Reduce code complexity and cgo dependency
Related to elastic/apm-server#8718