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

Improve save_args_to_submit_buf #4217

Merged
merged 1 commit into from
Aug 14, 2024

Conversation

geyslan
Copy link
Member

@geyslan geyslan commented Jul 31, 2024

1. Explain what the PR does

cf34d1f chore: improve save_args_to_submit_buf

This replaces the switch case branches for a direct access to a type
size table and uses bitmasking to decide about the code path to take.

Improvements:

| dist/tracee.bpf.o     | Before (B) | After (B) | Diff (B) | (%)     |
|-----------------------|------------|-----------|----------|---------|
| Size in Bytes         | 14118048   | 14098024  | -20024   | -0.14%  |

| sys_exit_submit       | Before (B) | After (B) | Diff (B) | (%)     |
|-----------------------|------------|-----------|----------|---------|
| Interpr Size (xlated) | 25248      | 19200     | -6048    | -23.96% |
| JITed Size (jited)    | 16600      | 12161     | -4439    | -26.73% |
| Memlock               | 28672      | 20480     | -8192    | -28.57% |

| Metric (1k evts)    | Before (ns) | After (ns) | Diff (ns) | (%)    |
|---------------------|-------------|------------|-----------|--------|
| Minimum Time        | 184,797     | 167,025    | -17,772   | -9.62% |
| Maximum Time        | 217,418     | 201,527    | -15,891   | -7.31% |
| Average Time        | 201,117     | 189,893    | -11,224   | -5.58% |

An improvement of ~ -11.22ns in the average time to process 1 single
event.

Benchmarked on:
- AMD Ryzen 9 7950X 16-Core Processor
- 64GB RAM

Runned with:
tracee -e execve,init_module,process_vm_writev,ptrace,arch_prctl,chdir

2. Explain how to test it

3. Other comments

@geyslan geyslan self-assigned this Jul 31, 2024
@geyslan geyslan force-pushed the save-args-to-submit-1.1 branch 2 times, most recently from bc7e849 to aa6f8e2 Compare July 31, 2024 20:30
@geyslan geyslan changed the title Reduce save_args_to_submit_buf Improve save_args_to_submit_buf Jul 31, 2024
@geyslan geyslan requested a review from yanivagman July 31, 2024 20:34
@geyslan geyslan marked this pull request as ready for review July 31, 2024 20:35
@geyslan geyslan force-pushed the save-args-to-submit-1.1 branch from aa6f8e2 to 9882329 Compare July 31, 2024 20:41
Copy link
Collaborator

@rscampos rscampos left a comment

Choose a reason for hiding this comment

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

LGTM - congrats on the improvement and the clean code!

This replaces the switch case branches for a direct access to a type
size table and uses bitmasking to decide about the code path to take.

Improvements:

| dist/tracee.bpf.o     | Before (B) | After (B) | Diff (B) | (%)     |
|-----------------------|------------|-----------|----------|---------|
| Size in Bytes         | 14118048   | 14098024  | -20024   | -0.14%  |

| sys_exit_submit       | Before (B) | After (B) | Diff (B) | (%)     |
|-----------------------|------------|-----------|----------|---------|
| Interpr Size (xlated) | 25248      | 19200     | -6048    | -23.96% |
| JITed Size (jited)    | 16600      | 12161     | -4439    | -26.73% |
| Memlock               | 28672      | 20480     | -8192    | -28.57% |

| Metric (1k evts)    | Before (ns) | After (ns) | Diff (ns) | (%)    |
|---------------------|-------------|------------|-----------|--------|
| Minimum Time        | 184,797     | 167,025    | -17,772   | -9.62% |
| Maximum Time        | 217,418     | 201,527    | -15,891   | -7.31% |
| Average Time        | 201,117     | 189,893    | -11,224   | -5.58% |

An improvement of ~ -11.22ns in the average time to process 1 single
event.

Benchmarked on:
- AMD Ryzen 9 7950X 16-Core Processor
- 64GB RAM

Runned with:
tracee -e execve,init_module,process_vm_writev,ptrace,arch_prctl,chdir
@geyslan geyslan force-pushed the save-args-to-submit-1.1 branch from 9882329 to cf34d1f Compare August 5, 2024 12:16
Copy link
Collaborator

@yanivagman yanivagman left a comment

Choose a reason for hiding this comment

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

LGTM

@geyslan geyslan merged commit e2c5f26 into aquasecurity:main Aug 14, 2024
32 checks passed
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.

3 participants