Skip to content

Commit

Permalink
chore: Add misc/stress-test
Browse files Browse the repository at this point in the history
Signed-off-by: Jeff Thompson <[email protected]>
  • Loading branch information
jefft0 committed Jun 24, 2024
1 parent 900bb2f commit 907101f
Show file tree
Hide file tree
Showing 4 changed files with 563 additions and 0 deletions.
61 changes: 61 additions & 0 deletions misc/stress-test/stress-test-many-posts/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# stress-test-many-posts

This is a utility which adds millions of posts to the (local) boards realm to test how memory and
transaction time change with lots of realm storage.

## Run

Start a local gno.land:

```
cd gno/gno.land
make install
gnoland start -lazy
```

Start gnoweb. In a separate terminal enter:

```
gnoweb
```

Run the utility. In a separate terminal enter:

```
gno/misc/stress-test/stress-test-many-posts
go run .
```

## Monitor

By default gno.land starts r/demo/boards where `testboard` is board #1. This utility adds millions of replies to the first post on that board.
To monitor progress, in a web browser go to http://127.0.0.1:8888/r/demo/boards:testboard . The first post says something like "(100 replies)".
Refresh your browser to see this number increase.

## Optional speedup

This utility adds 50 replies per transaction (as allowed by the maximum gas of 100 million). By default gno.land does one transaction every
5 seconds. It is optional but recommended to decrease this time to 1 second as follows:

* In the terminal where you started gno.land, hit ctrl-C
* In a text editor, open `gnoland-data/config/config.toml`
* Change `timeout_commit` to "1s"
* Save and close the text editor.
* Restart gno.land by entering `gnoland start -lazy`
* In the terminal where you started the test, restart it by entering `go run .`

Now data is added 5 times faster. This can reduce adding a million replies from days to hours.

## Test output

The utility prints results to the terminal in CSV which you can paste into a spreadsheet to analyze and graph.
Below is a sample output. On average the transaction time is 1 second (if you did the optional speedup), but
can be longer if the system becomes burdened with lots of data in memory.

```
nPosts, avg. for 50 posts [s], min for 50 posts [s], max for 50 posts [s]
1000, 1.044250, 1.015000, 1.136000
2000, 1.048650, 0.999000, 1.106000
3000, 1.047950, 1.021000, 1.079000
4000, 1.046450, 1.028000, 1.072000
```
68 changes: 68 additions & 0 deletions misc/stress-test/stress-test-many-posts/go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
module stress_test_many_posts

go 1.21

toolchain go1.21.7

require (
connectrpc.com/connect v1.14.0
github.com/gnolang/gnonative v1.0.1
)

require (
connectrpc.com/grpchealth v1.2.0 // indirect
connectrpc.com/grpcreflect v1.2.0 // indirect
github.com/btcsuite/btcd/btcec/v2 v2.3.3 // indirect
github.com/btcsuite/btcd/btcutil v1.1.5 // indirect
github.com/cenkalti/backoff/v4 v4.3.0 // indirect
github.com/cockroachdb/apd/v3 v3.2.1 // indirect
github.com/cosmos/ledger-cosmos-go v0.13.3 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.3.0 // indirect
github.com/gnolang/gno v0.0.0-20240429153043-de2fc456c1cd // indirect
github.com/gnolang/overflow v0.0.0-20170615021017-4d914c927216 // indirect
github.com/go-logr/logr v1.4.1 // indirect
github.com/go-logr/stdr v1.2.2 // indirect
github.com/golang/protobuf v1.5.4 // indirect
github.com/golang/snappy v0.0.4 // indirect
github.com/gorilla/websocket v1.5.1 // indirect
github.com/grpc-ecosystem/grpc-gateway/v2 v2.20.0 // indirect
github.com/libp2p/go-buffer-pool v0.1.0 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/rs/cors v1.10.1 // indirect
github.com/rs/xid v1.5.0 // indirect
github.com/stretchr/testify v1.9.0 // indirect
github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7 // indirect
github.com/zondax/hid v0.9.2 // indirect
github.com/zondax/ledger-go v0.14.3 // indirect
go.opentelemetry.io/otel v1.27.0 // indirect
go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetricgrpc v1.25.0 // indirect
go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetrichttp v1.27.0 // indirect
go.opentelemetry.io/otel/metric v1.27.0 // indirect
go.opentelemetry.io/otel/sdk v1.27.0 // indirect
go.opentelemetry.io/otel/sdk/metric v1.27.0 // indirect
go.opentelemetry.io/otel/trace v1.27.0 // indirect
go.opentelemetry.io/proto/otlp v1.2.0 // indirect
go.uber.org/multierr v1.11.0 // indirect
go.uber.org/zap v1.27.0 // indirect
golang.org/x/crypto v0.23.0 // indirect
golang.org/x/exp v0.0.0-20240222234643-814bf88cf225 // indirect
golang.org/x/mobile v0.0.0-20230531173138-3c911d8e3eda // indirect
golang.org/x/mod v0.16.0 // indirect
golang.org/x/net v0.25.0 // indirect
golang.org/x/sync v0.7.0 // indirect
golang.org/x/sys v0.20.0 // indirect
golang.org/x/text v0.15.0 // indirect
golang.org/x/tools v0.19.0 // indirect
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20240520151616-dc85e6b867a5 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240515191416-fc5f0ca64291 // indirect
google.golang.org/grpc v1.64.0 // indirect
google.golang.org/protobuf v1.34.1 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
moul.io/u v1.27.0 // indirect
)

replace github.com/gnolang/gno => ../../../
Loading

0 comments on commit 907101f

Please sign in to comment.