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: inefficient cache operation slows down scheduler #18255
Comments
The MetaKeyFunc is a generic method - what you're suggesting is obviously not. |
Yes. I suggest pass in a special keyfunc to nodeLister since you already know you are transforming a node struct. |
SGTM - since this is NodeLister, I agree it makes sense to use a dedicated type-specific functions there. |
So a more general fix would be to add a type switch in the existing key function, or write one in scheduler that uses a type switch. e.g., func KeyFunc(obj interface{}) (string, error) {
switch t := obj.(type) {
case *api.Node: return ObjectMetaToKey(&t.ObjectMeta)
case *api.Pod: return ObjectMetaToKey(&t.ObjectMeta)
case *api.Service: return ObjectMetaToKey(&t.ObjectMeta)
...
}
// fall through to reflection based method
} |
@lavalamp A cleaner and performant way is probably to let all relevant types (where performance is needed, like node struct) to satisfy a Key interface? |
Yes-- actually @smarterclayton just proposed such a change in a large refactoring PR he's working on. |
@smarterclayton Can you please point me to the pr? So I can avoid duplicate work. Thanks! |
It's #17922 |
I plan on making a separate PR for that shortly - we see this check show up in lots of large profiles so I want to make sure it goes away. Will update both issues once I do that. |
@smarterclayton Great. So I will wait for your update. Thanks! |
As a side node, making this change has dramatically reduced the ugliness and incomprehensibility of a bunch of nasty code paths. |
ref/ #18418 |
/cc @HardySimpson |
Opened #18473 |
Actual fix will be in #18534 |
Issue was merged |
@smarterclayton |
Instead of reflection to look up name and namespace, we use an
interface (a fast path) that allows direct field access. That makes
cache key construction require no reflection.
|
Automatic merge from submit-queue (batch tested with PRs 18423, 18255, 18526, 18539, 18509). UPSTREAM: 58720: Ensure that the runtime mounts RO volumes read-only This is a backport of kubernetes#58720 This change makes it so that containers cannot write to secret, configMap, downwardAPI and projected volumes since the runtime will now mount them read-only. This change makes things less confusing for a user since any attempt to update a secret volume will result in an error rather than a successful change followed by a revert by the kubelet when the volume next syncs. **Which issue(s) this PR fixes** N/A **Release note**: ``` Containers now mount secret, configMap, downwardAPI and projected volumes read-only. ``` Origin-commit: 6ce0af039208656c9b27d0d9a918794d9821f68c
After #18126 fixed by #18170, I run density test again.
Now the hot spot on the critical path is an inefficient cache access(https://github.com/kubernetes/kubernetes/blob/master/pkg/client/cache/store.go#L75) when listing nodes that uses reflection. Reflection causes a lot of allocations.
A simple fix would be
The simple fix improves the throughput of scheduler by 15%-20% on 1000 nodes case.
@lavalamp What do you think about this issue?
/cc @hongchaodeng @wojtek-t @gmarek @davidopp
The text was updated successfully, but these errors were encountered: