Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Matching simulation comparison tool #6287

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ test_eventsV2.log
test_eventsV2_xdc
test_eventsV2_xdc.log
matching-simulator-output/
simulation_comparison.csv

# Executables produced by cadence repo
/cadence
Expand Down
1 change: 1 addition & 0 deletions codecov.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,3 +70,4 @@ ignore:
- "testflags/**"
- "tools/common/schema/test/**"
- "tools/linter/**"
- "tools/matchingsimulationcomparison/**"
9 changes: 6 additions & 3 deletions host/matching_simulation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,15 @@
/*
To run locally:

1. Change the matchingconfig in host/testdata/matching_simulation.yaml as you wish
1. Pick a scenario from the existing config files host/testdata/matching_simulation_.*.yaml or add a new one

2. Run `./scripts/run_matching_simulator.sh`
2. Run the scenario
`./scripts/run_matching_simulator.sh default`

Full test logs can be found at test.log file. Event json logs can be found at matching-simulator-output.json.
Full test logs can be found at test.log file. Event json logs can be found at matching-simulator-output folder.
See the run_matching_simulator.sh script for more details about how to parse events.

If you want to run all the scenarios and compare them refer to tools/matchingsimulationcomparison/README.md
*/
package host

Expand Down
4 changes: 2 additions & 2 deletions host/testdata/matching_simulation_default.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ matchingconfig:
forwardermaxoutstandingtasks: 1
forwardermaxratepersecond: 10
forwardermaxchildrenpernode: 20
localpollwaittime: 0ms
localtaskwaittime: 0ms
localpollwaittime: 10ms
localtaskwaittime: 10ms
tasks:
- numtaskgenerators: 2
taskspersecond: 80
Expand Down
4 changes: 2 additions & 2 deletions host/testdata/matching_simulation_more_read_partitions.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ matchingconfig:
forwardermaxoutstandingtasks: 1
forwardermaxratepersecond: 10
forwardermaxchildrenpernode: 20
localpollwaittime: 0ms
localtaskwaittime: 0ms
localpollwaittime: 10ms
localtaskwaittime: 10ms
tasks:
- numtaskgenerators: 2
taskspersecond: 80
Expand Down
6 changes: 3 additions & 3 deletions host/testdata/matching_simulation_no_forwarding.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ matchingconfig:
forwardermaxoutstandingtasks: 0
forwardermaxratepersecond: 10
forwardermaxchildrenpernode: 20
localpollwaittime: 0ms
localtaskwaittime: 0ms
localpollwaittime: 10ms
localtaskwaittime: 10ms
tasks:
- numtaskgenerators: 2
taskspersecond: 80
Expand All @@ -25,4 +25,4 @@ matchingconfig:
numpollers: 8
polltimeout: 60s
workerconfig:
enableasyncwfconsumer: false
enableasyncwfconsumer: false
28 changes: 28 additions & 0 deletions host/testdata/matching_simulation_no_wait_time_for_addtask.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
enablearchival: false
clusterno: 1
messagingclientconfig:
usemock: true
historyconfig:
numhistoryshards: 4
numhistoryhosts: 1
matchingconfig:
nummatchinghosts: 4
simulationconfig:
tasklistwritepartitions: 4
tasklistreadpartitions: 4
forwardermaxoutstandingpolls: 1
forwardermaxoutstandingtasks: 1
forwardermaxratepersecond: 10
forwardermaxchildrenpernode: 20
localpollwaittime: 10ms
localtaskwaittime: 0ms
tasks:
- numtaskgenerators: 2
taskspersecond: 80
maxtasktogenerate: 3000
pollers:
- taskprocesstime: 1ms
numpollers: 8
polltimeout: 60s
workerconfig:
enableasyncwfconsumer: false
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
enablearchival: false
clusterno: 1
messagingclientconfig:
usemock: true
historyconfig:
numhistoryshards: 4
numhistoryhosts: 1
matchingconfig:
nummatchinghosts: 4
simulationconfig:
tasklistwritepartitions: 4
tasklistreadpartitions: 4
forwardermaxoutstandingpolls: 1
forwardermaxoutstandingtasks: 1
forwardermaxratepersecond: 10
forwardermaxchildrenpernode: 20
localpollwaittime: 0ms
localtaskwaittime: 10ms
tasks:
- numtaskgenerators: 2
taskspersecond: 80
maxtasktogenerate: 3000
pollers:
- taskprocesstime: 1ms
numpollers: 8
polltimeout: 60s
workerconfig:
enableasyncwfconsumer: false
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
enablearchival: false
clusterno: 1
messagingclientconfig:
usemock: true
historyconfig:
numhistoryshards: 4
numhistoryhosts: 1
matchingconfig:
nummatchinghosts: 4
simulationconfig:
tasklistwritepartitions: 4
tasklistreadpartitions: 4
forwardermaxoutstandingpolls: 1
forwardermaxoutstandingtasks: 1
forwardermaxratepersecond: 10
forwardermaxchildrenpernode: 20
localpollwaittime: 0ms
localtaskwaittime: 0ms
tasks:
- numtaskgenerators: 2
taskspersecond: 80
maxtasktogenerate: 3000
pollers:
- taskprocesstime: 1ms
numpollers: 8
polltimeout: 60s
workerconfig:
enableasyncwfconsumer: false
4 changes: 2 additions & 2 deletions host/testdata/matching_simulation_throughput.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ matchingconfig:
forwardermaxoutstandingtasks: 1
forwardermaxratepersecond: 10
forwardermaxchildrenpernode: 20
localpollwaittime: 0ms
localtaskwaittime: 0ms
localpollwaittime: 10ms
localtaskwaittime: 10ms
tasks:
- numtaskgenerators: 2
taskspersecond: 80
Expand Down
4 changes: 2 additions & 2 deletions host/testdata/matching_simulation_zonal_isolation.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ matchingconfig:
forwardermaxoutstandingtasks: 1
forwardermaxratepersecond: 10
forwardermaxchildrenpernode: 20
localpollwaittime: 0ms
localtaskwaittime: 0ms
localpollwaittime: 10ms
localtaskwaittime: 10ms
tasks:
- numtaskgenerators: 2
taskspersecond: 80
Expand Down
9 changes: 6 additions & 3 deletions scripts/run_matching_simulator.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,22 @@ set -eo pipefail

testCase="${1:-default}"
testCfg="testdata/matching_simulation_$testCase.yaml"
testName="test-$testCase-$(date '+%Y-%m-%d-%H-%M-%S')"
now="$(date '+%Y-%m-%d-%H-%M-%S')"
timestamp="${2:-$now}"
testName="test-$testCase-$timestamp"
resultFolder="matching-simulator-output"
mkdir -p "$resultFolder"
eventLogsFile="$resultFolder/events.json"
testSummaryFile="$resultFolder/$testName-summary.txt"


echo "Building test image"
docker-compose -f docker/buildkite/docker-compose-local-matching-simulation.yml \
build matching-simulator

echo "Running the test $testCase"
docker-compose \
-f docker/buildkite/docker-compose-local-matching-simulation.yml \
run -e MATCHING_SIMULATION_CONFIG=$testCfg --rm matching-simulator \
run -e MATCHING_SIMULATION_CONFIG=$testCfg --rm --remove-orphans matching-simulator \
| grep -a --line-buffered "Matching New Event" \
| sed "s/Matching New Event: //" \
| jq . > "$eventLogsFile"
Expand Down Expand Up @@ -187,5 +188,7 @@ cat "$eventLogsFile" \
| jq -c '.' | sort -n | uniq -c | sed -e 's/^/ /' | tee -a $testSummaryFile


echo "End of summary" | tee -a $testSummaryFile

printf "\nResults are saved in $testSummaryFile\n"
printf "For further analysis, please check $eventLogsFile via jq queries\n"
17 changes: 17 additions & 0 deletions tools/matchingsimulationcomparison/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@

This tool runs a set of matching simulation tests, extracts stats from their output and generates a csv to compare them easily.

Note: The parsing logic might break in the future if the `run_matching_simulator.sh` starts spitting different shaped lines. Alternative is to load all the event logs into a sqlite table and then run queries on top instead of parsing outputs of jq in this tool.


Run all the scenarios and compare:
```
go run tools/matchingsimulationcomparison/*.go --out simulation_comparison.csv
```

If you have already run some scenarios before and made changes in the output/comparison then run in Compare mode
```
go run tools/matchingsimulationcomparison/*.go --out simulation_comparison.csv \
--ts 2024-09-12-18-16-44 \
--mode Compare
```
Loading
Loading