-
Notifications
You must be signed in to change notification settings - Fork 416
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
Proctree refactor #4362
Closed
Closed
Proctree refactor #4362
Conversation
This file contains 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
geyslan
force-pushed
the
proctree-refactor
branch
from
October 22, 2024 00:05
3b1939b
to
62c8696
Compare
geyslan
force-pushed
the
proctree-refactor
branch
from
October 22, 2024 12:21
62c8696
to
5c2e985
Compare
Running tool: /home/gg/.goenv/versions/1.22.4/bin/go test -benchmem -run=^$ -tags ebpf -bench ^Benchmark_newProcStatus$ github.com/aquasecurity/tracee/pkg/utils/proc -benchtime=10000000x goos: linux goarch: amd64 pkg: github.com/aquasecurity/tracee/pkg/utils/proc cpu: AMD Ryzen 9 7950X 16-Core Processor Benchmark_newProcStatus-32 10000000 13203 ns/op 17851 B/op 137 allocs/op PASS ok github.com/aquasecurity/tracee/pkg/utils/proc 132.033s
This short-circuits the status parsing by avoiding fully parsing all status fields. It also makes ProcStatus a concrete type that contains only the fields we are interested in, what reduces the memory footprint. To reduce the size of the function it now uses a map to lookup the field handler functions. --- Running tool: /home/gg/.goenv/versions/1.22.4/bin/go test -benchmem -run=^$ -tags ebpf -bench ^Benchmark_newProcStatus$ github.com/aquasecurity/tracee/pkg/utils/proc -benchtime=10000000x goos: linux goarch: amd64 pkg: github.com/aquasecurity/tracee/pkg/utils/proc cpu: AMD Ryzen 9 7950X 16-Core Processor Benchmark_newProcStatus-32 10000000 5551 ns/op 5136 B/op 29 allocs/op PASS ok github.com/aquasecurity/tracee/pkg/utils/proc 55.516s --- | Metric | Old Bench. | New Bench. | Improvement (%) | |--------------------------|------------|------------|-----------------| | Execution Time (ns/op) | 13203 | 5551 | ~57.9% faster | | Memory Allocations (B/op)| 17851 | 5136 | ~71.2% reduction| | Allocations (allocs/op) | 137 | 29 | ~78.8% reduction| | Total Time (seconds) | 132.033 | 55.516 | ~57.9% faster |
Running tool: /home/gg/.goenv/versions/1.22.4/bin/go test -benchmem -run=^$ -tags ebpf -bench ^Benchmark_newProcStat$ github.com/aquasecurity/tracee/pkg/utils/proc -benchtime=10000000x goos: linux goarch: amd64 pkg: github.com/aquasecurity/tracee/pkg/utils/proc cpu: AMD Ryzen 9 7950X 16-Core Processor Benchmark_newProcStat-32 10000000 14336 ns/op 2976 B/op 45 allocs/op PASS ok github.com/aquasecurity/tracee/pkg/utils/proc 143.369s
geyslan
force-pushed
the
proctree-refactor
branch
from
October 22, 2024 20:32
5c2e985
to
a960304
Compare
This short-circuits the stat parsing by avoiding fully parsing all stat fields. It also removed ProcStat unused fields leaving the unique we are interested in, what reduces the memory footprint. To reduce the size of the function it now uses a array to lookup the field handler functions. --- Running tool: /home/gg/.goenv/versions/1.22.4/bin/go test -benchmem -run=^$ -tags ebpf -bench ^Benchmark_newProcStat$ github.com/aquasecurity/tracee/pkg/utils/proc -benchtime=10000000x goos: linux goarch: amd64 pkg: github.com/aquasecurity/tracee/pkg/utils/proc cpu: AMD Ryzen 9 7950X 16-Core Processor Benchmark_newProcStat-32 10000000 5591 ns/op 2657 B/op 13 allocs/op PASS ok github.com/aquasecurity/tracee/pkg/utils/proc 55.915s --- | Metric - | Old Bench. | New Bench.| Improvement (%) | |---------------------------|------------|-----------|-----------------| | Execution Time (ns/op) | 14336 | 5591 | ~61.0% faster | | Memory Allocations (B/op) | 2976 | 2657 | ~10.7% reduction| | Allocations (allocs/op) | 45 | 13 | ~71.1% reduction| | Total Time (seconds) | 143.369 | 55.915 | ~61.0% faster |
The field started_time fetched from /proc stat file and passed as ticks to ClockTicksToNsSinceBootTime() is an uint64.
geyslan
force-pushed
the
proctree-refactor
branch
from
October 22, 2024 20:37
a960304
to
bb573be
Compare
This was tackled by #4364. |
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.
1. Explain what the PR does
2. Explain how to test it
3. Other comments