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

⚠️ Change client.Patch to take client.Object for performance #1395

Merged
merged 2 commits into from
Mar 3, 2021

Commits on Mar 3, 2021

  1. ✨ Add a fast path for client.Object in merge-patch

    Most uses of merge-patch will be for built-in types or kubebuilder-
    generated custom resources which have accessors for ResourceVersion.
    Using these with DeepCopyObject() is simple and fast.
    
    name                            old time/op    new time/op    delta
    MergeFrom/NoOptions               91.6µs ± 4%   107.3µs ±26%     ~     (p=0.417 n=7+10)
    MergeFrom/NoOptions-2              112µs ±18%      88µs ±11%  -21.15%  (p=0.000 n=10+9)
    MergeFrom/WithOptimisticLock       163µs ± 3%     121µs ± 3%  -25.66%  (p=0.000 n=10+8)
    MergeFrom/WithOptimisticLock-2     137µs ± 4%     101µs ± 4%  -26.28%  (p=0.000 n=10+10)
    
    name                            old alloc/op   new alloc/op   delta
    MergeFrom/NoOptions               20.3kB ± 0%    20.3kB ± 0%     ~     (all equal)
    MergeFrom/NoOptions-2             20.3kB ± 0%    20.3kB ± 0%     ~     (all equal)
    MergeFrom/WithOptimisticLock      34.1kB ± 0%    26.7kB ± 0%  -21.89%  (p=0.000 n=10+10)
    MergeFrom/WithOptimisticLock-2    34.2kB ± 0%    26.7kB ± 0%  -21.89%  (p=0.000 n=10+8)
    
    name                            old allocs/op  new allocs/op  delta
    MergeFrom/NoOptions                  359 ± 0%       359 ± 0%     ~     (all equal)
    MergeFrom/NoOptions-2                359 ± 0%       359 ± 0%     ~     (all equal)
    MergeFrom/WithOptimisticLock         579 ± 0%       390 ± 0%  -32.64%  (p=0.000 n=10+10)
    MergeFrom/WithOptimisticLock-2       579 ± 0%       390 ± 0%  -32.64%  (p=0.000 n=10+10)
    cbandy committed Mar 3, 2021
    Configuration menu
    Copy the full SHA
    442bac3 View commit details
    Browse the repository at this point in the history
  2. ⚠ Change client.Patch to take client.Object

    This allows us to use metav1 accessors to speed up the merge-patch
    implementation.
    cbandy committed Mar 3, 2021
    Configuration menu
    Copy the full SHA
    aef159a View commit details
    Browse the repository at this point in the history