kubernetes-sigs / structured-merge-diff

Test cases and implementation for "server-side apply"
Apache License 2.0
97 stars 58 forks source link

Use EqualsUsing recursively #239

Closed apelisse closed 1 year ago

apelisse commented 1 year ago

Currently, EqualsUsing recurses with Equals, which loses the allocator that you're using, defeating the whole point. Address that in all places I could find. I don't think that code-path is specifically used anywhere so this has no impact on benchmarks.

apelisse commented 1 year ago

/assign @jpbetz

apelisse commented 1 year ago

I've added a benchmark for value.EqualsUsing which yields the following result before/after the change:

name                                              old time/op    new time/op    delta
Equals/pod.yaml/Equals-8                            19.7µs ± 5%    19.3µs ± 2%     ~     (p=0.222 n=5+5)
Equals/pod.yaml/EqualsUsingFreelist-8               19.4µs ± 4%    16.5µs ± 3%  -14.95%  (p=0.008 n=5+5)
Equals/endpoints.yaml/Equals-8                       982µs ± 3%     977µs ± 5%     ~     (p=0.548 n=5+5)
Equals/endpoints.yaml/EqualsUsingFreelist-8          970µs ± 5%     872µs ± 6%  -10.02%  (p=0.008 n=5+5)
Equals/list.yaml/Equals-8                           4.02µs ± 1%    4.20µs ± 8%   +4.37%  (p=0.008 n=5+5)
Equals/list.yaml/EqualsUsingFreelist-8              4.03µs ± 4%    3.42µs ± 4%  -15.15%  (p=0.008 n=5+5)
Equals/node.yaml/Equals-8                           42.0µs ± 3%    40.2µs ± 2%   -4.33%  (p=0.016 n=5+5)
Equals/node.yaml/EqualsUsingFreelist-8              40.3µs ± 2%    34.4µs ± 5%  -14.55%  (p=0.008 n=5+5)
Equals/prometheus-crd.yaml/Equals-8                  340µs ± 2%     347µs ± 2%     ~     (p=0.151 n=5+5)
Equals/prometheus-crd.yaml/EqualsUsingFreelist-8     352µs ± 3%     301µs ± 9%  -14.57%  (p=0.008 n=5+5)

name                                              old alloc/op   new alloc/op   delta
Equals/pod.yaml/Equals-8                            3.59kB ± 0%    4.36kB ± 0%  +21.38%  (p=0.008 n=5+5)
Equals/pod.yaml/EqualsUsingFreelist-8               3.58kB ± 0%    2.18kB ± 0%  -38.93%  (p=0.008 n=5+5)
Equals/endpoints.yaml/Equals-8                       113kB ± 0%     161kB ± 0%  +42.63%  (p=0.029 n=4+4)
Equals/endpoints.yaml/EqualsUsingFreelist-8          113kB ± 0%      96kB ± 0%  -14.53%  (p=0.008 n=5+5)
Equals/list.yaml/Equals-8                           1.02kB ± 0%    1.28kB ± 0%  +25.98%  (p=0.008 n=5+5)
Equals/list.yaml/EqualsUsingFreelist-8              1.00kB ± 0%    0.67kB ± 0%  -32.80%  (p=0.008 n=5+5)
Equals/node.yaml/Equals-8                           9.25kB ± 0%   10.64kB ± 0%  +15.05%  (p=0.008 n=5+5)
Equals/node.yaml/EqualsUsingFreelist-8              9.23kB ± 0%    4.94kB ± 0%  -46.45%  (p=0.008 n=5+5)
Equals/prometheus-crd.yaml/Equals-8                 60.7kB ± 0%    79.9kB ± 0%  +31.69%  (p=0.016 n=4+5)
Equals/prometheus-crd.yaml/EqualsUsingFreelist-8    60.6kB ± 0%    44.1kB ± 0%     ~     (p=0.079 n=4+5)

name                                              old allocs/op  new allocs/op  delta
Equals/pod.yaml/Equals-8                               159 ± 0%       159 ± 0%     ~     (all equal)
Equals/pod.yaml/EqualsUsingFreelist-8                  158 ± 0%        59 ± 0%  -62.66%  (p=0.008 n=5+5)
Equals/endpoints.yaml/Equals-8                       6.04k ± 0%     6.04k ± 0%     ~     (all equal)
Equals/endpoints.yaml/EqualsUsingFreelist-8          6.04k ± 0%     2.01k ± 0%  -66.63%  (p=0.008 n=5+5)
Equals/list.yaml/Equals-8                             47.0 ± 0%      47.0 ± 0%     ~     (all equal)
Equals/list.yaml/EqualsUsingFreelist-8                46.0 ± 0%      17.0 ± 0%  -63.04%  (p=0.008 n=5+5)
Equals/node.yaml/Equals-8                              384 ± 0%       384 ± 0%     ~     (all equal)
Equals/node.yaml/EqualsUsingFreelist-8                 383 ± 0%       148 ± 0%  -61.36%  (p=0.008 n=5+5)
Equals/prometheus-crd.yaml/Equals-8                  2.96k ± 0%     2.96k ± 0%     ~     (all equal)
Equals/prometheus-crd.yaml/EqualsUsingFreelist-8     2.96k ± 0%     1.04k ± 0%  -64.87%  (p=0.008 n=5+5)
k8s-ci-robot commented 1 year ago

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: alexzielenski, apelisse

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: - ~~[OWNERS](https://github.com/kubernetes-sigs/structured-merge-diff/blob/master/OWNERS)~~ [apelisse] Approvers can indicate their approval by writing `/approve` in a comment Approvers can cancel approval by writing `/approve cancel` in a comment