From e785d6851c8b24f8ed87052e5603fca320fd00d3 Mon Sep 17 00:00:00 2001 From: ValarDragon Date: Wed, 11 Jul 2018 22:55:20 -0700 Subject: [PATCH] Fix getting the start time so the first block is no longer empty --- tools/tm-bench/README.md | 23 +++++++++++++++++------ tools/tm-bench/main.go | 15 ++++++++++++++- tools/tm-bench/transacter.go | 11 +++++++---- 3 files changed, 38 insertions(+), 11 deletions(-) diff --git a/tools/tm-bench/README.md b/tools/tm-bench/README.md index 811141629..000f20f37 100644 --- a/tools/tm-bench/README.md +++ b/tools/tm-bench/README.md @@ -51,15 +51,26 @@ with the last command being in a seperate window. ## How stats are collected These stats are derived by having each connection send transactions at the -specified rate (or as close as it can get) for the specified time. After the -specified time, it iterates over all of the blocks that were created in that -time. The average and stddev per second are computed based off of that, by +specified rate (or as close as it can get) for the specified time. +After the specified time, it iterates over all of the blocks that were created +in that time. +The average and stddev per second are computed based off of that, by grouping the data by second. To send transactions at the specified rate in each connection, we loop -through the number of transactions. If its too slow, the loop stops at one second. -If its too fast, we wait until the one second mark ends. The transactions per -second stat is computed based off of what ends up in the block. +through the number of transactions. +If its too slow, the loop stops at one second. +If its too fast, we wait until the one second mark ends. +The transactions per second stat is computed based off of what ends up in the +block. + +Note that there will be edge effects on the number of transactions in the first +and last blocks. +This is because transactions may start sending midway through when tendermint +starts building the next block, so it only has half as much time to gather txs +that tm-bench sends. +Similarly the end of the duration will likely end mid-way through tendermint +trying to build the next block. Each of the connections is handled via two separate goroutines. diff --git a/tools/tm-bench/main.go b/tools/tm-bench/main.go index a9151404a..68b3bee16 100644 --- a/tools/tm-bench/main.go +++ b/tools/tm-bench/main.go @@ -101,7 +101,20 @@ Examples: "broadcast_tx_"+broadcastTxMethod, ) - // record time start + // Wait until transacters have begun until we get the start time + for { + started := true + for _, t := range transacters { + for i := 0; i < t.Connections; i++ { + if !t.connsStarted[i] && !t.connsBroken[i] { + started = false + } + } + } + if started { + break + } + } timeStart := time.Now() logger.Info("Time last transacter started", "t", timeStart) diff --git a/tools/tm-bench/transacter.go b/tools/tm-bench/transacter.go index de408136d..f89c55b7b 100644 --- a/tools/tm-bench/transacter.go +++ b/tools/tm-bench/transacter.go @@ -34,10 +34,11 @@ type transacter struct { Connections int BroadcastTxMethod string - conns []*websocket.Conn - connsBroken []bool - wg sync.WaitGroup - stopped bool + conns []*websocket.Conn + connsStarted []bool + connsBroken []bool + wg sync.WaitGroup + stopped bool logger log.Logger } @@ -50,6 +51,7 @@ func newTransacter(target string, connections, rate int, size int, broadcastTxMe Connections: connections, BroadcastTxMethod: broadcastTxMethod, conns: make([]*websocket.Conn, connections), + connsStarted: make([]bool, connections), connsBroken: make([]bool, connections), logger: log.NewNopLogger(), } @@ -156,6 +158,7 @@ func (t *transacter) sendLoop(connIndex int) { startTime := time.Now() endTime := startTime.Add(time.Second) numTxSent := t.Rate + t.connsStarted[connIndex] = true for i := 0; i < t.Rate; i++ { // each transaction embeds connection index, tx number and hash of the hostname