-
-
Notifications
You must be signed in to change notification settings - Fork 3.3k
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 performance of ConsolidatorScanPriority comparison #8452
Improve performance of ConsolidatorScanPriority comparison #8452
Conversation
Hey @starteleport! Thank you for the contribution. Could you please add some simple test/benchmark proof we can run to assert the improvement? A reference/documentation proof would be great too 🙏 |
Sure! Here are the benchmark results:
Benchmark code
The whole point of this change is to avoid using If this queue wasn't used in a hot spot, this optimisation wouldn't make much sense, but I believe it would be beneficial to grab this low hanging fruit. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you! 👍
Description
This introduces a new Comparer and supplies it to the PrioorityQueue constructor. This yields 5-10 percent improvement in data points per second for all Lean benchmarks on my machine.
Related Issue
See issue #8451
Motivation and Context
The ConsolidatorScanPriority type implements IComparable and is used as the priority in the SubscriptionManager's priority queue. Due to the way comparison is handled for the case when PriorityQueue is not supplied with IComparer instance explicitly, an intermediate ObjectComparer is used for the comparison that eventually delegates comparison to ConsolidatorScanPriority.CompareTo.
Requires Documentation Change
No
How Has This Been Tested?
Lean benchmarks
Types of changes
Checklist:
bug-<issue#>-<description>
orfeature-<issue#>-<description>