Skip to content
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

perf: change falco_engine::process_event to lookup sources by index #1944

Merged
merged 1 commit into from
Apr 6, 2022

Conversation

deepskyblue86
Copy link
Member

@deepskyblue86 deepskyblue86 commented Mar 16, 2022

What type of PR is this?
falco_engine::process_event gets called for every inspector event.
Profiling showed that std::map::find takes about 10% of falco_engine::process_event, and that can easily be improved by accessing the source by index.

How I tested it

https://gist.github.com/deepskyblue86/91ca71de9b464e5dcd87deac1b911a6d

Results

impl IR (just item access) detail
original 1450 std::map::find
vector 150 std::vector::at

Uncomment one (or more) /kind <> lines:

/kind bug

/kind cleanup

/kind design

/kind documentation

/kind failing-test

/kind feature

If contributing rules or changes to rules, please make sure to also uncomment one of the following line:

/kind rule-update

/kind rule-create

Any specific area of the project related to this PR?

Uncomment one (or more) /area <> lines:

/area build

/area engine

/area rules

/area tests

/area proposals

What this PR does / why we need it:
falco_engine::process_event performance enhancement

Which issue(s) this PR fixes:

Fixes #

Special notes for your reviewer:

Does this PR introduce a user-facing change?:

update: improved Falco engine event processing performance

@leogr
Copy link
Member

leogr commented Mar 17, 2022

/milestone 0.32.0

@poiana poiana added this to the 0.32.0 milestone Mar 17, 2022
leogr
leogr previously approved these changes Mar 18, 2022
Copy link
Member

@leogr leogr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/approve

@poiana
Copy link
Contributor

poiana commented Mar 18, 2022

LGTM label has been added.

Git tree hash: 7c000edc51789a565a0a6a328c2678e30fe0d428

Copy link
Contributor

@jasondellaluce jasondellaluce left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks great @deepskyblue86!! Left you a minor suggestion, let me know what you think before approving.

first(n), second(p) {}

// pair-like names
std::string first; // source
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since we don't need pair<> anymore, wouldn't it be better to give these more significant names? This would make it more understandable for newcomer fellow contributors. My vote would go to name these source and ruleset. Let me know what you think!

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was uncertain about it... let's do it 👍

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

... done 😸

falco_engine::process_event gets called for every inspector event.
Profiling showed that std::map::find takes about 10% of
falco_engine::process_event, and that can easily improved by accessing
the source by index.

Signed-off-by: Angelo Puglisi <[email protected]>
Copy link
Contributor

@jasondellaluce jasondellaluce left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/approve

Thanks 🥳

@poiana
Copy link
Contributor

poiana commented Mar 31, 2022

LGTM label has been added.

Git tree hash: a2ca25c54f9702042bd9d4a523d2f28585886208

Copy link
Member

@leogr leogr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/milestone 0.32.0

/approve

Thank you!

@poiana
Copy link
Contributor

poiana commented Apr 6, 2022

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: deepskyblue86, jasondellaluce, leogr

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:
  • OWNERS [jasondellaluce,leogr]

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@poiana poiana merged commit e8cb96a into falcosecurity:master Apr 6, 2022
@deepskyblue86 deepskyblue86 deleted the optimize-process_event2 branch April 6, 2022 13:17
@mstemm mstemm mentioned this pull request Apr 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants