-
-
Notifications
You must be signed in to change notification settings - Fork 4.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
lib/model: Change weak hash algo, add heuristic #3872
Conversation
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.
otherwise LGTM
@@ -1216,7 +1220,7 @@ func (f *sendReceiveFolder) copierRoutine(in <-chan copyBlocksState, pullChan ch | |||
f.model.fmut.RUnlock() | |||
|
|||
var weakHashFinder *weakhash.Finder | |||
if !f.DisableWeakHash { | |||
if (len(state.file.Blocks)-state.have)*100/len(state.file.Blocks) >= f.WeakHashThresholdPct { |
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 expression should definitely be a variable of some sort with a name
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.
Also, potential div by zero for empty files?
By not adding the |
I guess we could go for xxhash, which would potentially raise that a bit, but then the rolling would be incredibly expensive |
@@ -1216,7 +1220,8 @@ func (f *sendReceiveFolder) copierRoutine(in <-chan copyBlocksState, pullChan ch | |||
f.model.fmut.RUnlock() | |||
|
|||
var weakHashFinder *weakhash.Finder | |||
if !f.DisableWeakHash { | |||
blocksPercentChanged := (len(state.file.Blocks) - state.have) * 100 / len(state.file.Blocks) |
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.
what about len(state.file.Blockes) == 0
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.
fixed
@@ -1216,7 +1220,12 @@ func (f *sendReceiveFolder) copierRoutine(in <-chan copyBlocksState, pullChan ch | |||
f.model.fmut.RUnlock() | |||
|
|||
var weakHashFinder *weakhash.Finder | |||
if !f.DisableWeakHash { | |||
blocksPercentChanged := 0 | |||
if len(state.file.Blocks) != 0 { |
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.
if tot := len(state.file.Blocks); tot > 0 {
blocksPercentChanged = (tot - state.have) * 100 / tot
}
🚲 🏡
This is a vast improvement on both sides, it's good enough for now. |
🚂 🚂 |
@st-review merge it yo lib/model, lib/weakhash: Hash using adler32, add heuristic in puller Adler32 is much faster, and the heuristic avoid the obvious cases where it will not help. |
@calmh: Build status is |
obtypo in the commit message, which will look like you did it 💯 😑 |
👌 Merged as 29d010e. Thanks, @AudriusButkevicius! |
Adler32 is much faster, and the heuristic avoid the obvious cases where it will not help. GitHub-Pull-Request: #3872
No description provided.