-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
Add benchmarks for scanning files #36078
Conversation
So, we can compare how much slower the fingerprinting mode against using `device` and `inode` in the scanner.
Pinging @elastic/elastic-agent-data-plane (Team:Elastic-Agent-Data-Plane) |
Just a suggestion, you can use https://pkg.go.dev/golang.org/x/perf/cmd/benchstat to compare two or more benchmarks. |
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
One possible improvement, might want to use https://pkg.go.dev/testing#B.ResetTimer right before the for loop that does GetFiles
, that would remove the time it takes to make the files from the results.
So, we can compare how much slower the fingerprinting mode against using `device` and `inode` in the scanner. (cherry picked from commit b481143)
So, we can compare how much slower the fingerprinting mode against using `device` and `inode` in the scanner. (cherry picked from commit b481143) Co-authored-by: Denis <[email protected]>
So, we can compare how much slower the fingerprinting mode against using `device` and `inode` in the scanner.
What does this PR do?
So, we can compare how much slower the fingerprinting mode against using
device
andinode
in the scanner.Why is it important?
Our customers would want to know the performance impact.
Benchmark Results
Baseline:
main
branch before the scanner revamp and the fingerprint mode was introducedGit HEAD at a755bbc
Average ~33194198,2 ns/op
After the scanner revamp and
prospector.scanner.fingerprint.enabled: false
Git HEAD at 061cb88
Average ~5398583 ns/op
The scanner optimisations made in #35734 led to ~84% performance boost in normal mode (
device+inode
, not fingerprint).prospector.scanner.fingerprint.enabled: true
,prospector.scanner.fingerprint.length: 1024
The results are taken with this change applied #36073
Git HEAD at 061cb88
Average ~22251610,4 ns/op
Using fingerprint mode with length
1024
is ~76% slower than the defaultdevice+inode
mode in the NEW scanner, however it's still faster than the defaultdevice+inode
in the old scanner (baseline).prospector.scanner.fingerprint.enabled: true
,prospector.scanner.fingerprint.length: 512
Using fingerprint mode with a shorter length
512
does not significantly affect the performanceCPU Profile
As you can see from this CPU profile collected for the
prospector.scanner.fingerprint.enabled: true
,prospector.scanner.fingerprint.length: 1024
case the main contributor – 94,01% is the syscall to either open or close the file. So, optimisations on hashing would not make much of a difference.Full report:
profile001.pdf
Conclusion
Even activating the fingerprint mode in the new FileScanner it's working faster than the old FileScanner before the optimisations introduced in #35734
Related issues