Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

optimize metadata.Equal #306

Closed
smira opened this issue Aug 4, 2023 · 0 comments · Fixed by #335
Closed

optimize metadata.Equal #306

smira opened this issue Aug 4, 2023 · 0 comments · Fixed by #335
Assignees

Comments

@smira
Copy link
Member

smira commented Aug 4, 2023

the sort.Strings() and a copy of finalizers - can we do a better version? should we optimize for a special case of 1,2 items?

@smira smira self-assigned this Sep 22, 2023
smira added a commit to smira/os-runtime that referenced this issue Sep 22, 2023
It might be pretty common to have 1-2 finalizers, so we can do a special
case for it.

```
name                old time/op    new time/op    delta
MetadataEqual/0-32    11.9ns ± 4%    11.8ns ± 4%      ~     (p=0.971 n=4+4)
MetadataEqual/1-32     219ns ±19%      14ns ± 2%   -93.49%  (p=0.029 n=4+4)
MetadataEqual/2-32     273ns ± 7%      21ns ± 1%   -92.36%  (p=0.029 n=4+4)
MetadataEqual/3-32     328ns ± 7%     310ns ± 7%      ~     (p=0.200 n=4+4)

name                old alloc/op   new alloc/op   delta
MetadataEqual/0-32     0.00B          0.00B           ~     (all equal)
MetadataEqual/1-32     80.0B ± 0%      0.0B       -100.00%  (p=0.029 n=4+4)
MetadataEqual/2-32      112B ± 0%        0B       -100.00%  (p=0.029 n=4+4)
MetadataEqual/3-32      144B ± 0%      144B ± 0%      ~     (all equal)

name                old allocs/op  new allocs/op  delta
MetadataEqual/0-32      0.00           0.00           ~     (all equal)
MetadataEqual/1-32      4.00 ± 0%      0.00       -100.00%  (p=0.029 n=4+4)
MetadataEqual/2-32      4.00 ± 0%      0.00       -100.00%  (p=0.029 n=4+4)
MetadataEqual/3-32      4.00 ± 0%      4.00 ± 0%      ~     (all equal)
```

Fixes cosi-project#306

Signed-off-by: Andrey Smirnov <andrey.smirnov@siderolabs.com>
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant