Skip to content

✨ Reduce memory usage of default webhooks#3463

Merged
k8s-ci-robot merged 1 commit intokubernetes-sigs:mainfrom
sbueringer:pr-reduce-memory-usage-default
Mar 5, 2026
Merged

✨ Reduce memory usage of default webhooks#3463
k8s-ci-robot merged 1 commit intokubernetes-sigs:mainfrom
sbueringer:pr-reduce-memory-usage-default

Conversation

@sbueringer
Copy link
Member

@sbueringer sbueringer commented Feb 28, 2026

Before this PR we were always going through the JSON patch calculation which is pretty expensive.
This PR optimizes this by short-circuting if the objects are equal.

goos: darwin
goarch: arm64
pkg: sigs.k8s.io/controller-runtime/pkg/webhook/admission/bench
cpu: Apple M2 Pro
                          │   old.txt   │              new.txt               │
                          │   sec/op    │   sec/op     vs base               │
Defaulter/noop-12           95.52µ ± 7%   43.50µ ± 2%  -54.46% (p=0.002 n=6)
Defaulter/with_changes-12   89.98µ ± 2%   96.58µ ± 6%   +7.33% (p=0.002 n=6)
geomean                     92.71µ        64.82µ       -30.09%

                          │   old.txt    │               new.txt               │
                          │     B/op     │     B/op      vs base               │
Defaulter/noop-12           52.66Ki ± 0%   22.19Ki ± 0%  -57.86% (p=0.002 n=6)
Defaulter/with_changes-12   52.26Ki ± 0%   55.00Ki ± 0%   +5.25% (p=0.002 n=6)
geomean                     52.46Ki        34.94Ki       -33.40%

                          │  old.txt   │              new.txt              │
                          │ allocs/op  │ allocs/op   vs base               │
Defaulter/noop-12           950.0 ± 0%   217.0 ± 0%  -77.16% (p=0.002 n=6)
Defaulter/with_changes-12   950.0 ± 0%   982.0 ± 0%   +3.37% (p=0.002 n=6)
geomean                     950.0        461.6       -51.41%

@k8s-ci-robot k8s-ci-robot added approved Indicates a PR has been approved by an approver from all required OWNERS files. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels Feb 28, 2026
@sbueringer sbueringer force-pushed the pr-reduce-memory-usage-default branch from 64da3d7 to fdb1995 Compare February 28, 2026 11:30
@sbueringer
Copy link
Member Author

/cherry-pick release-0.23

@k8s-infra-cherrypick-robot

@sbueringer: once the present PR merges, I will cherry-pick it on top of release-0.23 in a new PR and assign it to you.

Details

In response to this:

/cherry-pick release-0.23

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-sigs/prow repository.

@sbueringer
Copy link
Member Author

/assign @alvaroaleman

@sbueringer sbueringer force-pushed the pr-reduce-memory-usage-default branch from 46661af to dd6334d Compare March 5, 2026 08:12
Copy link
Member

@alvaroaleman alvaroaleman left a comment

Choose a reason for hiding this comment

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

thanks!

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

LGTM label has been added.

DetailsGit tree hash: 4a51e2c233e415ddfa8c08147eaa7ba7c03b7696

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: alvaroaleman, sbueringer

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:
  • OWNERS [alvaroaleman,sbueringer]

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot merged commit b172b5b into kubernetes-sigs:main Mar 5, 2026
9 checks passed
@k8s-infra-cherrypick-robot

@sbueringer: new pull request created: #3467

Details

In response to this:

/cherry-pick release-0.23

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-sigs/prow repository.

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. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. 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.

4 participants