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

Don't use CachingObject if the number of watchers is small #84043

Merged

Conversation

wojtek-t
Copy link
Member

@wojtek-t wojtek-t commented Oct 17, 2019

The gain from using CachingObject is huge when there is huge number of watchers (e.g. 5000 kube-proxies, watching all Endpoints objects).
However, if the number of watchers is very small (say 1), creation of the CachingObject itself is unnecessary cost (it results in a bunch of memory allocations):

  • if there are 0 watchers - it is complete waste
  • if there is 1 watcher - gain from caching is 0, so we unnecessary copy stuff to create CachingObject
  • if there are 2 watchers - additional copy is roughly amortized by saved serialization
    So only with 3+ watchers the gain starts to be visible.

This PR is changing the logic to use CachingObject only in this case.

The gain in large clusters isn't huge - seem to be ~1-2%, but probably still worth given how small this change is.

@wojtek-t wojtek-t self-assigned this Oct 17, 2019
@k8s-ci-robot
Copy link
Contributor

@wojtek-t: Adding the "do-not-merge/release-note-label-needed" label because no release-note block was detected, please follow our release note process to remove it.

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.

@k8s-ci-robot k8s-ci-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. do-not-merge/release-note-label-needed Indicates that a PR should not merge because it's missing one of the release note labels. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. needs-kind Indicates a PR lacks a `kind/foo` label and requires one. needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. needs-priority Indicates a PR lacks a `priority/foo` label and requires one. labels Oct 17, 2019
@wojtek-t wojtek-t changed the title Don't use CachingObject if the number of watchers is small [WIP] Don't use CachingObject if the number of watchers is small Oct 17, 2019
@k8s-ci-robot k8s-ci-robot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Oct 17, 2019
@k8s-ci-robot k8s-ci-robot added approved Indicates a PR has been approved by an approver from all required OWNERS files. area/apiserver sig/api-machinery Categorizes an issue or PR as relevant to SIG API Machinery. and removed needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. labels Oct 17, 2019
@wojtek-t wojtek-t added release-note-none Denotes a PR that doesn't merit a release note. kind/feature Categorizes issue or PR as related to a new feature. priority/important-longterm Important over the long term, but may not be staffed and/or may need multiple releases to complete. and removed do-not-merge/release-note-label-needed Indicates that a PR should not merge because it's missing one of the release note labels. needs-kind Indicates a PR lacks a `kind/foo` label and requires one. needs-priority Indicates a PR lacks a `priority/foo` label and requires one. labels Oct 17, 2019
@wojtek-t wojtek-t changed the title [WIP] Don't use CachingObject if the number of watchers is small Don't use CachingObject if the number of watchers is small Oct 17, 2019
@k8s-ci-robot k8s-ci-robot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Oct 17, 2019
@k8s-ci-robot
Copy link
Contributor

@wojtek-t: Adding the "do-not-merge/release-note-label-needed" label because no release-note block was detected, please follow our release note process to remove it.

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.

@k8s-ci-robot k8s-ci-robot added do-not-merge/release-note-label-needed Indicates that a PR should not merge because it's missing one of the release note labels. and removed release-note-none Denotes a PR that doesn't merit a release note. labels Oct 17, 2019
@wojtek-t wojtek-t assigned liggitt and unassigned wojtek-t Oct 17, 2019
@wojtek-t
Copy link
Member Author

/retest

}

func TestCachingObjects(t *testing.T) {
testCachingObjects(t, 1)
Copy link
Member

Choose a reason for hiding this comment

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

nit, call these inside subtests so if they fail we know which one it failed on

Copy link
Member Author

Choose a reason for hiding this comment

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

done (hopefully that's what you meant)

@liggitt
Copy link
Member

liggitt commented Oct 17, 2019

one nit, lgtm otherwise. would be good to get updated numbers on the performance impact of this change before merge

@wojtek-t
Copy link
Member Author

one nit, lgtm otherwise. would be good to get updated numbers on the performance impact of this change before merge

Update the PR description:
The gain in large clusters isn't huge - seem to be ~1-2%, but probably still worth given how small this change is.

@liggitt - PTAL

@liggitt
Copy link
Member

liggitt commented Oct 17, 2019

The gain in large clusters isn't huge - seem to be ~1-2%, but probably still worth given how small this change is.

that's fine, I mostly wanted numbers to prove this was actually an improvement and there were no unexpected downsides

/lgtm
/approve

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Oct 17, 2019
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: liggitt, wojtek-t

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 /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@wojtek-t wojtek-t added release-note-none Denotes a PR that doesn't merit a release note. and removed do-not-merge/release-note-label-needed Indicates that a PR should not merge because it's missing one of the release note labels. labels Oct 17, 2019
@fejta-bot
Copy link

/retest
This bot automatically retries jobs that failed/flaked on approved PRs (send feedback to fejta).

Review the full test history for this PR.

Silence the bot with an /lgtm cancel or /hold comment for consistent failures.

@fedebongio
Copy link
Contributor

/cc @apelisse @jennybuckley

@fejta-bot
Copy link

/retest
This bot automatically retries jobs that failed/flaked on approved PRs (send feedback to fejta).

Review the full test history for this PR.

Silence the bot with an /lgtm cancel or /hold comment for consistent failures.

@k8s-ci-robot k8s-ci-robot merged commit f9acca8 into kubernetes:master Oct 18, 2019
@k8s-ci-robot k8s-ci-robot added this to the v1.17 milestone Oct 18, 2019
@wojtek-t wojtek-t deleted the tweak_serialize_object_once branch December 18, 2019 08:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. area/apiserver cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/feature Categorizes issue or PR as related to a new feature. lgtm "Looks good to me", indicates that a PR is ready to be merged. priority/important-longterm Important over the long term, but may not be staffed and/or may need multiple releases to complete. release-note-none Denotes a PR that doesn't merit a release note. sig/api-machinery Categorizes an issue or PR as relevant to SIG API Machinery. 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