-
Notifications
You must be signed in to change notification settings - Fork 422
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
perf: use lazy program data initialization
We currently initialize all task context related fields on the beginning of our BPF programs. Reading all the relevant fields takes some CPU cycles although these fields are not always used. In many cases, for example when filters are applied, the event is not sent to userspace and is just dropped without any side effects. Reading only the essential fields and leaving all other fields initialization to the submit stage will avoid wasting these cycles, and will also allow us to perform some of the event enrichment in userspace instead (not part of this PR). To do this change, we have to remove the matched_policies which were cached in task_info since we can't check if "context changed" anymore. Considering that the average user will only use one or two scope filters (e.g. container id or binary name), computing the scope on every run is not a big overhead - running BPF statistics with and without the change verified this is indeed the case, and with the change the performance is even slightly better. Although this change does not introduce a visible performance gain for most of the events, it is clear for some other specific event that it does. For example, the hidden_inode event which attach a program to the filldir64 function has a 50% performance gain.
- Loading branch information
1 parent
8030c56
commit f806cb4
Showing
6 changed files
with
105 additions
and
164 deletions.
There are no files selected for viewing
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 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 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 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
Oops, something went wrong.