Process packs in order of first appearance
This commit is contained in:
parent
fe69b83074
commit
2e7d475029
1 changed files with 7 additions and 1 deletions
|
@ -101,6 +101,10 @@ func (r *fileRestorer) forEachBlob(blobIDs []restic.ID, fn func(packID restic.ID
|
||||||
func (r *fileRestorer) restoreFiles(ctx context.Context) error {
|
func (r *fileRestorer) restoreFiles(ctx context.Context) error {
|
||||||
|
|
||||||
packs := make(map[restic.ID]*packInfo) // all packs
|
packs := make(map[restic.ID]*packInfo) // all packs
|
||||||
|
// Process packs in order of first access. While this cannot guarantee
|
||||||
|
// that file chunks are restored sequentially, it offers a good enough
|
||||||
|
// approximation to shorten restore times by up to 19% in some test.
|
||||||
|
var packOrder restic.IDs
|
||||||
|
|
||||||
// create packInfo from fileInfo
|
// create packInfo from fileInfo
|
||||||
for _, file := range r.files {
|
for _, file := range r.files {
|
||||||
|
@ -123,6 +127,7 @@ func (r *fileRestorer) restoreFiles(ctx context.Context) error {
|
||||||
files: make(map[*fileInfo]struct{}),
|
files: make(map[*fileInfo]struct{}),
|
||||||
}
|
}
|
||||||
packs[packID] = pack
|
packs[packID] = pack
|
||||||
|
packOrder = append(packOrder, packID)
|
||||||
}
|
}
|
||||||
pack.files[file] = struct{}{}
|
pack.files[file] = struct{}{}
|
||||||
})
|
})
|
||||||
|
@ -157,7 +162,8 @@ func (r *fileRestorer) restoreFiles(ctx context.Context) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
// the main restore loop
|
// the main restore loop
|
||||||
for _, pack := range packs {
|
for _, id := range packOrder {
|
||||||
|
pack := packs[id]
|
||||||
select {
|
select {
|
||||||
case <-ctx.Done():
|
case <-ctx.Done():
|
||||||
return ctx.Err()
|
return ctx.Err()
|
||||||
|
|
Loading…
Reference in a new issue