Skip to content
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

skip calculate available replicas when no need #4574

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

zhzhuang-zju
Copy link
Contributor

@zhzhuang-zju zhzhuang-zju commented Jan 23, 2024

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

@karmada-bot karmada-bot added the kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. label Jan 23, 2024
@karmada-bot
Copy link
Collaborator

[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 karmada-bot added the size/S Denotes a PR that changes 10-29 lines, ignoring generated files. label Jan 23, 2024
@codecov-commenter
Copy link

codecov-commenter commented Jan 23, 2024

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 ⚠️

❗ 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%) ⬆️

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

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@Garrybest
Copy link
Member

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.

@zhzhuang-zju
Copy link
Contributor Author

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

refer to

func SelectClusters(clustersScore framework.ClusterScoreList,
placement *policyv1alpha1.Placement, spec *workv1alpha2.ResourceBindingSpec) ([]*clusterv1alpha1.Cluster, error) {
startTime := time.Now()
defer metrics.ScheduleStep(metrics.ScheduleStepSelect, startTime)
groupClustersInfo := spreadconstraint.GroupClustersWithScore(clustersScore, placement, spec, calAvailableReplicas)
return spreadconstraint.SelectBestClusters(placement, groupClustersInfo, spec.Replicas)

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.

@karmada-bot karmada-bot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. and removed size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Jan 26, 2024
Copy link
Member

@jwcesign jwcesign left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Other lgtm

pkg/scheduler/core/spreadconstraint/group_clusters.go Outdated Show resolved Hide resolved
pkg/scheduler/core/spreadconstraint/select_clusters.go Outdated Show resolved Hide resolved
pkg/scheduler/core/spreadconstraint/select_clusters.go Outdated Show resolved Hide resolved
Signed-off-by: zhzhuang-zju <m17799853869@163.com>
@RainbowMango
Copy link
Member

/retest

Signed-off-by: zhzhuang-zju <m17799853869@163.com>
@karmada-bot karmada-bot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Apr 28, 2024
@zhzhuang-zju
Copy link
Contributor Author

cc @Garrybest

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants