Some optimizations for HRW sort #8
No reviewers
Labels
No labels
P0
P1
P2
P3
good first issue
Infrastructure
blocked
bug
config
discussion
documentation
duplicate
enhancement
go
help wanted
internal
invalid
kludge
observability
perfomance
question
refactoring
wontfix
No milestone
No project
No assignees
4 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference: TrueCloudLab/hrw#8
Loading…
Reference in a new issue
No description provided.
Delete branch "fyrchik/hrw:optimize-hrw"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Total value of all optimizations in this PR (don't look at the last line, there was 100 in master and fixed 1000 in this PR):
f1874161d6
to6ec195b0c9
@ -36,0 +44,4 @@
if s.asc {
return s.dist[i] < s.dist[j]
} else {
return s.dist[i] > s.dist[j]
Redundant
else
Fixed
@ -112,2 +141,3 @@
dist[i] = distance(slice[i].Hash(), hash)
}
sortByWeight(len(slice), false, rule, weights, hash, swap)
sortHasherByDistance(slice, false, dist)
return?
Fixed
@ -115,0 +154,4 @@
sort.Sort(&hasherSorter[T, float64]{
slice: slice,
dist: dist,
asc: false,
Why
asc: false
, butsortHasherByDistance
hasasc: true
.It is intentional, if you look at the previous implementation, we sort with
dist[i] < dist[j]
for distance and the other way here. In the latter case it is transformed, see line 151.6ec195b0c9
to16a7740ccd