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

perf(otelstorage): optimize allocations in Hash #298

Merged
merged 3 commits into from
Jan 17, 2024
Merged

Conversation

tdakkota
Copy link
Member

@tdakkota tdakkota commented Jan 17, 2024

For #293.

                 │   old.txt   │               new.txt               │
                 │   sec/op    │   sec/op     vs base                │
_metricsBatch-32   1.257m ± 0%   1.095m ± 1%  -12.83% (p=0.000 n=15)

                 │   old.txt    │               new.txt                │
                 │     B/op     │     B/op      vs base                │
_metricsBatch-32   511.2Ki ± 0%   290.8Ki ± 0%  -43.11% (p=0.000 n=15)

                 │   old.txt   │               new.txt               │
                 │  allocs/op  │  allocs/op   vs base                │
_metricsBatch-32   7.894k ± 0%   6.280k ± 0%  -20.45% (p=0.000 n=15)

Use stack-allocated slice, if possible.

```
Hash-32   767.7n ± 1%   684.8n ± 2%  -10.80% (p=0.000 n=15)

Hash-32   384.0 ± 0%   0.0 ± 0%  -100.00% (p=0.000 n=15)

Hash-32   1.000 ± 0%   0.000 ± 0%  -100.00% (p=0.000 n=15)
```
Use `strings.Compare` instead of `cmp.Compare`.

```
Hash-32   685.3n ± 3%   571.6n ± 2%  -16.59% (p=0.000 n=15)
```
@tdakkota tdakkota requested a review from ernado as a code owner January 17, 2024 10:32
@ernado ernado merged commit 6e2ede0 into main Jan 17, 2024
15 checks passed
@ernado ernado deleted the perf/improve-hash branch January 17, 2024 11:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants