mirror of
https://github.com/kopia/kopia.git
synced 2026-03-06 07:17:56 -05:00
fix(snapshots): fixed --parallel flag when snapshotting (#2392)
Previously the value of --parallel flag was (unintentionally) capped at max number of CPUs. This PR fixes the logic.
This commit is contained in:
@@ -727,8 +727,13 @@ func (u *Uploader) maybeIgnoreCachedEntry(ctx context.Context, ent fs.Entry) fs.
|
||||
|
||||
func (u *Uploader) effectiveParallelFileReads(pol *policy.Policy) int {
|
||||
p := u.ParallelUploads
|
||||
max := pol.UploadPolicy.MaxParallelFileReads.OrDefault(runtime.NumCPU())
|
||||
if p > 0 {
|
||||
// command-line override takes precedence.
|
||||
return p
|
||||
}
|
||||
|
||||
// use policy setting or number of CPUs.
|
||||
max := pol.UploadPolicy.MaxParallelFileReads.OrDefault(runtime.NumCPU())
|
||||
if p < 1 || p > max {
|
||||
return max
|
||||
}
|
||||
|
||||
@@ -679,7 +679,7 @@ func TestParallelUploadUploadsBlobsInParallel(t *testing.T) {
|
||||
th := newUploadTestHarness(ctx, t)
|
||||
|
||||
u := NewUploader(th.repo)
|
||||
u.ParallelUploads = 10
|
||||
u.ParallelUploads = 13
|
||||
|
||||
// no faults for first blob write - session marker.
|
||||
th.faulty.AddFault(blobtesting.MethodPutBlob)
|
||||
@@ -705,6 +705,8 @@ func TestParallelUploadUploadsBlobsInParallel(t *testing.T) {
|
||||
|
||||
policyTree := policy.BuildTree(nil, policy.DefaultPolicy)
|
||||
|
||||
require.Equal(t, 13, u.effectiveParallelFileReads(policyTree.EffectivePolicy()))
|
||||
|
||||
si := snapshot.SourceInfo{
|
||||
UserName: "user",
|
||||
Host: "host",
|
||||
|
||||
Reference in New Issue
Block a user