Files
tendermint/test/loadtime/cmd/load/main.go
mergify[bot] 014d0d6ca0 add separated runs by UUID (backport #9367) (#9380)
* add separated runs by UUID (#9367)

This _should_ be the last piece needed for this tool.
This allows the tool to generate reports on multiple experimental runs that may have been performed against the same chain.

The `load` tool has been updated to generate a `UUID` on startup to uniquely identify each experimental run. The `report` tool separates all of the results it reads by `UUID` and performs separate calculations for each discovered experiment.

Sample output is as follows

```
Experiment ID: 6bd7d1e8-d82c-4dbe-a1b3-40ab99e4fa30

        Connections: 1
        Rate: 1000
        Size: 1024

        Total Valid Tx: 9000
        Total Negative Latencies: 0
        Minimum Latency: 86.632837ms
        Maximum Latency: 1.151089602s
        Average Latency: 813.759361ms
        Standard Deviation: 225.189977ms

Experiment ID: 453960af-6295-4282-aed6-367fc17c0de0

        Connections: 1
        Rate: 1000
        Size: 1024

        Total Valid Tx: 9000
        Total Negative Latencies: 0
        Minimum Latency: 79.312992ms
        Maximum Latency: 1.162446243s
        Average Latency: 422.755139ms
        Standard Deviation: 241.832475ms

Total Invalid Tx: 0
```

closes: #9352

#### PR checklist

- [ ] Tests written/updated, or no tests needed
- [ ] `CHANGELOG_PENDING.md` updated, or no changelog entry needed
- [ ] Updated relevant documentation (`docs/`) and code comments, or no
      documentation updates needed

(cherry picked from commit 1067ba1571)

# Conflicts:
#	go.mod

* fix merge conflict

* fix lint

Co-authored-by: William Banfield <4561443+williambanfield@users.noreply.github.com>
Co-authored-by: William Banfield <wbanfield@gmail.com>
2022-09-06 11:07:59 -04:00

71 lines
1.8 KiB
Go

package main
import (
"fmt"
"github.com/google/uuid"
"github.com/informalsystems/tm-load-test/pkg/loadtest"
"github.com/tendermint/tendermint/test/loadtime/payload"
)
// Ensure all of the interfaces are correctly satisfied.
var (
_ loadtest.ClientFactory = (*ClientFactory)(nil)
_ loadtest.Client = (*TxGenerator)(nil)
)
// ClientFactory implements the loadtest.ClientFactory interface.
type ClientFactory struct{}
// TxGenerator is responsible for generating transactions.
// TxGenerator holds the set of information that will be used to generate
// each transaction.
type TxGenerator struct {
id []byte
conns uint64
rate uint64
size uint64
}
func main() {
if err := loadtest.RegisterClientFactory("loadtime-client", &ClientFactory{}); err != nil {
panic(err)
}
loadtest.Run(&loadtest.CLIConfig{
AppName: "loadtime",
AppShortDesc: "Generate timestamped transaction load.",
AppLongDesc: "loadtime generates transaction load for the purpose of measuring the end-to-end latency of a transaction from submission to execution in a Tendermint network.", //nolint:lll
DefaultClientFactory: "loadtime-client",
})
}
func (f *ClientFactory) ValidateConfig(cfg loadtest.Config) error {
psb, err := payload.MaxUnpaddedSize()
if err != nil {
return err
}
if psb > cfg.Size {
return fmt.Errorf("payload size exceeds configured size")
}
return nil
}
func (f *ClientFactory) NewClient(cfg loadtest.Config) (loadtest.Client, error) {
u := [16]byte(uuid.New())
return &TxGenerator{
id: u[:],
conns: uint64(cfg.Connections),
rate: uint64(cfg.Rate),
size: uint64(cfg.Size),
}, nil
}
func (c *TxGenerator) GenerateTx() ([]byte, error) {
return payload.NewBytes(&payload.Payload{
Connections: c.conns,
Rate: c.rate,
Size: c.size,
Id: c.id,
})
}