mirror of
https://github.com/restic/restic.git
synced 2025-10-11 03:12:38 +00:00
repository: optimize MasterIndex.Each
Sending data through a channel at very high frequency is extremely inefficient. Thus use simple callbacks instead of channels. > name old time/op new time/op delta > MasterIndexEach-16 6.68s ±24% 0.96s ± 2% -85.64% (p=0.008 n=5+5)
This commit is contained in:
@@ -595,10 +595,15 @@ func (r *Repository) LoadIndex(ctx context.Context) error {
|
||||
// sanity check
|
||||
ctx, cancel := context.WithCancel(ctx)
|
||||
defer cancel()
|
||||
for blob := range r.idx.Each(ctx) {
|
||||
|
||||
invalidIndex := false
|
||||
r.idx.Each(ctx, func(blob restic.PackedBlob) {
|
||||
if blob.IsCompressed() {
|
||||
return errors.Fatal("index uses feature not supported by repository version 1")
|
||||
invalidIndex = true
|
||||
}
|
||||
})
|
||||
if invalidIndex {
|
||||
return errors.Fatal("index uses feature not supported by repository version 1")
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user