-
Notifications
You must be signed in to change notification settings - Fork 417
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
Changelog optimization #4242
Merged
Merged
Changelog optimization #4242
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
This comment was marked as resolved.
This comment was marked as resolved.
geyslan
force-pushed
the
changelog-opt
branch
2 times, most recently
from
August 12, 2024 12:41
8efa7b3
to
c32dcc0
Compare
These optimizations make the enforceSizeBoundary function more efficient across various scenarios, leading to overall better performance while maintaining the same behaviour (*). Running tool: /home/gg/.goenv/versions/1.22.4/bin/go test -benchmem -run=^$ -tags ebpf -bench ^(BenchmarkEnforceSizeBoundaryOld|BenchmarkEnforceSizeBoundary)$ github.com/aquasecurity/tracee/pkg/changelog -benchtime=100000000x goos: linux goarch: amd64 pkg: github.com/aquasecurity/tracee/pkg/changelog cpu: AMD Ryzen 9 7950X 16-Core Processor | Test Case | Old (ns/op) | New (ns/op) | (%) | |------------------------|-------------|-------------|--------| | No change needed | 1.446 | 1.434 | 0.83% | | Trim excess duplicates | 30.18 | 21.97 | 27.21% | | Remove oldest entries | 27.29 | 21.39 | 21.60% | Since enforceSizeBoundary is called by setAt, the performance improvements will be reflected in the latter: -bench ^(setAtOld|setAt)$ | Test Case | Old (ns/op) | New (ns/op) | (%) | |--------------------|-------------|-------------|--------| | All Scenarios | 1267 | 1163 | 8.21% | | Within Limit | 1770 | 1747 | 1.30% | Tests were fixed and added to ensure the correctness of the implementation. Benchmarks were also added to track the performance improvements. (*) The behaviour of the function is the same, but the implementation fixes a bug that when coalescing duplicate values, the removal of the oldest entry was not being done correctly. Instead of removing the oldest entry, the function was removing the newest one.
Probably related: #3878 |
rscampos
approved these changes
Aug 23, 2024
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, @geyslan just double check the setAt because couldn't run it here.
Finished (10000000x):
|
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
8cee7a2 perf(changelog): optimize enforceSizeBoundary
3bc61a8 chore(changelog): avoid unnecessary initialization
8cee7a2 perf(changelog): optimize enforceSizeBoundary
2. Explain how to test it
3. Other comments
This is part of the proctree effort.