-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Deprecate Sortable #4734
Deprecate Sortable #4734
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #4734 +/- ##
=======================================
- Coverage 83.5% 83.4% -0.1%
=======================================
Files 238 238
Lines 15757 15745 -12
=======================================
- Hits 13159 13143 -16
- Misses 2309 2314 +5
+ Partials 289 288 -1
|
CC @MrAlias |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks to removes the amortized allocations from NewSet
and the removal of an allocation for NewSetWithSortableFiltered
. Please show this doesn't add an additional allocation before this can be considered.
I've added a new benchmark that exercises the
Because we are testing sorting, actual performance depends on the data being sorted. But this branch performs 1 allocation too. |
7b76af7
to
c52d3d0
Compare
$ go1.20 version
go version go1.20 linux/amd64
$ go1.20 test -run='^$' -bench=NewSetWithSortableFiltered
goos: linux
goarch: amd64
pkg: go.opentelemetry.io/otel/attribute
cpu: Intel(R) Core(TM) i7-8550U CPU @ 1.80GHz
BenchmarkNewSetWithSortableFiltered-8 2496835 480.1 ns/op 584 B/op 4 allocs/op
PASS On main: $ go1.20 test -run='^$' -bench=NewSetWithSortableFiltered
goos: linux
goarch: amd64
pkg: go.opentelemetry.io/otel/attribute
cpu: Intel(R) Core(TM) i7-8550U CPU @ 1.80GHz
BenchmarkNewSetWithSortableFiltered-8 4108585 283.9 ns/op 448 B/op 1 allocs/op
PASS |
On branch:
I think we can consider this PR when we drop support for Go 1.20. |
This should be ready to merge now that #4967 is merged. Please update to remove the separate code paths for versions of Go less than 1.21 as they are no longer supported. |
New code:
Old code:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you also please update the PR description as the current one is outdated and may be misleading?
Co-authored-by: Tyler Yahn <MrAlias@users.noreply.github.com>
Co-authored-by: Robert Pająk <pellared@hotmail.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please include the benchmarks from the comments in the PR. There seems to be a lack of tests measuring the performance of NewSet
in the existing tetss.
@MrAlias Added back the benchmark. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@open-telemetry/go-approvers please take a look
* Deprecate Sortable * Remove redundant checks * Move code to a non-deprecated func * Apply suggestions from code review Co-authored-by: Tyler Yahn <MrAlias@users.noreply.github.com> * Mention individual deprecated function * Update attribute/set.go Co-authored-by: Robert Pająk <pellared@hotmail.com> * Add BenchmarkNewSet --------- Co-authored-by: Tyler Yahn <MrAlias@users.noreply.github.com> Co-authored-by: Robert Pająk <pellared@hotmail.com>
I wonder what was the reason for introducing the methods with
*Sortable
in the first place? Code in this PR works fine, but I couldn't find the benchmarks from #3832 to see if it allocates more or is slower. Any pointers?I ran the existing benchmarks and the results are identical old vs new on both Go 1.20.10 and 1.21.4.
1.20.10, old vs new:
1.21.4, old vs new:
New code, 1.20.10 vs 1.21.4:
There are some performance differences (not allocations though), but I only ran count=3 for the 1.21 version as I'm short on time today. I'll re-run that tomorrow with count=10 to improve accuracy.