Skip to content

Conversation

@constanca-m
Copy link
Contributor

Description

Improves performance on hashing. See:

$ benchstat old.txt new.txt
goos: linux
goarch: amd64
pkg: github.com/open-telemetry/opentelemetry-collector-contrib/internal/coreinternal/attraction
cpu: 11th Gen Intel(R) Core(TM) i7-11800H @ 2.30GHz
                                │   old.txt    │               new.txt                │
                                │    sec/op    │    sec/op     vs base                │
AttrProc_HashRegex/N20_R10-16     1.802µ ± 15%   1.490µ ± 29%  -17.31% (p=0.029 n=10)
AttrProc_HashRegex/N20_R50-16     5.487µ ± 29%   4.662µ ±  5%  -15.02% (p=0.000 n=10)
AttrProc_HashRegex/N2000_R10-16   162.9µ ± 10%   153.0µ ±  6%   -6.12% (p=0.011 n=10)
AttrProc_HashRegex/N2000_R50-16   537.3µ ±  5%   429.1µ ± 79%  -20.14% (p=0.029 n=10)
geomean                           30.50µ         25.99µ        -14.81%

                                │   old.txt    │               new.txt                │
                                │     B/op     │     B/op      vs base                │
AttrProc_HashRegex/N20_R10-16       480.0 ± 0%     288.0 ± 0%  -40.00% (p=0.000 n=10)
AttrProc_HashRegex/N20_R50-16     2.345Ki ± 0%   1.406Ki ± 0%  -40.02% (p=0.000 n=10)
AttrProc_HashRegex/N2000_R10-16   46.91Ki ± 0%   28.14Ki ± 0%  -40.00% (p=0.000 n=10)
AttrProc_HashRegex/N2000_R50-16   234.5Ki ± 0%   140.7Ki ± 0%  -40.00% (p=0.000 n=10)
geomean                           10.49Ki        6.291Ki       -40.01%

                                │   old.txt   │               new.txt               │
                                │  allocs/op  │  allocs/op   vs base                │
AttrProc_HashRegex/N20_R10-16     10.000 ± 0%    6.000 ± 0%  -40.00% (p=0.000 n=10)
AttrProc_HashRegex/N20_R50-16      50.00 ± 0%    30.00 ± 0%  -40.00% (p=0.000 n=10)
AttrProc_HashRegex/N2000_R10-16   1000.0 ± 0%    600.0 ± 0%  -40.00% (p=0.000 n=10)
AttrProc_HashRegex/N2000_R50-16   4.999k ± 0%   2.999k ± 0%  -40.01% (p=0.000 n=10)
geomean                            223.6         134.2       -40.00%

Testing

I added a unit test to make sure there were no breaking changes.

@constanca-m constanca-m requested a review from a team as a code owner January 2, 2026 10:38
@constanca-m constanca-m requested a review from mwear January 2, 2026 10:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants