From d3ebec8f21803da2642dc6798db71b7abc317a00 Mon Sep 17 00:00:00 2001 From: Michael Eischer Date: Sat, 8 Oct 2022 18:20:41 +0200 Subject: [PATCH] backup: Use buffered channels to collect backup status When backing up many small files, the unbuffered channels frequently cause the FileSaver to block when reporting progress information. Thus, add buffers to these channels to avoid unnecessary scheduling. As the status information is purely informational, it doesn't matter that the status reporting shutdown is somewhat racy and could miss a few final updates. --- internal/ui/backup/progress.go | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/internal/ui/backup/progress.go b/internal/ui/backup/progress.go index a4b641fe9..2bb7579d3 100644 --- a/internal/ui/backup/progress.go +++ b/internal/ui/backup/progress.go @@ -87,10 +87,13 @@ func NewProgress(printer ProgressPrinter) *Progress { MinUpdatePause: time.Second / 60, start: time.Now(), - totalCh: make(chan Counter), - processedCh: make(chan Counter), + // use buffered channels for the information used to update the status + // the shutdown of the `Run()` method is somewhat racy, but won't affect + // the final backup statistics + totalCh: make(chan Counter, 100), + processedCh: make(chan Counter, 100), errCh: make(chan struct{}), - workerCh: make(chan fileWorkerMessage), + workerCh: make(chan fileWorkerMessage, 100), closed: make(chan struct{}), summary: &Summary{},