Skip to content
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

prepare selector compute #39597

Closed
wants to merge 6 commits into from
Closed

prepare selector compute #39597

wants to merge 6 commits into from

Conversation

zouyee
Copy link
Member

@zouyee zouyee commented Jun 24, 2022

Signed-off-by: zounengren zouyee1989@gmail.com

Please provide a description of this PR:
ServiceSelectorCache is a cache of service selectors to avoid high CPU consumption caused by frequent calls to AsSelectorPreValidated

Signed-off-by: zounengren <zouyee1989@gmail.com>
@zouyee zouyee requested a review from a team as a code owner June 24, 2022 02:56
@istio-policy-bot
Copy link

😊 Welcome @zouyee! This is either your first contribution to the Istio istio repo, or it's been
awhile since you've been here.

You can learn more about the Istio working groups, code of conduct, and contributing guidelines
by referring to Contributing to Istio.

Thanks for contributing!

Courtesy of your friendly welcome wagon.

@istio-testing istio-testing added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Jun 24, 2022
Copy link
Member

@howardjohn howardjohn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

instead of catching the selector would it be simpler to just re-implement the selector using the map directly? It should be fairly simple and avoid the cost.

A bit worried about complexity here.

@zouyee
Copy link
Member Author

zouyee commented Jun 28, 2022

instead of catching the selector would it be simpler to just re-implement the selector using the map directly? It should be fairly simple and avoid the cost.

A bit worried about complexity here.

This method has been well practiced in the endpont controller of k8s.

Signed-off-by: zounengren <zouyee1989@gmail.com>
@howardjohn
Copy link
Member

This method has been well practiced in the endpont controller of k8s.

I don't think that is a convincing argument to do this on its own. Is there a technical reason this complexity is justified compared to just using the map directly?

@hzxuzhonghu
Copy link
Member

Not sure have you tested the performance? Which function call is CPU costing?

Copy link
Member

@hzxuzhonghu hzxuzhonghu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/hold

// ServiceSelectorCache is a cache of service selectors to avoid high CPU consumption caused by frequent calls to AsSelectorPreValidated (see #73527)
type ServiceSelectorCache struct {
lock sync.RWMutex
cache map[string]labels.Selector
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is heavily increasing memory cost

Signed-off-by: zounengren <zouyee1989@gmail.com>
@hzxuzhonghu hzxuzhonghu added the do-not-merge/hold Block automatic merging of a PR. label Jun 29, 2022
@zouyee
Copy link
Member Author

zouyee commented Jun 29, 2022

original getPodServices:

BenchmarkGetPodServices-8   	    2607	    385935 ns/op	  161913 B/op	    4023 allocs/op

current GetPodServiceMemberships which use ServiceSelectorCache

BenchmarkGetPodServiceMemberships-8   	    4287	    268554 ns/op	   49981 B/op	    1023 allocs/op

more than 50% performance improvement

@hzxuzhonghu
Copy link
Member

You have to weigh off cpu and memory. It is not justice to say only CPU

@howardjohn
Copy link
Member

Please also compare it to just using the map directly.

Signed-off-by: zounengren <zouyee1989@gmail.com>
@istio-testing
Copy link
Collaborator

istio-testing commented Jul 8, 2022

@zouyee: The following test failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
release-notes_istio c7b450f link true /test release-notes_istio

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. I understand the commands that are listed here.

@istio-policy-bot istio-policy-bot added the lifecycle/stale Indicates a PR or issue hasn't been manipulated by an Istio team member for a while label Jul 30, 2022
@istio-policy-bot
Copy link

🚧 This issue or pull request has been closed due to not having had activity from an Istio team member since 2022-06-29. If you feel this issue or pull request deserves attention, please reopen the issue. Please see this wiki page for more information. Thank you for your contributions.

Created by the issue and PR lifecycle manager.

@istio-policy-bot istio-policy-bot added the lifecycle/automatically-closed Indicates a PR or issue that has been closed automatically. label Aug 14, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
do-not-merge/hold Block automatic merging of a PR. lifecycle/automatically-closed Indicates a PR or issue that has been closed automatically. lifecycle/stale Indicates a PR or issue hasn't been manipulated by an Istio team member for a while size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants