forked from TrueCloudLab/frostfs-sdk-go
[#236] netmap: Replace sort.Slice() with slices.Sort()
``` goos: linux goarch: amd64 pkg: git.frostfs.info/TrueCloudLab/frostfs-sdk-go/netmap cpu: 11th Gen Intel(R) Core(TM) i5-1135G7 @ 2.40GHz │ old │ new │ │ sec/op │ sec/op vs base │ Netmap_ContainerNodes/REP_2-8 10.395µ ± 14% 9.227µ ± 13% -11.24% (p=0.015 n=10) Netmap_ContainerNodes/REP_2_IN_X_CBF_2_SELECT_2_FROM_*_AS_X-8 10.110µ ± 16% 9.189µ ± 7% ~ (p=0.105 n=10) geomean 10.25µ 9.208µ -10.18% │ old │ new │ │ B/op │ B/op vs base │ Netmap_ContainerNodes/REP_2-8 8.695Ki ± 0% 8.320Ki ± 0% -4.31% (p=0.000 n=10) Netmap_ContainerNodes/REP_2_IN_X_CBF_2_SELECT_2_FROM_*_AS_X-8 8.117Ki ± 0% 7.742Ki ± 0% -4.62% (p=0.000 n=10) geomean 8.401Ki 8.026Ki -4.47% │ old │ new │ │ allocs/op │ allocs/op vs base │ Netmap_ContainerNodes/REP_2-8 138.0 ± 0% 122.0 ± 0% -11.59% (p=0.000 n=10) Netmap_ContainerNodes/REP_2_IN_X_CBF_2_SELECT_2_FROM_*_AS_X-8 138.0 ± 0% 122.0 ± 0% -11.59% (p=0.000 n=10) geomean 138.0 122.0 -11.59% ``` Signed-off-by: Evgenii Stratonikov <e.stratonikov@yadro.com>
This commit is contained in:
parent
9d89f08c7b
commit
a69f00903c
4 changed files with 17 additions and 29 deletions
|
@ -1,8 +1,9 @@
|
|||
package netmap
|
||||
|
||||
import (
|
||||
"cmp"
|
||||
"fmt"
|
||||
"sort"
|
||||
"slices"
|
||||
|
||||
"git.frostfs.info/TrueCloudLab/frostfs-api-go/v2/netmap"
|
||||
"git.frostfs.info/TrueCloudLab/hrw"
|
||||
|
@ -70,12 +71,12 @@ func (c *context) getSelection(s netmap.Selector) ([]nodes, error) {
|
|||
// we also need to have deterministic input to HRW sorting routine.
|
||||
if len(c.hrwSeed) == 0 {
|
||||
if s.GetAttribute() == "" {
|
||||
sort.Slice(buckets, func(i, j int) bool {
|
||||
return less(buckets[i].nodes[0], buckets[j].nodes[0])
|
||||
slices.SortFunc(buckets, func(b1, b2 nodeAttrPair) int {
|
||||
return cmp.Compare(b1.nodes[0].Hash(), b2.nodes[0].Hash())
|
||||
})
|
||||
} else {
|
||||
sort.Slice(buckets, func(i, j int) bool {
|
||||
return buckets[i].attr < buckets[j].attr
|
||||
slices.SortFunc(buckets, func(b1, b2 nodeAttrPair) int {
|
||||
return cmp.Compare(b1.attr, b2.attr)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue