-
Notifications
You must be signed in to change notification settings - Fork 1k
skip calculate available replicas when no need #4574
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
base: master
Are you sure you want to change the base?
Conversation
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #4574 +/- ##
==========================================
- Coverage 45.60% 45.60% -0.01%
==========================================
Files 692 692
Lines 57678 57685 +7
==========================================
+ Hits 26305 26307 +2
- Misses 29728 29735 +7
+ Partials 1645 1643 -2
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Well, I'm afraid not. This func will only be invoked when strategy is Aggregated or DynamicWeight which is necessay indeed. |
refer to karmada/pkg/scheduler/core/common.go Lines 32 to 38 in d508417
as you can see, the function GroupClustersWithScore is executed first, and then the function SelectBestClusters. And function GroupClustersWithScore will execute function calAvailableReplicas to calculate available replicas, no matter what the strategy is.
|
631ca2f to
6b84629
Compare
jwcesign
left a comment
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.
Other lgtm
6b84629 to
e1a71e5
Compare
|
/retest |
|
cc @Garrybest |
|
@zhzhuang-zju Please help to resolve the conflicts, i will take a look then. |
Received, I will pick it up soon. |
|
OK. No rush. |
|
/gemini review |
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.
Code Review
This pull request introduces an optimization to skip calculating available replicas during scheduling when it's not necessary. However, the implementation has a critical issue: it incorrectly skips the calculation for the Duplicated scheduling strategy, which would lead to a panic due to a division-by-zero error in the scoring function. There is also a potential nil pointer dereference. I have provided a detailed comment with a suggested fix for this function. Additionally, I've pointed out a minor discrepancy in a test case name for better clarity.
40ce389 to
1c223cf
Compare
RainbowMango
left a comment
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.
/assign
@zhzhuang-zju The failing e2e test seems unrelated, but could you please give it a look?
sure~ |
|
/genmini review |
|
/gemini review |
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.
Code Review
This pull request introduces an optimization to skip calculating available replicas when it's not necessary, such as for 'Duplicated' or static 'Weighted' scheduling strategies. The changes are logical and well-tested. My review includes a suggestion to improve the readability of the new logic and points out an inconsistency with existing code that should be addressed for better maintainability.
1c223cf to
85e5f42
Compare
This instability in e2e tests is caused by feature changes. Some Prometheus metrics only appear at the metrics endpoint after actual usage. For example, |
41dfd0c to
4eda7fb
Compare
4eda7fb to
b0cb266
Compare
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here.
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
1 similar comment
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here.
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
record |
|
/retest |
|
/gemini review |
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.
Code Review
This pull request introduces a valuable optimization to skip the calculation of available replicas for Duplicated and static weighted scheduling strategies, which should help reduce CPU overhead during scheduling. The implementation looks solid, with the core logic encapsulated in new helper functions and backed by unit tests. I've identified a potential bug in an updated E2E test where a slice is not being reset, and I've also suggested adding a comment to a complex function to improve maintainability. Overall, this is a good improvement.
Signed-off-by: zhzhuang-zju <[email protected]>
aded184 to
ee0e484
Compare
What type of PR is this?
/kind feature
What this PR does / why we need it:
When Karmada is scheduling, it will always invoke
calAvailableReplicasto calculate available replicas, regardless of necessity, thereby increasing CPU overhead.Which issue(s) this PR fixes:
Fixes #
Special notes for your reviewer:
NONE
Does this PR introduce a user-facing change?: