-
Notifications
You must be signed in to change notification settings - Fork 669
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 appending list multiple times in RemoveDuplicates #336
avoid appending list multiple times in RemoveDuplicates #336
Conversation
Hi @lixiang233. Thanks for your PR. I'm waiting for a kubernetes-sigs member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. 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. |
/kind bug |
/kind cleanup |
duplicatePods = append(duplicatePods, pod) | ||
break | ||
} | ||
} | ||
if !matched { |
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.
It's not a bug. Even though the list of keys is duplicated, it will never get read since if reflect.DeepEqual(keys, podContainerKeys) {
has break
keyword so the duplicated lists are never checked against.
The code change avoids duplication. Which will have almost zero impact on the performance unless the list of pods is quite large and there's many duplicates. I will leave this for @damemi to decide.
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, this change improves the performance obviously only in some extreme situations which may never happen in real world.
I think the original design was: append podContainerKeys
to the list only one time if there's no same keys in it, but the implementation has defect that will cause this operation happens multiple times, so I treat this as a bug.
/kind bug cancel |
@ingvagabund: The label(s) 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. |
/kind cancel bug |
@ingvagabund: The label(s) 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. |
/remove-kind bug |
/assign @damemi |
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.
This looks pretty good to me, good catch on this @lixiang233 thanks!
/ok-to-test
/approve
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: damemi, lixiang233 The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
/lgtm |
…ed_append_RemoveDuplicatePods avoid appending list multiple times in RemoveDuplicates
Currently, appending
podContainerKeys
toduplicateKeysMap[podContainerKeys[0]]
is inside the for loop, so it may append same keys multiple times.