From de6e6cd6a7868003d282e9403c450110a487a4ea Mon Sep 17 00:00:00 2001 From: Noah Treuhaft Date: Fri, 5 Apr 2024 17:34:06 -0400 Subject: [PATCH] Buffer zngio.scanner.workerCh for more concurrency Tracing with package runtime/trace shows the scanner.start and worker.run goroutines block frequently on the workerCh channel. Add buffering to workerCH to reduce blocking and increase concurrency. When scanning a 4 GB ZNG file containing Zeek logs, this yields a 1.1X speedup on my 10-core machine. --- zio/zngio/scanner.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/zio/zngio/scanner.go b/zio/zngio/scanner.go index c5d9d55c9a..3c29e65173 100644 --- a/zio/zngio/scanner.go +++ b/zio/zngio/scanner.go @@ -40,7 +40,7 @@ func newScanner(ctx context.Context, zctx *zed.Context, r io.Reader, filter zbuf maxSize: opts.Max, }, validate: opts.Validate, - workerCh: make(chan *worker), + workerCh: make(chan *worker, opts.Threads+1), resultChCh: make(chan chan op.Result, opts.Threads+1), } for i := 0; i < opts.Threads; i++ {