Skip to content

Conversation

@ahouene
Copy link
Contributor

@ahouene ahouene commented Dec 9, 2025

Merely scratching an itch here, but the docs for the sort.Sort function we're using to sort BlobList mention:

Note: in many situations, the newer slices.SortFunc function is more ergonomic and runs faster.

And indeed:

$ go test . -bench=BlobListSort -benchmem -count=30 | benchstat -
goos: linux
goarch: amd64
pkg: github.com/PowerDNS/simpleblob
cpu: 11th Gen Intel(R) Core(TM) i9-11950H @ 2.60GHz
                                │      -      │
                                │   sec/op    │
BlobListSort/sort.Sort-16         912.7n ± 1%
BlobListSort/slices.SortFunc-16   823.7n ± 2%
geomean                           867.0n

                                │      -       │
                                │     B/op     │
BlobListSort/sort.Sort-16         24.00 ± 0%
BlobListSort/slices.SortFunc-16   0.000 ± 0%
geomean                                      ¹
¹ summaries must be >0 to compute geomean

                                │      -       │
                                │  allocs/op   │
BlobListSort/sort.Sort-16         1.000 ± 0%
BlobListSort/slices.SortFunc-16   0.000 ± 0%
geomean                                      ¹
¹ summaries must be >0 to compute geomean

This PR thus changes to slices.SortFunc, and provides a convenience (BlobList).Sort method.

@ahouene ahouene requested a review from Luit December 9, 2025 16:25
@ahouene ahouene self-assigned this Dec 9, 2025
@ahouene ahouene merged commit f67d4b6 into PowerDNS:main Dec 11, 2025
2 checks passed
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