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 KObj and KObjs #106945
Comments
/triage accepted |
See also kubernetes/klog#300 |
/unassign Thanks for your help, please also look at KObjs. |
@pohly: GitHub didn't allow me to assign the following users: dharmjit. Note that only kubernetes members, repo collaborators and people who have commented on this issue/PR can be assigned. Additionally, issues/PRs can only have 10 assignees at the same time. In response to this:
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. |
For KObjs, we need benchmark variants that iterate over slices of different lengths (1, 10, 100, ....). |
Moving the code is no longer planned. If we find that the current KObjs has severe performance drawbacks, we need to consider what we can do about this in klog itself. |
Thanks @pohly , I will take a look. /assign |
Sorry I got late on this. Below are the benchmarks for the proxy approach.
Below are the benchmarks with different slice lengths.
|
It sounds like you kept KObjs mostly unchanged and just changed the return value from It's interesting that this already shows an improvement. Where does that come from? What I had in mind was different: if we change KObjs so that it just stores its parameters and analyses it only when needed, then we should see a huge performance improvement for the common case of calling a logging function without actually logging anything. Let me write that down as code, this might be faster than English prose. |
When you post such a PR, don't bother introducing a second version of some function. Just pretend that breaking the klog API is okay and modify the existing functions. |
For example, here's what I had in mind: kubernetes/klog#322 |
That is correct and it uses
Not sure but I suspect it could be from returning the interface type( |
I've taken your commit and split it up for a before/after comparison: kubernetes/klog@main...pohly:kobjs-benchmark Because ObjectRef changes, some additional tests had to be removed. I can confirm that performance improves, but an API break for KObj doesn't seem worthwhile (IMHO). |
Hi @pohly, Got caught up in the work so couldn't spend time on this. Is there anything else to look into for this issue? |
I think we are done. /close |
@pohly: Closing this issue. In response to this:
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. |
What would you like to be added?
Some small
KObj
performance improvement is possible by making it return a simple struct that converts the actual object only on demand - see kubernetes/klog#261For
KObjs
, two optimizations are possible:The benefit there might be even higher. I haven't measured it, but I am concerned that the current implementation:
https://github.com/kubernetes/klog/blob/7fa0f3b6c7f8269e5b2f296b038d3bf1532e9146/klog.go#L1716-L1731
is slower than the code that it could replace, for example:
kubernetes/pkg/controller/replicaset/replica_set.go
Lines 222 to 228 in cc6f125
We cannot do that in klog (v2 API is frozen, having differently named functions would be confusing) but we can and should investigate this when moving the code (see kubernetes/enhancements#3078).
/sig instrumentation
/wg structured-logging
/assign
Why is this needed?
Better performance. Whether it is worthwhile needs to be measured.
The text was updated successfully, but these errors were encountered: