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

Optimize Repeated registration of AlgorithmProvider when ApplyFeatureGates #54047

Merged
merged 1 commit into from
Oct 30, 2017

Conversation

kuramal
Copy link
Contributor

@kuramal kuramal commented Oct 17, 2017

What this PR does / why we need it:
modified ApplyFeatureGates() just add/del features, cancel the register of all AlgorithmProvider.

there is Repeated registration of all AlgorithmProvider when ApplyFeatureGates() runs;
AlgorithmProvider have already registered when package defaults loaded;
I think ApplyFeatureGates() is just add/del features, it needn't register all AlgorithmProvider again
Which issue this PR fixes (optional, in fixes #<issue number>(, fixes #<issue_number>, ...) format, will close that issue when PR gets merged): fixes #

Special notes for your reviewer:

Release note:

@k8s-ci-robot k8s-ci-robot added do-not-merge/release-note-label-needed Indicates that a PR should not merge because it's missing one of the release note labels. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels Oct 17, 2017
@k8s-ci-robot
Copy link
Contributor

Hi @kuramal. Thanks for your PR.

I'm waiting for a kubernetes member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

I understand the commands that are listed here.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. I understand the commands that are listed here.

@k8s-ci-robot k8s-ci-robot added the needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. label Oct 17, 2017
@kuramal
Copy link
Contributor Author

kuramal commented Oct 17, 2017

@wojtek-t

@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 Oct 17, 2017
@wojtek-t wojtek-t assigned bsalamat and unassigned wojtek-t Oct 17, 2017
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.

Looks good to me. Just minor comments.

validateAlgorithmNameOrDie(providerName)
provider, ok := algorithmProviderMap[providerName]
if !ok {
return fmt.Errorf("plugin %q has not been registered", providerName)
Copy link
Member

Choose a reason for hiding this comment

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

s/%q/%v/

Copy link
Contributor Author

Choose a reason for hiding this comment

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

corrected

validateAlgorithmNameOrDie(providerName)
provider, ok := algorithmProviderMap[providerName]
if !ok {
return fmt.Errorf("plugin %q has not been registered", providerName)
Copy link
Member

Choose a reason for hiding this comment

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

s/%q/%v/

Copy link
Contributor Author

Choose a reason for hiding this comment

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

corrected

@kuramal
Copy link
Contributor Author

kuramal commented Oct 18, 2017

@bsalamat updated

@bsalamat
Copy link
Member

@k82cn Could you please take a look at this PR as well?

@k82cn
Copy link
Member

k82cn commented Oct 18, 2017

/assign

sure, I'll review it recently :).

@k82cn
Copy link
Member

k82cn commented Oct 18, 2017

@kuramal , thanks very much for your contribution :). The logic of this PR is correct, but my concern is that someone may miss ApplyFeatureGates when introduce new provider. As we only register algorithm twice when scheduler startup, so no performance impact. That'll be better to find a way for central place on provider registering.

@kuramal
Copy link
Contributor Author

kuramal commented Oct 19, 2017

@k82cn, is there any case that apply different feature for providers? In fact, I can apply all providers with range algorithmProviderMap[].

@k82cn
Copy link
Member

k82cn commented Oct 19, 2017

no for now :). If someone add a new provider in future, he may miss this part; so it's better to have a central place to add new provider.

This PR is correct; just thinking if we can do it better :).

@k82cn
Copy link
Member

k82cn commented Oct 19, 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 Oct 19, 2017
@kuramal
Copy link
Contributor Author

kuramal commented Oct 19, 2017

@k82cn, I can use algorithmProviderMap[] as a central place, but when ApplyFeatureGates runs, it will apply all providers, no matter it is registered by registerAlgorithmProvider() or not. Or add a new algorithmProviderList[] which store the providers registered by registerAlgorithmProvider().
Is that ok? or which one is better?

@kuramal
Copy link
Contributor Author

kuramal commented Oct 23, 2017

@k82cn

@k82cn
Copy link
Member

k82cn commented Oct 23, 2017

The first option is ok to me :). IMO, it's ok to have some overlap or overwrite; we just need to make sure it's "clear" with enough comments.

…Gates

Add InsertPredicateKeyToAlgorithmProviderMap() and RemovePredicateKeyFromAlgorithmProviderMap() to insert/remove fit predicate key of all algorithmProviders which in algorithmProviderMap
Add Func RemovePredicateKeyFromAlgoProvider() AND InsertPredicateKeyToAlgoProvider() which can insert/remove fit predicate key to specific algorithmProvider
@kuramal kuramal changed the title Add Func RemovePredicateKeyFromAlgoProvider AND InsertPredicateKeyToA… Optimize Repeated registration of AlgorithmProvider when ApplyFeatureGates Oct 26, 2017
@kuramal
Copy link
Contributor Author

kuramal commented Oct 26, 2017

@k82cn updated


glog.Warningf("TaintNodesByCondition is enabled, PodToleratesNodeTaints predicate is mandatory")
}

registerAlgorithmProvider(predSet, defaultPriorities())
Copy link
Member

Choose a reason for hiding this comment

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

can you also help to rollback this func?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@k82cn Hi, what does rollback this func mean? could you let me be more specific?

Copy link
Member

Choose a reason for hiding this comment

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

remove registerAlgorithmProvider definition :).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

func init() {
...
registerAlgorithmProvider(defaultPredicates(), defaultPriorities())
...
}

The func registerAlgorithmProvider is using register algorithm provider, it is called when package defaults loading.

remove registerAlgorithmProvider() ?!
@k82cn

Copy link
Member

Choose a reason for hiding this comment

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

ok.

@k82cn
Copy link
Member

k82cn commented Oct 27, 2017

LGTM overall , thanks very much :).

@k82cn
Copy link
Member

k82cn commented Oct 30, 2017

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Oct 30, 2017
@k82cn
Copy link
Member

k82cn commented Oct 30, 2017

/approve no-issue

@k8s-github-robot
Copy link

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: k82cn, kuramal

Associated issue requirement bypassed by: k82cn

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 k8s-github-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Oct 30, 2017
@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.

@k8s-github-robot k8s-github-robot merged commit 7c96feb into kubernetes:master Oct 30, 2017
@kuramal kuramal deleted the my branch October 30, 2017 05:23
@kuramal kuramal restored the my branch October 30, 2017 05:23
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. 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.

7 participants