Skip to content

Commit 3c45b4e

Browse files
feat(test-suite): gw reliable benchmark (#923)
* chore(test-suite): add gw benchmarking cli * docs(test-suite): update README * fix(test-suite): error handling in bench * chore(test-suite): use http instead of ws
1 parent 3a16b97 commit 3c45b4e

13 files changed

Lines changed: 479 additions & 133 deletions

File tree

test-suite/gateway-stress/Cargo.lock

Lines changed: 22 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

test-suite/gateway-stress/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ aws-sdk-kms = { version = "1.79.0", default-features = true }
2222
aws-sdk-s3 = { version = "1.98.0", default-features = true }
2323
clap = { version = "4.5.38", features = ["cargo", "derive"] }
2424
config = { version = "0.15.13", default-features = false, features = ["toml"] }
25+
csv = { version = "1.3.1", default-features = false }
2526
futures = { version = "0.3.31", default-features = false }
2627
humantime = "2.2.0"
2728
humantime-serde = "1.1.1"

test-suite/gateway-stress/README.md

Lines changed: 54 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,28 @@
11
# Gateway Stress-Test Tool
22

3+
## Introduction
4+
35
A simple tool to send a configurable number of parallel decryption requests (public or user
46
decrypts at the time of writing), at a given frequency and for a specified duration.
57

8+
## Table of Contents
9+
- [Introduction](#introduction)
10+
- [Build](#build)
11+
- [Configuration](#configuration)
12+
- [Run](#run)
13+
- [Stress testing](#stress-testing)
14+
- [Benchmarking](#benchmarking)
15+
- [Tracing](#tracing)
16+
- [Bonus: Generating handles via coprocessor stress-test-generator](#bonus-generating-handles-via-coprocessor-stress-test-generator)
17+
18+
## Build
19+
20+
You can build the tool by running the `cargo build --release` command in the
21+
`test-suite/gateway-stress` directory.
22+
23+
Alternatively, you can run the manual `gateway-stress-tool-docker-build` workflow to trigger the
24+
build of the Docker images for the tool.
25+
626
## Configuration
727

828
To configure the tool, you can use either a configuration file (TOML format) or environment
@@ -13,16 +33,10 @@ along with its associated environment variable.
1333

1434
Configuration fields defined via environment variables override those in the configuration file.
1535

16-
## Build
17-
18-
You can build the tool by running the `cargo build --release` command in the
19-
`test-suite/gateway-stress` directory.
20-
21-
Alternatively, you can run the manual `gateway-stress-tool-docker-build` workflow to trigger the
22-
build of the Docker images for the tool.
23-
2436
## Run
2537

38+
### Stress testing
39+
2640
Once the `gateway-stress` binary has been built, you can run the following commands:
2741

2842
```bash
@@ -48,6 +62,28 @@ cargo run -- -c config/config.toml user
4862

4963
Note that the `mixed` command of the CLI is not implemented yet.
5064

65+
### Benchmarking
66+
67+
The `benchmark` command take a CSV file in input (and the global config file as well).
68+
Each line of this CSV represent a burst of decryption to benchmark, which is composed of:
69+
- The number of parallel requests in the burst (1st column)
70+
- The number of time we must measure this burst (2nd column)
71+
- The type of decryption in the burst (`public` or `user`)
72+
73+
See the [templates](./templates) folder for examples.
74+
75+
It will then run the benchmark and stores the results (average and standard deviation of latency
76+
and throughput) for each burst in a CSV file.
77+
78+
```bash
79+
# Run a benchmarking session using `templates/small_bench.csv` as input and store the global
80+
# results in `/tmp/bench.csv`
81+
./gateway-stress -c config/config.toml benchmark -i templates/small_bench.csv -o /tmp/bench.csv
82+
83+
# Same, but also store each burst result in `tmp/full.csv`
84+
./gateway-stress -c config/config.toml benchmark -i templates/small_bench.csv -o /tmp/bench.csv -r /tmp/full.csv
85+
```
86+
5187
## Tracing
5288

5389
This tool aims to output only essential information regarding the status of the test. The main
@@ -67,17 +103,23 @@ RUST_LOG="gateway_stress=debug,alloy=debug" ./gateway-stress -c config/config.to
67103
RUST_LOG="debug" ./gateway-stress -c config/config.toml public
68104
```
69105

70-
## Bonus: Generating handles via coprocessor-stress-test-generator
106+
## Bonus: Generating handles via coprocessor stress-test-generator
107+
108+
To use this tool, you would need already existing handles to decrypt. You could use coprocessor's
109+
`stress-test-generator` tool to generate these handles.
71110

72-
First clone the repo. Then, look at the `README.md` and gather all the environment variable values
73-
needed (default values work only for e2e setup).
111+
The tool is located at `coprocessor/fhevm-engine/stress-test-generator` in the `fhevm` repo.
112+
Then, look at the `README.md` and gather all the environment variable values needed (default
113+
values work only for e2e setup).
74114

75115
```bash
76-
git checkout simon/chore/fhevm-0.8.3
77116
export EVGEN_DB_URL="TODO"
78117
export ACL_CONTRACT_ADDRESS="TODO"
79118
# ...
80119
EVGEN_SCENARIO=data/minitest_003_generate_handles_for_decryption.csv make run
81120
```
82121

83122
This will generate the `data/handles_for_pub_decryption` and `handles_for_usr_decryption` files.
123+
124+
Make sure that the 6th column of the `EVGEN_SCENARIO` file match the `allowed_contract` value of
125+
this tool's configuration, and that the 7th column match the wallet address used by the tool.

test-suite/gateway-stress/config/config.toml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ decryption_address = "0xc9bAE822fE6793e3B456144AdB776D5A318CB71e"
1717
# The time during which the tool will send requests burst to the Gateway
1818
# Format documentation: https://docs.rs/humantime/latest/humantime/
1919
# ENV: TESTS_DURATION
20-
tests_duration = "10s"
20+
tests_duration = "500ms"
2121

2222
# If requests burst must be sent sequentially when the previous one has been completed
2323
# Defaults to false, if set to true, then `tests_interval` is ignored
@@ -37,14 +37,14 @@ parallel_requests = 5
3737
# ENV: USER_CT_HANDLES (format: comma separated list)
3838
# Example: USER_CT_HANDLES="0x408a1510fb9ebf45651a6b0d40ce34c52a4bfc6338ff00000000000030390500,0x408a1510fb9ebf45651a6b0d40ce34c52a4bfc6338ff00000000000030390500"
3939
user_ct_handles = [
40-
"0x7a88b93ad2e636eaba00eab25e3db6a39bb3965a2fff00000000000030390500",
40+
"0x7e314aadb1fe25d0eedc986529cf05604b71b717fdff00000000000030390500",
4141
]
4242

4343
# The handles used for public decryptions
4444
# ENV: PUBLIC_CT_HANDLES (format: comma separated list)
4545
# Example: PUBLIC_CT_HANDLES="0xbbb647e5a8dba46ed6f2eff8aed91d96ce9a80f537ff00000000000030390500,0xbbb647e5a8dba46ed6f2eff8aed91d96ce9a80f537ff00000000000030390500"
4646
public_ct_handles = [
47-
"0x1c7538f08f6054130981aca8a7d85896ca2a197067ff00000000000030390500",
47+
"0xcc0fe2694c954beeea00716b20dbff2f4aa3756afbff00000000000030390500",
4848
]
4949

5050
# The contract allowed for user decrytion on ct_handles
@@ -53,7 +53,7 @@ allowed_contract = "0xa5880e99d86F081E8D3868A8C4732C8f65dfdB08"
5353

5454
# Wallet's private key as a hex string (optional if `aws_kms_config` or `mnemonic` is configured)
5555
# ENV: PRIVATE_KEY
56-
private_key = "3f45b129a7fd099146e9fe63851a71646231f7743c712695f3b2d2bf0e41c774"
56+
private_key = "24af7cb5f6cd0f29df22c6f3e2f18ee5b3949f5a489a14b0674bef8fd89bfe91"
5757

5858
# Wallet's mnemonic (optional if `aws_kms_config` or `private_key` is configured)
5959
# ENV: MNEMONIC

0 commit comments

Comments
 (0)