mirror of
https://github.com/restic/restic.git
synced 2025-12-08 06:09:56 +00:00
more aggressive batching
This commit is contained in:
parent
857b42fca4
commit
e79b01d82f
1 changed files with 7 additions and 2 deletions
|
|
@ -3,6 +3,7 @@ package main
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"time"
|
||||||
|
|
||||||
"github.com/restic/restic/internal/data"
|
"github.com/restic/restic/internal/data"
|
||||||
"github.com/restic/restic/internal/debug"
|
"github.com/restic/restic/internal/debug"
|
||||||
|
|
@ -193,13 +194,17 @@ func copyTreeBatched(ctx context.Context, srcRepo restic.Repository, dstRepo res
|
||||||
// remember already processed trees across all snapshots
|
// remember already processed trees across all snapshots
|
||||||
visitedTrees := restic.NewIDSet()
|
visitedTrees := restic.NewIDSet()
|
||||||
|
|
||||||
|
targetSize := uint64(dstRepo.PackSize()) * 100
|
||||||
|
minDuration := 1 * time.Minute
|
||||||
|
|
||||||
for len(selectedSnapshots) > 0 {
|
for len(selectedSnapshots) > 0 {
|
||||||
var batch []*data.Snapshot
|
var batch []*data.Snapshot
|
||||||
batchSize := uint64(0)
|
batchSize := uint64(0)
|
||||||
targetSize := uint64(dstRepo.PackSize()) * 10
|
startTime := time.Now()
|
||||||
|
|
||||||
// call WithBlobUploader() once and then loop over all selectedSnapshots
|
// call WithBlobUploader() once and then loop over all selectedSnapshots
|
||||||
err := dstRepo.WithBlobUploader(ctx, func(ctx context.Context, uploader restic.BlobSaver) error {
|
err := dstRepo.WithBlobUploader(ctx, func(ctx context.Context, uploader restic.BlobSaver) error {
|
||||||
for len(selectedSnapshots) > 0 && batchSize < targetSize {
|
for len(selectedSnapshots) > 0 && (batchSize < targetSize || time.Since(startTime) < minDuration) {
|
||||||
sn := selectedSnapshots[0]
|
sn := selectedSnapshots[0]
|
||||||
selectedSnapshots = selectedSnapshots[1:]
|
selectedSnapshots = selectedSnapshots[1:]
|
||||||
batch = append(batch, sn)
|
batch = append(batch, sn)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue