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

[dtrace-perf-map] Use binary rather than linear search #86

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

bdw
Copy link

@bdw bdw commented Aug 28, 2020

On a dtrace data file of 2342965 lines and a perf map file of 19072 lines, processing of dtrace-perf-map.pl took well over 5 hours.

Investigation demonstrated that this was because of the inner loop over the @map_entries array; reducing the length of that array to 10 would give a 5s runtime, 20 a 10s, 30 a 15s, etc.
Perl is good for a lot of things but not for 4 billion array iterations.

It seemed to me that we could improve this by sorting the array and applying binary search (An extent map was also considered but thought too complex to build, though fun).
Processing the same file now takes roughly 20s on the same machine (11s on mine).

Or, binary search go brrr.

Linear search was very slow on a decently-sized perf map, but with
sorting + binary search it's rather faster.
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.

1 participant