8000 test: Benchmark tracee-rules by danielpacak · Pull Request #785 · aquasecurity/tracee · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

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

Merged
merged 6 commits into from
Jun 24, 2021
Merged

test: Benchmark tracee-rules #785

merged 6 commits into from
Jun 24, 2021

Conversation

danielpacak
Copy link
Contributor

Signed-off-by: Daniel Pacak pacak.daniel@gmail.com

Signed-off-by: Daniel Pacak <pacak.daniel@gmail.com>
@danielpacak danielpacak marked this pull request as ready for review June 23, 2021 16:39
@danielpacak danielpacak requested a review from simar7 June 23, 2021 16:41
@simar7
Copy link
Member
simar7 commented Jun 24, 2021

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.

Copy link
Member
@simar7 simar7 left a 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.

Comment on lines +54 to +55
eventsCh := make(chan types.Event, inputEventsCount)
ProduceEventsInMemory(eventsCh, inputEventsCount)
Copy link
Collaborator

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

Copy link
Contributor Author

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.

Comment on lines +57 to +62
inputs := engine.EventSources{
Tracee: eventsCh,
}
output := make(chan types.Finding, inputEventsCount)

e := engine.NewEngine(sigs, inputs, output, os.Stderr)
Copy link
Collaborator

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

Copy link
Contributor Author
@danielpacak danielpacak Jun 24, 2021

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))
	}
}

danielpacak and others added 5 commits June 24, 2021 14:18
Signed-off-by: Daniel Pacak <pacak.daniel@gmail.com>
…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>
@simar7 simar7 self-requested a review June 24, 2021 21:36
@simar7
Copy link
Member
simar7 commented Jun 24, 2021

lgtm, merging to rebase on top with my work

@simar7 simar7 merged commit acf1752 into aquasecurity:main Jun 24, 2021
@danielpacak danielpacak deleted the tracee_rules_benchmarks branch June 25, 2021 07:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants
0