-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(miri): slow tests & bitset sizes (#468)
Closes #466 ## Changes - Fix: Bitsets are now correctly-sized (were x8 larger than expected) - Fix: Unexpected panic when calling `Entities::create()` with a maxed-out bitset - Fix: Reduce Miri CI job runtime to <30 minutes - Fix: Warnings emitted by Miri - Fix: Update the workspace `rust-version` to match the `rust-toolchain.toml` file at 1.81 - Add: More bitset iterator tests (there will be a follow-up PR on this to organize them and simplify some that involve `Entities` unnecessarily) - Fix: Simplify test data, remove prints & `dbg!`s ## Explanation **Fix: Bitsets are now correctly-sized (were x8 larger than expected)** - Bitsets are `2^K` bits, and the number of `u32` arrays within them (which the docs now call "sectors") was previously calculated as `2^K / (32 * 8 / 8)`. The arrays are `32 * 8` bits meaning the array count should be calculated as `2^K / (32 * 8)`. - Added more docs to the `bitset` module. **Fix: Unexpected panic when calling `Entities::create()` with a maxed-out bitset** - Unexpected panic on `bit_set` when all bits are set in `alive` except for some in the last sector, but those all belong to killed entities. - It attempts to `bit_test` at index `BITSET_BITSIZE` which is an overflow. This was not noticed before due to the bitset actually being larger than the size const. **Fix: Reduce Miri CI job runtime to <30 minutes** - A full run pre-fix would likely take 12+ hours since it usually stops during seed 5/11, but it times-out at 6hrs. - Add a new feature set `miri` which is the same as `default` but with `keysize10` (where bitsets are 128 bytes). - Unfortunately this complicates the script that runs miri because the new feature is not usable when running the whole workspace (`cargo +nightly miri test --no-default-features -F miri` does not work). - The bash script now runs each crate separately with `-p`, and adds `--no-default-features -F miri` only for `bones_ecs`. - Moved bash script into its own file since it's now more complex.
- Loading branch information
Showing
13 changed files
with
491 additions
and
177 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
#!/usr/bin/env bash | ||
# | ||
# Run workspace tests with miri. | ||
# | ||
# This script is executed by the CI workflow in `.github/workflows/ci.yml`. Miri | ||
# must be run with a nightly toolchain, but the workflow configures this with a | ||
# rustup override rather than using rustup's `+toolchain` on the CLI. To run | ||
# this script locally use the rustup env var: | ||
# | ||
# RUSTUP_TOOLCHAIN=nightly ./github/miri-test.sh | ||
# | ||
# The number of seed runs can also be configured with the `NUM_SEEDS` env var: | ||
# | ||
# NUM_SEEDS=1 RUSTUP_TOOLCHAIN=nightly ./github/miri-test.sh | ||
# | ||
|
||
line() { | ||
printf -- "${1}%0.s" $(seq "$2") | ||
printf '\n' | ||
} | ||
|
||
header() { | ||
line "$1" "$2" | ||
echo "$3" | ||
line "$1" "$2" | ||
} | ||
|
||
get_default_workspace_members() { | ||
cargo metadata --quiet --no-deps \ | ||
| sed -nE 's/.*"workspace_default_members":\[([^]]+)\].*/\1/p' \ | ||
| tr ',' '\n' | awk -F/ '{print gensub(/([^#]+).*/, "\\1", 1, $NF)}' | ||
} | ||
|
||
# The maximum number of seeds with which to run the tests | ||
[ -z "$NUM_SEEDS" ] && NUM_SEEDS=10 | ||
|
||
# The crates to test | ||
declare -a CRATES | ||
|
||
# Extra flags to pass to `cargo test` for crates | ||
declare -A FLAGS | ||
|
||
CRATES=( $(get_default_workspace_members) ) | ||
FLAGS[bones_ecs]='--no-default-features -F miri' | ||
|
||
# Try multiple seeds to catch possible alignment issues | ||
for SEED in $(seq "$NUM_SEEDS"); do | ||
export MIRIFLAGS="-Zmiri-seed=$SEED" | ||
|
||
echo | ||
header '#' 80 "MIRI TEST WORKSPACE" | ||
echo | ||
|
||
for (( i=0; i<${#CRATES[@]}; i++ )); do | ||
NAME="${CRATES[i]}" | ||
header '-' 70 "TEST CRATE: $NAME (seed $SEED/$NUM_SEEDS, crate $(( i+1 ))/${#CRATES[@]})" | ||
echo | ||
eval "cargo miri test --package $NAME ${FLAGS[$NAME]}" || { echo "Failing seed: $SEED"; exit 1; }; | ||
done | ||
done |
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
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
Oops, something went wrong.