Skip to content

Conversation

dmitryax
Copy link
Member

@dmitryax dmitryax commented Jun 29, 2025

Trying consolidating the CopyTo logic for slices as suggested in #13267 (comment)

@bogdandrutu looks like the compiler is not that smart and we cannot use the append approach for the complex slices. See the results:

before

goos: darwin
goarch: arm64
pkg: go.opentelemetry.io/collector/pdata/internal
cpu: Apple M1 Max
BenchmarkCopyOrigSlice
BenchmarkCopyOrigSlice/0_to_7-10         	 6696460	       187.7 ns/op	     252 B/op	      10 allocs/op
BenchmarkCopyOrigSlice/1_to_7-10         	 6324669	       181.4 ns/op	     252 B/op	      10 allocs/op
BenchmarkCopyOrigSlice/7_to_7-10         	 6145800	       191.6 ns/op	     252 B/op	      10 allocs/op
BenchmarkCopyOrigSlice/10_to_7-10        	 4897490	       247.2 ns/op	     412 B/op	      11 allocs/op
BenchmarkCopyOrigSlice/20_to_7-10        	 3922288	       306.8 ns/op	     572 B/op	      11 allocs/op
BenchmarkCopyOrigSlice/50_to_7-10        	 2775319	       430.0 ns/op	    1148 B/op	      11 allocs/op
PASS

after

BenchmarkCopyOrigSlice/0_to_7-10         	 6255495	       188.3 ns/op	     252 B/op	      10 allocs/op
BenchmarkCopyOrigSlice/1_to_7-10         	 5359400	       186.6 ns/op	     252 B/op	      10 allocs/op
BenchmarkCopyOrigSlice/7_to_7-10         	 5916748	       206.2 ns/op	     252 B/op	      10 allocs/op
BenchmarkCopyOrigSlice/10_to_7-10        	 4371021	       264.9 ns/op	     476 B/op	      11 allocs/op
BenchmarkCopyOrigSlice/20_to_7-10        	 3081704	       395.6 ns/op	     924 B/op	      12 allocs/op
BenchmarkCopyOrigSlice/50_to_7-10        	 1881642	       631.2 ns/op	    1948 B/op	      13 allocs/op
PASS

10 allocations are spent to regenerate the destination slice

Copy link

codecov bot commented Jun 29, 2025

Codecov Report

❌ Patch coverage is 29.16667% with 17 lines in your changes missing coverage. Please review.
✅ Project coverage is 91.56%. Comparing base (c6cd1ae) to head (a035f59).
⚠️ Report is 129 commits behind head on main.

Files with missing lines Patch % Lines
pdata/internal/wrapper_value.go 22.72% 17 Missing ⚠️

❌ Your patch status has failed because the patch coverage (29.16%) is below the target coverage (95.00%). You can increase the patch coverage or adjust the target coverage.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #13293      +/-   ##
==========================================
- Coverage   91.61%   91.56%   -0.06%     
==========================================
  Files         522      522              
  Lines       29120    29139      +19     
==========================================
+ Hits        26679    26681       +2     
- Misses       1925     1942      +17     
  Partials      516      516              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

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

Copy link
Contributor

This PR was marked stale due to lack of activity. It will be closed in 14 days.

@github-actions github-actions bot added the Stale label Jul 15, 2025
Copy link
Contributor

Closed as inactive. Feel free to reopen if this PR is still being worked on.

@github-actions github-actions bot closed this Jul 29, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant