Optimizing version check to happen once per run #597
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.
Description
When running the python profiler on this library, I noticed a pretty intense amount of calls and total time spent in
Version.py
. Upon investigation, I traced the call to a check that happened once per loop infetch_one
. Taking a clue from #363 (which is more than a year old and sitting), I refactored what had initially been a@lru_cache
change on my end to just be a static call once and then replaced all if trees that used it with the variable. I also changed as little as possible in an attempt to get this through. Below are the cProfiler stats before and after the change. Tested when parsing through a remote binary log, limited both to 3000 events from the stream reader just to save time, there is a nearly 50% speedup and the calls toVersion.py
is no longer dead at the top of the cProfiler for time spent.Type of Change
Checklist
Tests
Additional Information
As stated above, there IS another PR that makes this change, but likely due to the fact that there were both multiple changes being thrown in and an unresponsive PR, I'm hoping this can make it through as it provides an immense speedup to performance of this library.
Before
After