-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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 deep copying objects twice in the CacheReader List method #621
Comments
controller-runtime/pkg/cache/internal/cache_reader.go Lines 122 to 136 in 801e12a
We deepcopy twice currently. One in the for loop, the other one in Also be aware this potential issue: https://github.com/kubernetes-sigs/controller-runtime/pull/389/files#r274350644 cc: @DirectXMan12 |
I saw the comments in #389 too. When I ran the tests with the proposed change, there were no race detector warnings so I don't think that will be an issue. |
Cool! Feel free to open a PR. |
Improve Dockerfile template such that copying vendor dir is cached.
In the
List
method of theCacheReader
, the list of objects retrieved from the index is added to theruntimeObjs
array by deep copying each object. This array is then passed to theobjectutil.FilterWithLabels
which again creates a deep copy of the objects that match the label selector.It would be more efficient to inline the label filtering logic as follows to avoid this extra work and reduce heap usage of controllers that work with large number of items.
Are there any downsides to patching the method as suggested? If not, I'll be happy to raise a PR.
The text was updated successfully, but these errors were encountered: