karmada icon indicating copy to clipboard operation
karmada copied to clipboard

skip calculate available replicas when no need

Open zhzhuang-zju opened this issue 1 year ago • 6 comments

What type of PR is this? /kind feature

What this PR does / why we need it: When Karmada is scheduling, it will always invoke calAvailableReplicas to 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?:

NONE

zhzhuang-zju avatar Jan 23 '24 11:01 zhzhuang-zju

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: To complete the pull request process, please assign garrybest after the PR has been reviewed. You can assign the PR to them by writing /assign @garrybest in a comment when ready.

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 /approve in a comment Approvers can cancel approval by writing /approve cancel in a comment

karmada-bot avatar Jan 23 '24 11:01 karmada-bot

Codecov Report

Attention: Patch coverage is 58.33333% with 5 lines in your changes are missing coverage. Please review.

Project coverage is 53.07%. Comparing base (d508417) to head (8ef8ca3). Report is 240 commits behind head on master.

Files Patch % Lines
.../scheduler/core/spreadconstraint/group_clusters.go 0.00% 4 Missing and 1 partial :warning:

:exclamation: Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #4574      +/-   ##
==========================================
+ Coverage   51.89%   53.07%   +1.17%     
==========================================
  Files         246      251       +5     
  Lines       24329    20395    -3934     
==========================================
- Hits        12625    10824    -1801     
+ Misses      11017     8857    -2160     
- Partials      687      714      +27     
Flag Coverage Δ
unittests 53.07% <58.33%> (+1.17%) :arrow_up:

Flags with carried forward coverage won't be shown. Click here to find out more.

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

codecov-commenter avatar Jan 23 '24 12:01 codecov-commenter

When Karmada is scheduling, it will always invoke calAvailableReplicas to calculate available replicas, regardless of necessity, thereby increasing CPU overhead.

Well, I'm afraid not. This func will only be invoked when strategy is Aggregated or DynamicWeight which is necessay indeed.

Garrybest avatar Jan 23 '24 13:01 Garrybest

Well, I'm afraid not. This func will only be invoked when strategy is Aggregated or DynamicWeight which is necessay indeed.

refer to https://github.com/karmada-io/karmada/blob/d508417a1e9b6be048a181ae89adbb94e1b08fbb/pkg/scheduler/core/common.go#L32-L38 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.

zhzhuang-zju avatar Jan 24 '24 01:01 zhzhuang-zju

/retest

RainbowMango avatar Feb 18 '24 08:02 RainbowMango

cc @Garrybest

zhzhuang-zju avatar Apr 28 '24 07:04 zhzhuang-zju