Skip to content

attribute: use typed slice access in hashKV for slice types#8201

Closed
alliasgher wants to merge 2 commits intoopen-telemetry:mainfrom
alliasgher:perf-hash-slice-types
Closed

attribute: use typed slice access in hashKV for slice types#8201
alliasgher wants to merge 2 commits intoopen-telemetry:mainfrom
alliasgher:perf-hash-slice-types

Conversation

@alliasgher
Copy link
Copy Markdown
Contributor

Fixes #8200. Replace reflect.ValueOf + reflection iteration with direct typed slice access (asBoolSlice, etc.) for the four slice types in hashKV, matching the same improvement applied to the new SLICE type in #8166.

Replace reflect.ValueOf + reflection-based iteration with direct typed
slice access (asBoolSlice, asInt64Slice, asFloat64Slice, asStringSlice)
for BOOLSLICE, INT64SLICE, FLOAT64SLICE, and STRINGSLICE in hashKV.

This avoids the per-element reflection overhead — the same improvement
applied to the SLICE type in open-telemetry#8166.

Fixes open-telemetry#8200

Signed-off-by: alliasgher <alliasgher123@gmail.com>
@dashpole
Copy link
Copy Markdown
Contributor

Can you post the benchmark difference?

@dashpole dashpole added the Skip Changelog PRs that do not require a CHANGELOG.md entry label Apr 14, 2026
@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 14, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 82.3%. Comparing base (8899c97) to head (176fb93).

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##            main   #8201     +/-   ##
=======================================
- Coverage   82.3%   82.3%   -0.1%     
=======================================
  Files        310     310             
  Lines      24263   24259      -4     
=======================================
- Hits       19983   19979      -4     
  Misses      3903    3903             
  Partials     377     377             
Files with missing lines Coverage Δ
attribute/hash.go 91.3% <100.0%> (-0.7%) ⬇️

... and 2 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Copy Markdown
Contributor

@MrAlias MrAlias left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This almost certainly degrades the performance as these are now allocating for each call.

Please provide benchmarks to motivate this change.

Copy link
Copy Markdown
Member

@pellared pellared left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@alliasgher
Copy link
Copy Markdown
Contributor Author

alliasgher commented Apr 14, 2026

Closing , you're right that asBoolSlice() etc. allocate new slices which would degrade performance rather than improve it. I misread the issue. Thanks for the review.

@alliasgher alliasgher closed this Apr 14, 2026
@alliasgher alliasgher reopened this Apr 14, 2026
@alliasgher alliasgher closed this Apr 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Skip Changelog PRs that do not require a CHANGELOG.md entry

Projects

None yet

Development

Successfully merging this pull request may close these issues.

attribute: Improve performance of hashValue for BOOLSLICE, INT64SLICE, FLOAT64SLICE, STRINGSLICE

4 participants