From abe35ec18ef4f47dca13a6347ada41113bf2e99e Mon Sep 17 00:00:00 2001 From: Leander Beernaert Date: Mon, 26 Sep 2022 10:30:58 +0200 Subject: [PATCH] fix: Benchmark fixes Do not print verbose message if not in verbose mode and don't use msg count divided by 2 as the number of operations by default to avoid misleading information. Fix imap seqset interval generation code, was always generating more intervals than those available. --- benchmarks/gluon_bench/benchmark/run.go | 4 +++- .../gluon_bench/imap_benchmarks/copy.go | 2 +- .../gluon_bench/imap_benchmarks/expunge.go | 2 +- .../gluon_bench/imap_benchmarks/fetch.go | 2 +- .../imap_benchmarks/parallel_seqset.go | 20 ++++++++++++++----- .../gluon_bench/imap_benchmarks/search.go | 2 +- .../gluon_bench/imap_benchmarks/store.go | 2 +- 7 files changed, 23 insertions(+), 11 deletions(-) diff --git a/benchmarks/gluon_bench/benchmark/run.go b/benchmarks/gluon_bench/benchmark/run.go index bcf54e60..03848321 100644 --- a/benchmarks/gluon_bench/benchmark/run.go +++ b/benchmarks/gluon_bench/benchmark/run.go @@ -140,7 +140,9 @@ func measureBenchmark(dirConfig BenchDirConfig, iteration uint, bench Benchmark) } if !*flags.SkipClean { - fmt.Printf("Cleaning benchmark dir: %v\n", benchPath) + if *flags.Verbose { + fmt.Printf("Cleaning benchmark dir: %v\n", benchPath) + } if err := os.RemoveAll(benchPath); err != nil { fmt.Fprintf(os.Stderr, "Failed to remote benchmark data dir '%v': %v\n", benchPath, err) diff --git a/benchmarks/gluon_bench/imap_benchmarks/copy.go b/benchmarks/gluon_bench/imap_benchmarks/copy.go index 53942cd4..09301428 100644 --- a/benchmarks/gluon_bench/imap_benchmarks/copy.go +++ b/benchmarks/gluon_bench/imap_benchmarks/copy.go @@ -44,7 +44,7 @@ func (c *Copy) Setup(ctx context.Context, addr net.Addr) error { copyCount := uint32(*copyCountFlag) if copyCount == 0 { - copyCount = uint32(*flags.IMAPMessageCount / 2) + copyCount = uint32(*flags.IMAPMessageCount) } seqSets, err := NewParallelSeqSet(copyCount, diff --git a/benchmarks/gluon_bench/imap_benchmarks/expunge.go b/benchmarks/gluon_bench/imap_benchmarks/expunge.go index 1dee7a43..8e2c8372 100644 --- a/benchmarks/gluon_bench/imap_benchmarks/expunge.go +++ b/benchmarks/gluon_bench/imap_benchmarks/expunge.go @@ -43,7 +43,7 @@ func (e *Expunge) Setup(ctx context.Context, addr net.Addr) error { expungeCount := uint32(*expungeCountFlag) if expungeCount == 0 { - expungeCount = uint32(*flags.IMAPMessageCount) / 2 + expungeCount = uint32(*flags.IMAPMessageCount) } e.seqSets = NewParallelSeqSetExpunge(expungeCount, diff --git a/benchmarks/gluon_bench/imap_benchmarks/fetch.go b/benchmarks/gluon_bench/imap_benchmarks/fetch.go index 6afae862..0d079a25 100644 --- a/benchmarks/gluon_bench/imap_benchmarks/fetch.go +++ b/benchmarks/gluon_bench/imap_benchmarks/fetch.go @@ -39,7 +39,7 @@ func (f *Fetch) Setup(ctx context.Context, addr net.Addr) error { fetchCount := uint32(*fetchCountFlag) if fetchCount == 0 { - fetchCount = uint32(*flags.IMAPMessageCount) / 2 + fetchCount = uint32(*flags.IMAPMessageCount) } seqSets, err := NewParallelSeqSet(fetchCount, diff --git a/benchmarks/gluon_bench/imap_benchmarks/parallel_seqset.go b/benchmarks/gluon_bench/imap_benchmarks/parallel_seqset.go index 748bc8a4..e3c5d75b 100644 --- a/benchmarks/gluon_bench/imap_benchmarks/parallel_seqset.go +++ b/benchmarks/gluon_bench/imap_benchmarks/parallel_seqset.go @@ -122,9 +122,7 @@ func NewParallelSeqSetRandom(count uint32, numWorkers uint, generateIntervals, r itemsLeft := uint32(len(available)) index := rand.Uint32() % itemsLeft - if index > intervalRange { - index -= intervalRange - } else { + if index >= itemsLeft { index = 0 } @@ -136,11 +134,23 @@ func NewParallelSeqSetRandom(count uint32, numWorkers uint, generateIntervals, r if uid { seqSet.AddRange(available[index], available[index+intervalRange-1]) } else { - seqSet.AddRange(index+1, index+intervalRange) + endSeq := index + intervalRange + 1 + + if endSeq > itemsLeft { + endSeq = itemsLeft + } + + seqSet.AddRange(index+1, endSeq) } list = append(list, seqSet) - available = append(available[:index], available[index+intervalRange:]...) + + cutIndex := index + if index > 0 { + cutIndex-- + } + + available = append(available[:cutIndex], available[index+intervalRange:]...) } } else { for r := uint32(0); r < count; r++ { diff --git a/benchmarks/gluon_bench/imap_benchmarks/search.go b/benchmarks/gluon_bench/imap_benchmarks/search.go index 92bcb975..b3a4e43b 100644 --- a/benchmarks/gluon_bench/imap_benchmarks/search.go +++ b/benchmarks/gluon_bench/imap_benchmarks/search.go @@ -51,7 +51,7 @@ func (s *Search) Setup(ctx context.Context, addr net.Addr) error { searchCount := uint32(*searchCountFlag) if searchCount == 0 { - searchCount = uint32(*flags.IMAPMessageCount) / 2 + searchCount = uint32(*flags.IMAPMessageCount) } if err := s.query.Setup(ctx, cl, searchCount); err != nil { diff --git a/benchmarks/gluon_bench/imap_benchmarks/store.go b/benchmarks/gluon_bench/imap_benchmarks/store.go index 5e0f392d..9e82954c 100644 --- a/benchmarks/gluon_bench/imap_benchmarks/store.go +++ b/benchmarks/gluon_bench/imap_benchmarks/store.go @@ -39,7 +39,7 @@ func (s *StoreBench) Setup(ctx context.Context, addr net.Addr) error { storeCount := uint32(*storeCountFlag) if storeCount == 0 { - storeCount = uint32(*flags.IMAPMessageCount) / 2 + storeCount = uint32(*flags.IMAPMessageCount) } seqSets, err := NewParallelSeqSet(storeCount,