-
Notifications
You must be signed in to change notification settings - Fork 38.7k
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
Remove repeated random string generations in scheduler volume predicate #53989
Remove repeated random string generations in scheduler volume predicate #53989
Conversation
I'll try running kubemark-5000 with this change and see the outcome. |
} | ||
|
||
return c.predicate | ||
} | ||
|
||
func (c *MaxPDVolumeCountChecker) getNextVolumeIDPrefix() string { | ||
c.lock.Lock() | ||
defer c.lock.Unlock() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can be lock-free with atomic.AddInt64(&c.volumeIDPrefixCounter, 1)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Smooth! Changed it.
874f578
to
82b2716
Compare
@liggitt Fixed stuff. PTAL. |
change LGTM, will let sig-storage weigh in |
cc @kubernetes/sig-storage-pr-reviews |
// predicate() call so a deleted PVC used by two pods is counted as one volume | ||
// and not as two. Also, appending a counter to a const string removes | ||
// the need to create a random string each time (which is expensive). | ||
randomPrefix := c.getNextVolumeIDPrefix() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure if a random prefix is needed for each predicate call. It may be good enough to just generate a random prefix once during initialization. All the structures used to count volumes in this predicate are local and shouldn't conflict if the predicate is running in parallel.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's precisely what I'm doing in this PR - a random prefix initialized once and then just appending it to a counter. Do you mean sth else?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I mean, I don't think you even need a counter. Just a random prefix initialized in the beginning.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In that case do we even need the initialized string to be random? For e.g why not just set it to some hard-coded value like 'foobar'?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
don't you risk conflicting with actual object names?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, we just want a prefix that won't conflict with actual object names. So we could generate some random prefix, or have some hardcoded value that we are sure nobody would ever use. I don't think it needs to be generated every time we run the predicate though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed it - PTAL.
82b2716
to
07e3a09
Compare
@shyamjvs: Adding do-not-merge/release-note-label-needed because the release note process has not been followed. One of the following labels is required "release-note", "release-note-action-required", or "release-note-none". 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. |
@kubernetes/test-infra-maintainers Seems like there's a bug with the |
maxVolumes: maxVolumes, | ||
pvInfo: pvInfo, | ||
pvcInfo: pvcInfo, | ||
randomVolumeIDPrefix: rand.String(8), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can this be 32 like originally? That way we reduce the chance of conflicting with the user's object names.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
07e3a09
to
5a85f9d
Compare
@shyamjvs The release note process is WAI.
/release-note-none |
@cjwagner Sounds good. But any idea why the label is getting removed on renaming the PR title? |
/lgtm |
@shyamjvs Yeah, the PR 'edit' event is used to detect when the PR body text (including the release-note block) is changed, but it is also triggered by title changes. The Prow plugin that handled the event saw the |
/approve |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: bsalamat, msau42, shyamjvs Associated issue: 53327 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 |
/test pull-kubernetes-e2e-gce |
Automatic merge from submit-queue. If you want to cherry-pick this change to another branch, please follow the instructions here. |
Automatic merge from submit-queue. UPSTREAM: 53989: Remove repeated random string generations in scheduler volume predicate @sjenning @smarterclayton Though the upstream PR 53793 has been backported to kube 1.7 branch (53884). I am not sure if we have a plan for another origin rebase to latest kube 1.7, and if we would want to wait for that. So this backports following 3 PRs: kubernetes/kubernetes#53793 kubernetes/kubernetes#53720 (partial) kubernetes/kubernetes#53989
Ref #53327
@wojtek-t @liggitt @jsafrane - Does this look ok to you?