-
Notifications
You must be signed in to change notification settings - Fork 444
test: Benchmark tracee-rules #785
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
test: Benchmark tracee-rules #785
Conversation
Signed-off-by: Daniel Pacak <pacak.daniel@gmail.com>
I think we need to add the new benchmark dir as part of the ignored dirs for opa test: https://github.com/aquasecurity/tracee/blob/main/tracee-rules/Makefile#L56 That would make the currently failing check pass. |
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.
Just one comment to be addressed for adding the reset of timer after initial setup is done.
eventsCh := make(chan types.Event, inputEventsCount) | ||
ProduceEventsInMemory(eventsCh, inputEventsCount) |
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.
maybe move this out of the bench loop? IMO we can produce the events once
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.
How would you Stop then engine (and benchmark iteration) in this approach? We generate 1000 events in each benchmark loop and close done channel when the input events channel is empty.
inputs := engine.EventSources{ | ||
Tracee: eventsCh, | ||
} | ||
output := make(chan types.Finding, inputEventsCount) | ||
|
||
e := engine.NewEngine(sigs, inputs, output, os.Stderr) |
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.
I think we shouldn't include the engine initialization in the benchmark
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.
One way to do that, which I tried out in this PR, is to use b.StopTimer and b.StartTime to skip timing events producer.
func BenchmarkEngineWithCodeInjectionRegoRule(b *testing.B) {
// Prepare signatures and what not
b.ResetTimer()
for i := 0; i < b.N; i++ {
b.StopTimer()
eventsCh := make(chan types.Event, inputEventsCount)
// Produce events without timing it
b.StartTimer()
// Start rules engine and wait until all events are processed
e.Start(waitForEventsProcessed(eventsCh))
b.Logf("Test is done with %d findings", len(output))
}
}
…om 100 to 1 millisecond Co-authored-by: Simar <1254783+simar7@users.noreply.github.com>
Signed-off-by: Daniel Pacak <pacak.daniel@gmail.com>
Signed-off-by: Daniel Pacak <pacak.daniel@gmail.com>
lgtm, merging to rebase on top with my work |
Signed-off-by: Daniel Pacak pacak.daniel@gmail.com