-
Notifications
You must be signed in to change notification settings - Fork 1.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
Optimize Adaptive Server Selection #13952
Conversation
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.
Please attach the CPU flame graph where we saw the increased CPU utilization.
Also would be good to post the before vs after CPU utilization.
...main/java/org/apache/pinot/broker/routing/instanceselector/ReplicaGroupInstanceSelector.java
Outdated
Show resolved
Hide resolved
...main/java/org/apache/pinot/broker/routing/instanceselector/ReplicaGroupInstanceSelector.java
Outdated
Show resolved
Hide resolved
...main/java/org/apache/pinot/broker/routing/instanceselector/ReplicaGroupInstanceSelector.java
Outdated
Show resolved
Hide resolved
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #13952 +/- ##
============================================
- Coverage 61.75% 57.92% -3.83%
- Complexity 207 219 +12
============================================
Files 2436 2612 +176
Lines 133233 143201 +9968
Branches 20636 21985 +1349
============================================
+ Hits 82274 82953 +679
- Misses 44911 53752 +8841
- Partials 6048 6496 +448
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
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.
lgtm otherwise, linter is failing, could you please fix?
...main/java/org/apache/pinot/broker/routing/instanceselector/ReplicaGroupInstanceSelector.java
Show resolved
Hide resolved
...main/java/org/apache/pinot/broker/routing/instanceselector/ReplicaGroupInstanceSelector.java
Outdated
Show resolved
Hide resolved
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.
LGTM. Thanks for this optimization.
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.
minor. Thanks for the optimizations
Summary
This PR enhances the server selection logic in the

adaptive server selector
by using aHashMap
for efficient server rank lookups and aHashSet
to track selected servers. These changes improve performance when processing large sets of segments and servers, resulting in faster and more scalable server selection.Description
The existing implementation of the adaptive server selector uses a linear search on a list (
serverRankList
) to determine server rankings, leading to performance inefficiencies when handling large numbers of serversserverRankMap
is now used for ranking lookups, providing O(1) access to server ranks compared to the previous O(n) list iteration.HashSet
(selectedServers) is introduced to track which servers have been selected and use it exit earlyComplexity:
Total complexity of the adaptive server selection process per segment is reduced to O(m) per segment (with m being the number of candidates), improving the overall process to O(n * m) for n segments.
Previous: O(n* m * s) (with s being the number of total servers).