-
Notifications
You must be signed in to change notification settings - Fork 3.8k
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
R4R: Multi-seed parallel simulation #2313
Merged
Merged
Changes from 7 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
82a5655
Add PENDING.md
cwgoes 13a3642
Merge branch 'develop' into cwgoes/multi-seed-parallel-sim
cwgoes e97a7f0
Very basic goroutines
cwgoes c22af29
Merge branch 'develop' into cwgoes/multi-seed-parallel-sim
cwgoes bad2f1b
Multi-seed through bash script
cwgoes 411862c
Merge branch 'develop' into cwgoes/multi-seed-parallel-sim
cwgoes e918760
Kill simulations on exit, more useful help messages
cwgoes 3e2d84c
Split line for clarity
cwgoes File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
#!/bin/bash | ||
|
||
seeds=(1 2 4 7 9 20 32 123 4728 37827 981928 87821 891823782 989182 89182391) | ||
|
||
echo "Running multi-seed simulation with seeds: ${seeds[@]}" | ||
echo "Edit scripts/multisim.sh to add new seeds. Keeping parameters in the file makes failures easy to reproduce." | ||
echo "This script will kill all sub-simulations on SIGINT/SIGTERM/EXIT (i.e. Ctrl-C)." | ||
|
||
trap 'kill $(jobs -pr)' SIGINT SIGTERM EXIT | ||
|
||
tmpdir=$(mktemp -d) | ||
echo "Using temporary log directory: $tmpdir" | ||
|
||
sim() { | ||
seed=$1 | ||
echo "Running full Gaia simulation with seed $seed. This may take awhile!" | ||
file="$tmpdir/gaia-simulation-seed-$seed-date-$(date -Iseconds -u).stdout" | ||
echo "Writing stdout to $file..." | ||
go test ./cmd/gaia/app -run TestFullGaiaSimulation -SimulationEnabled=true -SimulationNumBlocks=1000 -SimulationVerbose=true -SimulationCommit=true -SimulationSeed=$seed -v -timeout 24h > $file | ||
} | ||
|
||
i=0 | ||
pids=() | ||
for seed in ${seeds[@]}; do | ||
sim $seed & | ||
pids[${i}]=$! | ||
i=$(($i+1)) | ||
sleep 0.1 # start in order, nicer logs | ||
done | ||
|
||
echo "Simulation processes spawned, waiting for completion..." | ||
|
||
code=0 | ||
|
||
i=0 | ||
for pid in ${pids[*]}; do | ||
wait $pid | ||
last=$? | ||
if [ $last -ne 0 ]; then | ||
seed=${seeds[${i}]} | ||
echo "Simulation with seed $seed failed!" | ||
code=1 | ||
fi | ||
i=$(($i+1)) | ||
done | ||
|
||
exit $code |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we break this command on multi-lines with
\
to make it easier to read?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, done.