chore: remove weak hashing which does not pull its weight (#10005)

We've had weak/rolling hashing in the code for quite a while. It was a
popular request for a while, based on the belief that rsync does this
and we should too. However, the benefit is quite small; we save on
average about 0.8% of transferred blocks over the population as a whole:

<img width="974" alt="Screenshot 2025-03-28 at 17 09 02"
src="https://github.com/user-attachments/assets/bbe10dea-f85e-4043-9823-7cef1220b4a2"
/>

This would be fine if the cost was comparably low, however the downside
of attempting rolling hash matching is that we (by default) do a
complete file read on the destination in order to look for matches
before we starting pulling blocks for the file. For any larger file this
means a sometimes long, I/O-intensive pause before the file starts
syncing, for usually no benefit.

I propose we simply rip off the bandaid and save the effort.
This commit is contained in:
Jakob Borg
2025-03-29 13:21:10 +01:00
committed by GitHub
parent 1a25ae32ca
commit b1c8f88a44
38 changed files with 288 additions and 1030 deletions
+26 -28
View File
@@ -435,19 +435,18 @@ type Model struct {
result1 protocol.RequestResponse
result2 error
}
RequestGlobalStub func(context.Context, protocol.DeviceID, string, string, int, int64, int, []byte, uint32, bool) ([]byte, error)
RequestGlobalStub func(context.Context, protocol.DeviceID, string, string, int, int64, int, []byte, bool) ([]byte, error)
requestGlobalMutex sync.RWMutex
requestGlobalArgsForCall []struct {
arg1 context.Context
arg2 protocol.DeviceID
arg3 string
arg4 string
arg5 int
arg6 int64
arg7 int
arg8 []byte
arg9 uint32
arg10 bool
arg1 context.Context
arg2 protocol.DeviceID
arg3 string
arg4 string
arg5 int
arg6 int64
arg7 int
arg8 []byte
arg9 bool
}
requestGlobalReturns struct {
result1 []byte
@@ -2580,7 +2579,7 @@ func (fake *Model) RequestReturnsOnCall(i int, result1 protocol.RequestResponse,
}{result1, result2}
}
func (fake *Model) RequestGlobal(arg1 context.Context, arg2 protocol.DeviceID, arg3 string, arg4 string, arg5 int, arg6 int64, arg7 int, arg8 []byte, arg9 uint32, arg10 bool) ([]byte, error) {
func (fake *Model) RequestGlobal(arg1 context.Context, arg2 protocol.DeviceID, arg3 string, arg4 string, arg5 int, arg6 int64, arg7 int, arg8 []byte, arg9 bool) ([]byte, error) {
var arg8Copy []byte
if arg8 != nil {
arg8Copy = make([]byte, len(arg8))
@@ -2589,23 +2588,22 @@ func (fake *Model) RequestGlobal(arg1 context.Context, arg2 protocol.DeviceID, a
fake.requestGlobalMutex.Lock()
ret, specificReturn := fake.requestGlobalReturnsOnCall[len(fake.requestGlobalArgsForCall)]
fake.requestGlobalArgsForCall = append(fake.requestGlobalArgsForCall, struct {
arg1 context.Context
arg2 protocol.DeviceID
arg3 string
arg4 string
arg5 int
arg6 int64
arg7 int
arg8 []byte
arg9 uint32
arg10 bool
}{arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8Copy, arg9, arg10})
arg1 context.Context
arg2 protocol.DeviceID
arg3 string
arg4 string
arg5 int
arg6 int64
arg7 int
arg8 []byte
arg9 bool
}{arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8Copy, arg9})
stub := fake.RequestGlobalStub
fakeReturns := fake.requestGlobalReturns
fake.recordInvocation("RequestGlobal", []interface{}{arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8Copy, arg9, arg10})
fake.recordInvocation("RequestGlobal", []interface{}{arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8Copy, arg9})
fake.requestGlobalMutex.Unlock()
if stub != nil {
return stub(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10)
return stub(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9)
}
if specificReturn {
return ret.result1, ret.result2
@@ -2619,17 +2617,17 @@ func (fake *Model) RequestGlobalCallCount() int {
return len(fake.requestGlobalArgsForCall)
}
func (fake *Model) RequestGlobalCalls(stub func(context.Context, protocol.DeviceID, string, string, int, int64, int, []byte, uint32, bool) ([]byte, error)) {
func (fake *Model) RequestGlobalCalls(stub func(context.Context, protocol.DeviceID, string, string, int, int64, int, []byte, bool) ([]byte, error)) {
fake.requestGlobalMutex.Lock()
defer fake.requestGlobalMutex.Unlock()
fake.RequestGlobalStub = stub
}
func (fake *Model) RequestGlobalArgsForCall(i int) (context.Context, protocol.DeviceID, string, string, int, int64, int, []byte, uint32, bool) {
func (fake *Model) RequestGlobalArgsForCall(i int) (context.Context, protocol.DeviceID, string, string, int, int64, int, []byte, bool) {
fake.requestGlobalMutex.RLock()
defer fake.requestGlobalMutex.RUnlock()
argsForCall := fake.requestGlobalArgsForCall[i]
return argsForCall.arg1, argsForCall.arg2, argsForCall.arg3, argsForCall.arg4, argsForCall.arg5, argsForCall.arg6, argsForCall.arg7, argsForCall.arg8, argsForCall.arg9, argsForCall.arg10
return argsForCall.arg1, argsForCall.arg2, argsForCall.arg3, argsForCall.arg4, argsForCall.arg5, argsForCall.arg6, argsForCall.arg7, argsForCall.arg8, argsForCall.arg9
}
func (fake *Model) RequestGlobalReturns(result1 []byte, result2 error) {