fix: improve performance of magic_write event #3899
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Currently, when magic_write event is selected on its own it introduces a very high overhead on the system. This is due to the reason that the logic used for magic_write event is mixed with the logic used for vfs_write(v) events and capture write, thus a lot of extra unnecessary calculations are being performed.
Fix that issue by seperating the logic used for magic_write from any other logic.
To compare the results, following is the first few lines of output of
the command:
sudo bpftool prog show | grep run_time | awk '{print $1" "$2" "$3" "$4" "$8" "$9" "$10" "$11}' | sort -g -r -k 6
Without the change:
With the change:
As can be seen, vfs_write_magic programs are not the "top" programs
anymore. Also, while all other events have more or less the same runtime
during this period, the magic_write event total time has changed:
Total runtime of magic_write programs before the change is 741250170 ns.
Total runtime of magic_write programs after the change is 126045185 ns.
So assuming the load on the system was the same during this period,
there is more than x5 improvement.
1. Explain what the PR does
"Replace me with
make check-pr
output"2. Explain how to test it
3. Other comments
close #3445