From d142fa9295e0ba7fdd5a3a67a74b63333e614547 Mon Sep 17 00:00:00 2001 From: rasmus Date: Sun, 6 Nov 2022 16:09:28 +0200 Subject: [PATCH] perf: cache catchupped status --- cmd/submit.go | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/cmd/submit.go b/cmd/submit.go index da0b785..30dfdb7 100644 --- a/cmd/submit.go +++ b/cmd/submit.go @@ -118,6 +118,7 @@ func (s *submitter) shipFileRoutine(ctx context.Context, name string, sendQueue return fmt.Errorf("tailing file: %w", err) } + var catchUpped bool // cache for { select { case err := <-errChan: @@ -128,10 +129,14 @@ func (s *submitter) shipFileRoutine(ctx context.Context, name string, sendQueue return nil } - if line.EndOffset > startSize { - select { - case sigCatchupped <- struct{}{}: - default: + if !catchUpped { + catchUpped = line.EndOffset > startSize + + if catchUpped { + select { + case sigCatchupped <- struct{}{}: + default: + } } }