From e52033a8bd1aa0bfb23ccde5805a00e64ea4cfa4 Mon Sep 17 00:00:00 2001 From: Michael Eischer Date: Sun, 19 May 2024 22:14:28 +0200 Subject: [PATCH] index: slightly reduce Rewrite concurrency The index operations are likely CPU-bounded. Thus, reduce the concurrency accordingly. --- internal/index/master_index.go | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/internal/index/master_index.go b/internal/index/master_index.go index 8e959bed3..f9fc4505b 100644 --- a/internal/index/master_index.go +++ b/internal/index/master_index.go @@ -395,8 +395,9 @@ func (mi *MasterIndex) Rewrite(ctx context.Context, repo restic.Unpacked, exclud } return nil } - // loading an index can take quite some time such that this can be both CPU- or IO-bound - loaderCount := int(repo.Connections()) + runtime.GOMAXPROCS(0) + // loading an index can take quite some time such that this is probably CPU-bound + // the index files are probably already cached at this point + loaderCount := runtime.GOMAXPROCS(0) // run workers on ch for i := 0; i < loaderCount; i++ { rewriteWg.Add(1) @@ -467,8 +468,9 @@ func (mi *MasterIndex) Rewrite(ctx context.Context, repo restic.Unpacked, exclud return nil } - // encoding an index can take quite some time such that this can be both CPU- or IO-bound - workerCount := int(repo.Connections()) + runtime.GOMAXPROCS(0) + // encoding an index can take quite some time such that this can be CPU- or IO-bound + // do not add repo.Connections() here as there are already the loader goroutines. + workerCount := runtime.GOMAXPROCS(0) // run workers on ch for i := 0; i < workerCount; i++ { wg.Go(worker)