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

Avoid full sort when selecting host with highest priority. #16647

Merged
merged 1 commit into from
Nov 16, 2015
Merged

Avoid full sort when selecting host with highest priority. #16647

merged 1 commit into from
Nov 16, 2015

Conversation

abursavich
Copy link
Contributor

I was reading through the scheduling code and figured I'd offer a little optimization when selecting the highest priority host. I wouldn't argue that this is strictly needed, but I think it's a little better and not overly complicated. There aren't added tests because the output is the same and already tested.

  • We can avoid a full sort of the list and find the top priority hosts with a single pass.
  • We can avoid generating []string garbage from the top host names.
  • We can avoid locking and generating a random number when there's one top host.
  • We can avoid modulo bias in the random number.

@k8s-bot
Copy link

k8s-bot commented Nov 1, 2015

Can one of the admins verify that this patch is reasonable to test? (reply "ok to test", or if you trust the user, reply "add to whitelist")

If this message is too spammy, please complain to ixdy.

1 similar comment
@k8s-bot
Copy link

k8s-bot commented Nov 1, 2015

Can one of the admins verify that this patch is reasonable to test? (reply "ok to test", or if you trust the user, reply "add to whitelist")

If this message is too spammy, please complain to ixdy.

@k8s-github-robot
Copy link

Labelling this PR as size/M

@k8s-github-robot k8s-github-robot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Nov 1, 2015
@smarterclayton
Copy link
Contributor

@kubernetes/goog-control-plane @kubernetes/rh-cluster-infra

@wojtek-t
Copy link
Member

wojtek-t commented Nov 1, 2015

@davidopp

@mikedanese mikedanese assigned davidopp and unassigned dchen1107 Nov 1, 2015
@davidopp
Copy link
Member

LGTM

@davidopp davidopp added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Nov 15, 2015
@k8s-github-robot
Copy link

@k8s-bot ok to test

pr builder appears to be missing, activating due to 'lgtm' label.

@k8s-bot
Copy link

k8s-bot commented Nov 15, 2015

GCE e2e build/test failed for commit c64048d.

@piosz
Copy link
Member

piosz commented Nov 16, 2015

@k8s-bot e2e test this please

@k8s-bot
Copy link

k8s-bot commented Nov 16, 2015

GCE e2e test build/test passed for commit c64048d.

@k8s-github-robot
Copy link

@k8s-bot test this [submit-queue is verifying that this PR is safe to merge]

@k8s-bot
Copy link

k8s-bot commented Nov 16, 2015

GCE e2e test build/test passed for commit c64048d.

@k8s-github-robot
Copy link

Automatic merge from submit-queue

k8s-github-robot pushed a commit that referenced this pull request Nov 16, 2015
@k8s-github-robot k8s-github-robot merged commit f8db8f1 into kubernetes:master Nov 16, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
lgtm "Looks good to me", indicates that a PR is ready to be merged. 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.