From 2db3639fe200660a1623f2f01a46a748f956c6ee Mon Sep 17 00:00:00 2001 From: Anna Shaleva Date: Mon, 24 Aug 2020 10:15:02 +0300 Subject: [PATCH 1/3] cmd: print count of all transactions in block Yet another part of the old code from 2-x. Now we have to take into account all transactions from block. --- cmd/internal/worker.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmd/internal/worker.go b/cmd/internal/worker.go index a66c2aa..b2bb766 100644 --- a/cmd/internal/worker.go +++ b/cmd/internal/worker.go @@ -357,7 +357,7 @@ func (d *doer) parse(ctx context.Context, startBlock int, lastTime *uint64) (las // report current tps d.tpsReporter(tps) - for i := 1; i < cnt; i++ { + for i := 0; i < cnt; i++ { tx := blk.Transactions[i] if len(tx.Scripts) > 0 { if _, ok := d.dump.Hashes[tx.Hash().String()]; ok { From d12ef1f2435192d62a57f902e88d49160317d8c2 Mon Sep 17 00:00:00 2001 From: Anna Shaleva Date: Mon, 24 Aug 2020 10:18:45 +0300 Subject: [PATCH 2/3] cmd: do not add to TPS list zero values at the start We shouldn't take into account zero TPS values at the start of the test before any non-empty block arrives. --- cmd/internal/worker.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/cmd/internal/worker.go b/cmd/internal/worker.go index b2bb766..e9a8e1c 100644 --- a/cmd/internal/worker.go +++ b/cmd/internal/worker.go @@ -29,6 +29,7 @@ type ( waiter *sync.WaitGroup countTxs *atomic.Int32 // stores count of completed queries countErr *atomic.Int32 + hasStarted *atomic.Bool parsedCount int parsedBlocks map[int]struct{} } @@ -194,6 +195,7 @@ func NewWorkers(opts ...WorkerOption) (Worker, error) { sentOut: make(chan struct{}), countTxs: atomic.NewInt32(0), countErr: atomic.NewInt32(0), + hasStarted: atomic.NewBool(false), parsedBlocks: make(map[int]struct{}), } @@ -343,6 +345,8 @@ func (d *doer) parse(ctx context.Context, startBlock int, lastTime *uint64) (las if cnt = len(blk.Transactions); cnt < 1 { log.Printf("empty block: %d", i) + } else if !d.hasStarted.Load() { + d.hasStarted.Store(true) } // Timestamp is in milliseconds so we multiply numerator by 1000 to be more precise. @@ -354,6 +358,13 @@ func (d *doer) parse(ctx context.Context, startBlock int, lastTime *uint64) (las // update last block timestamp *lastTime = blk.Timestamp + // do not add zero TPS in case if there were no non-empty blocks yet + if tps == 0 { + if !d.hasStarted.Load() { + continue + } + } + // report current tps d.tpsReporter(tps) From cb8585475965a414b944a57375f75fed3760ffb3 Mon Sep 17 00:00:00 2001 From: Anna Shaleva Date: Mon, 24 Aug 2020 14:59:53 +0300 Subject: [PATCH 3/3] cmd: do not add to TPS list zero values at the end We shouldn't pay attention to the zero TPS values after the node has completed transactions handling. This moment should be treated as the test end, but there's a problem of missing transactions. --- cmd/internal/report.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/cmd/internal/report.go b/cmd/internal/report.go index b67afd8..db704a0 100644 --- a/cmd/internal/report.go +++ b/cmd/internal/report.go @@ -18,6 +18,7 @@ type ( ErrCount int32 RPS []float64 TPS []float64 + TPSPool []float64 Stats [][2]float64 // CPU, Mem } @@ -233,7 +234,13 @@ func (r *reporter) UpdateTPS(v float64) { r.Lock() defer r.Unlock() - r.TPS = append(r.TPS, v) + if v > 0 { + r.TPS = append(r.TPS, r.TPSPool...) + r.TPS = append(r.TPS, v) + r.TPSPool = nil + } else { + r.TPSPool = append(r.TPSPool, v) + } } // UpdateRes sets current resource usage by containers.