Some optimizations for HRW sort #8
No reviewers
Labels
No Label
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 Assignees
4 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: TrueCloudLab/hrw#8
Loading…
Reference in New Issue
There is no content yet.
Delete Branch "fyrchik/hrw:optimize-hrw"
Deleting a branch is permanent. Although the deleted branch may exist for a short time before cleaning up, in most cases it CANNOT be undone. 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