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

-Add scheduler optimization options, short circuit all predicates if … #56926

Merged
merged 1 commit into from
Jan 14, 2018

Conversation

wgliang
Copy link
Contributor

@wgliang wgliang commented Dec 7, 2017

…one predicate fails

Signed-off-by: Wang Guoliang iamwgliang@gmail.com

What this PR does / why we need it:
Short circuit all predicates if one predicate fails.

I think we can add a switch to control it, maybe some scenes do not need to know all the causes of failure, but also can get a great performance improvement; if you need to fully understand the reasons for the failure, and accept the current performance requirements, can maintain the current logic. It should expose this switch to the user.

Which issue(s) this PR fixes (optional, in fixes #<issue number>(, fixes #<issue_number>, ...) format, will close the issue(s) when PR gets merged):

Fixes #56889 and #48186

Special notes for your reviewer:
@davidopp

Release note:

Allow scheduler set AlwaysCheckAllPredicates, short circuit all predicates if one predicate fails can greatly improve the scheduling performance.

@k8s-ci-robot k8s-ci-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. do-not-merge/release-note-label-needed Indicates that a PR should not merge because it's missing one of the release note labels. needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Dec 7, 2017
@k8s-github-robot k8s-github-robot added the kind/api-change Categorizes issue or PR as related to adding, removing, or otherwise changing an API label Dec 7, 2017
@wgliang
Copy link
Contributor Author

wgliang commented Dec 7, 2017

/assign @davidopp @jayunit100

@dims
Copy link
Member

dims commented Dec 11, 2017

/ok-to-test

@k8s-ci-robot k8s-ci-robot removed the needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. label Dec 11, 2017
@wgliang
Copy link
Contributor Author

wgliang commented Dec 12, 2017

/test pull-kubernetes-unit
/test pull-kubernetes-e2e-gce
/test pull-kubernetes-bazel-test

@wgliang
Copy link
Contributor Author

wgliang commented Dec 12, 2017

The test failed, I think I might need help when I short circuit all predicates if one predicate fails, what else do I need.

@wgliang
Copy link
Contributor Author

wgliang commented Dec 12, 2017

/retest

@wgliang
Copy link
Contributor Author

wgliang commented Dec 12, 2017

how can i fix it?
https://k8s-gubernator.appspot.com/build/kubernetes-jenkins/pr-logs/pull/56926/pull-kubernetes-bazel-test/21327/

W1212 03:56:43.025] ____From Testing //pkg/apis/core/validation:go_default_test:
I1212 03:56:43.126] ==================== Test output for //pkg/apis/core/validation:go_default_test:
I1212 03:56:43.126] --- FAIL: TestValidatePersistentVolumeClaimUpdate (0.01s)
I1212 03:56:43.126] 	validation_test.go:1428: Unexpected failure for scenario: valid-size-update-resize-enabled - [spec: Forbidden: is immutable after creation except resources.requests for bound claims]
I1212 03:56:43.127] FAIL

@davidopp
Copy link
Member

/cc @kubernetes/sig-scheduling-pr-reviews

@k8s-ci-robot k8s-ci-robot added the sig/scheduling Categorizes an issue or PR as relevant to SIG Scheduling. label Dec 12, 2017
@@ -111,6 +111,9 @@ type KubeSchedulerConfiguration struct {
// Indicate the "all topologies" set for empty topologyKey when it's used for PreferredDuringScheduling pod anti-affinity.
// DEPRECATED: This is no longer used.
FailureDomains string

// EnablePodFitsOnNodeOptimization enables shorting circuit all predicates if one predicate fails
EnablePodFitsOnNodeOptimization bool
Copy link
Contributor

@resouer resouer Dec 12, 2017

Choose a reason for hiding this comment

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

This is a bad name ... should be more specific like QuickFailPredicate or something else

Copy link
Member

Choose a reason for hiding this comment

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

I don't think we need an option for this. This should be default behavior in my opinion. It doesn't make sense to check all other predicates when one fails. We are adding the logic to order predicates and default ordering is to run predicates with lower overhead first. The whole ordering of predicates makes sense only if we stop checking predicates when one fails. Otherwise, the ordering is not useful.

Copy link
Member

@bsalamat bsalamat Dec 12, 2017

Choose a reason for hiding this comment

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

UPDATE: reading another thread, we may actually need a flag for those customers who want to find what are all the predicates that have failed for a node. So, let's rename this flag to something like AlwaysCheckAllPredicates. Default value should be false. Please add a comment in front of the flag to mention that enabling this option may hurt scheduler performance.

Copy link
Contributor

Choose a reason for hiding this comment

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

Totally agree this should put predicate ordering into consideration.

cc @wgliang It's https://github.com/kubernetes/community/pull/1152/files

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sorry, it's my fault I should say that put predicate ordering will improve performance even more. In fact, we have already sorted out our own scheduler, for example, we will calculate the smaller number of CPU cores, memory size in front of the complex information such as disk and network. In this way, the implementation of the previous failure, to avoid later more complex calculations.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@resouer You are right, I will rename it.

Copy link
Member

Choose a reason for hiding this comment

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

+1 for default behaviour setting AlwaysCheckAllPredicates to false.

@resouer
Copy link
Contributor

resouer commented Dec 12, 2017

This is related to what @bsalamat discussed recently.

But I am not very sure if an extra option is the solution ... or, fast fail should be default behavior at least . WDYT bobby?

@wgliang
Copy link
Contributor Author

wgliang commented Dec 13, 2017

@resouer Instead of modifying current default behavior, I wanted to add a higher-performance option, albeit losing some failure information.

@k8s-github-robot k8s-github-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Dec 16, 2017
@@ -917,7 +923,7 @@ func selectVictimsOnNode(
violatingVictims, nonViolatingVictims := filterPodsWithPDBViolation(potentialVictims.Items, pdbs)
reprievePod := func(p *v1.Pod) bool {
addPod(p)
fits, _, _ := podFitsOnNode(pod, meta, nodeInfoCopy, fitPredicates, nil, queue)
fits, _, _ := podFitsOnNode(pod, meta, nodeInfoCopy, fitPredicates, nil, queue, false)
Copy link
Member

Choose a reason for hiding this comment

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

Should it be true?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It has been modified.

@k8s-ci-robot k8s-ci-robot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. and removed size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Dec 17, 2017
@k8s-github-robot k8s-github-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Dec 17, 2017
@wgliang
Copy link
Contributor Author

wgliang commented Dec 18, 2017

/retest

@wgliang
Copy link
Contributor Author

wgliang commented Dec 18, 2017

Who can help me solve the problem or tell me the reason of test failure?

@wgliang
Copy link
Contributor Author

wgliang commented Dec 18, 2017

/retest

@@ -474,6 +475,11 @@ func podFitsOnNode(
if !fit {
// eCache is available and valid, and predicates result is unfit, record the fail reasons
failedPredicates = append(failedPredicates, reasons...)
// since alwaysCheckAllPredicates has not been set, the predicate evaluation is short
// circuited and there are chances of other predicates failing as well.
Copy link
Contributor

Choose a reason for hiding this comment

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

Actually, I wanted this to be logged using glog.V(5) or higher not as a comment in the code, the reason being debugging becomes easy when someone is going through scheduler logs.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

As for each node will be implemented here, so there will be a lot of log information is printed out, are you sure it is friendly?

Copy link
Contributor

Choose a reason for hiding this comment

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

I think thats a trade-off that we will have but putting logging at highest level might reduce the impact.

@yastij
Copy link
Member

yastij commented Jan 5, 2018

@wgliang - can you add your release-note between `` ?

@@ -377,6 +378,17 @@ func TestGenericScheduler(t *testing.T) {
expectsErr: true,
wErr: fmt.Errorf("persistentvolumeclaim \"existingPVC\" is being deleted"),
},
{
// alwaysCheckAllPredicates is true
Copy link
Member

Choose a reason for hiding this comment

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

Sorry, but this is not useful. You should probably add a couple of predicates and create a pod that fails all predicates and then check that all of the predicates are exercised when alwaysCheckAllPredicates is true.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@bsalamat Thank you very much for your guidance, I have already done it.

@k8s-github-robot k8s-github-robot added needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. and removed needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. labels Jan 6, 2018
@wgliang
Copy link
Contributor Author

wgliang commented Jan 9, 2018

/test pull-kubernetes-unit

@yastij
Copy link
Member

yastij commented Jan 10, 2018

@wgliang @bsalamat - Is this one ready to merge ?

@wgliang
Copy link
Contributor Author

wgliang commented Jan 11, 2018

I'm ready.
ping @bsalamat

@bsalamat
Copy link
Member

/lgtm

Thanks, @wgliang!

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Jan 11, 2018
@wgliang
Copy link
Contributor Author

wgliang commented Jan 11, 2018

/assign [@brendandburns @eparis @thockin @zmerlynn]

@thockin
Copy link
Member

thockin commented Jan 13, 2018

/approve

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jan 13, 2018
@k8s-github-robot k8s-github-robot added needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. and removed lgtm "Looks good to me", indicates that a PR is ready to be merged. needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. labels Jan 13, 2018
@wgliang
Copy link
Contributor Author

wgliang commented Jan 13, 2018

@bsalamat There has been a conflict commit, has been rebase. Please help delete do-not-merge label and merge PR. Thanks!

@ravisantoshgudimetla
Copy link
Contributor

ravisantoshgudimetla commented Jan 13, 2018

/lgtm
based on #56926 (comment). @wgliang You need to add your release-note between `` to remove the do-not-merge/release-note-label-needed. I think I don't have enough power to lgtm :).

@k8s-ci-robot k8s-ci-robot added release-note Denotes a PR that will be considered when it comes time to generate release notes. and removed do-not-merge/release-note-label-needed Indicates that a PR should not merge because it's missing one of the release note labels. labels Jan 13, 2018
@k82cn
Copy link
Member

k82cn commented Jan 14, 2018

/lgtm

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

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: bsalamat, k82cn, ravisantoshgudimetla, thockin, wgliang

Associated issue: #56889

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

Needs approval from an approver in each of these OWNERS Files:

You can indicate your approval by writing /approve in a comment
You can cancel your approval by writing /approve cancel in a comment

@k8s-github-robot
Copy link

/test all [submit-queue is verifying that this PR is safe to merge]

@k8s-github-robot
Copy link

Automatic merge from submit-queue. If you want to cherry-pick this change to another branch, please follow the instructions here.

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. lgtm "Looks good to me", indicates that a PR is ready to be merged. release-note Denotes a PR that will be considered when it comes time to generate release notes. sig/scheduling Categorizes an issue or PR as relevant to SIG Scheduling. 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.