[dtrace-perf-map] Use binary rather than linear search #86
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.
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.