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

scheduler: fix perf downgrade of cases without presence of (anti-)affinity pods #76973

Merged
merged 2 commits into from
Apr 25, 2019

Conversation

Huang-Wei
Copy link
Member

What type of PR is this?

/kind bug
/sig scheduling
/assign @bsalamat @ravisantoshgudimetla

What this PR does / why we need it:

  • Some background: scheduler: performance improvement on PodAffinity #76243 was introduced to improve pod affinity, but it sorts of regress other usecases, so we reverted that PR.

  • Root cause of old PR: For a typical kubemark test, it just runs some regular workloads. No affinity pods are involved in. With that said, the mutex in inter-podaffinity priority is actually a non-op. So, what's the exact overhead old pr brings in? I did a test and it turns out the allocation of *int64 pointer for each node is the culprit.

  • How this PR fixes the issue: This PR introduces a dynamic init mechanism for those *int64 pointers. Then in the final score calculation phase, if it's not inited, we simply assign score 0 to it.

  • Benchmark tests for Inter-PodAffinity Priority: It shows old PR has 60%+ overhead (for cases without affinity pods), and new(this) PR has zero overhead.

  • Can this PR still help PodAffinity cases: Yes.

Which issue(s) this PR fixes:

A robust version of #76243.

Special notes for your reviewer:

If you have already reviewed the old PR, just take a look at commit 4bc5476.

Does this PR introduce a user-facing change?:

NONE

(I guess we shouldn't mention it in release-note again, yes or no?)

@k8s-ci-robot k8s-ci-robot added the release-note-none Denotes a PR that doesn't merit a release note. label Apr 24, 2019
@k8s-ci-robot k8s-ci-robot added kind/bug Categorizes issue or PR as related to a bug. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. sig/scheduling Categorizes an issue or PR as relevant to SIG Scheduling. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. needs-priority Indicates a PR lacks a `priority/foo` label and requires one. labels Apr 24, 2019
@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Apr 24, 2019
@bsalamat bsalamat requested review from bsalamat and removed request for smarterclayton and thockin April 24, 2019 17:33
Copy link
Member

@bsalamat bsalamat left a comment

Choose a reason for hiding this comment

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

Thanks, @Huang-Wei! It looks good. I hope this one behaves as expected.
I also see a couple other potential optimizations in finding min/max, but let's first see if this PR improves performance. We can add those in follow-up PRs.

}
}

// calculate final priority score for each node
result := make(schedulerapi.HostPriorityList, 0, len(nodes))
maxMinDiff := maxCount - minCount
Copy link
Member

Choose a reason for hiding this comment

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

It looks to me that if maxMinDiff is zero, we can skip the for loop below altogether.

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks for the review!

Yes, that could be possible. I can investigate later to see whether current Priority reduce interface is fine with an empty []schedulerapi.HostPriorityList vs. mandatory entries with schedulerapi.HostPriority{Host: node.Name, Score: 0} in the result set.

Copy link
Member

@bsalamat bsalamat left a comment

Choose a reason for hiding this comment

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

/lgtm
/approve

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Apr 24, 2019
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: bsalamat, Huang-Wei

The full list of commands accepted by this bot can be found here.

The pull request process is described 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

@Huang-Wei
Copy link
Member Author

/retest

@k8s-ci-robot k8s-ci-robot merged commit 1a325db into kubernetes:master Apr 25, 2019
@Huang-Wei Huang-Wei deleted the lazy-init-int64-ptr branch May 3, 2019 18:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/bug Categorizes issue or PR as related to a bug. lgtm "Looks good to me", indicates that a PR is ready to be merged. needs-priority Indicates a PR lacks a `priority/foo` label and requires one. release-note-none Denotes a PR that doesn't merit a release note. sig/scheduling Categorizes an issue or PR as relevant to SIG Scheduling. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants