Skip to content

Perf/test time - #148

Merged
REALAZK merged 2 commits into
ootrando:nightlyfrom
OnticoDev:perf/test-time
Nov 26, 2026
Merged

REALAZK merged 2 commits into
ootrando:nightlyfrom
OnticoDev:perf/test-time

Conversation

@OnticoDev

Copy link
Copy Markdown
Collaborator

Faster test suite (and faster mod builds)

The full test run with the game tests on had grown to about 12 minutes, around 20 minutes with the compile. This PR roughly halves the test run. I'd like your thoughts before it goes in, especially on the two questions at the end.

Numbers

Measured with cargo test --workspace --profile ci, OOTRR_ROMFS set, on a 6-core Windows machine.

Before After
Full test run 742 s 349 s
Core tests 663 s 315 s
Cosmetics tests 71 s 27 s
Results 2436 passed 2436 passed

Slowest tests, seconds inside the full run:

Test Before After
seed_packs::key_items_at_every_spot_class_... 273 128
frost::a_seed_with_them_builds 212 98
door_open::every_build_carries_the_pedestal_fix_... 192 82
fire_gorons::the_boss_key_chest_is_unlocked_in_full_builds 163 63

What was slow

About 100 of the 2400 tests take 85% of the time. Nearly all of them build a whole mod. Two things made each build slow.

1. The BYML writer. Writing a BYML took 17 times longer than reading it (ActorInfo: 308 ms to write, 18 ms to read). Every pickup pack in a seed rewrites the three actor tables, one pack after another, so a wide seed spent most of its build time in the writer. Two parts of byml.rs did most of it:

  • Finding repeated containers serialized every subtree once for each of its ancestors. Now each container gets a shape id once, bottom up. The ids are equal exactly when the old byte keys were equal, so the writer makes the same sharing decisions.
  • Sorting map keys built a new folded key on every comparison. The sort now compares the folded characters without allocating. It uses the same comparison, so the order is the same.

Strings are also borrowed instead of cloned. ActorInfo now writes in 77 ms.

2. The Windows system allocator. With 12 tests building at once, the heavy tests ran about 3 times slower than alone. The core and cosmetics test binaries now use mimalloc. On 24 of the heaviest tests that took the run from 278 s to 176 s. It is a dev-dependency behind cfg(test), so the shipped builds and the wasm build do not change.

The sfx bank test also builds its two seeds on two threads now instead of one after the other.

What this changes outside the tests

Seed generation (placement, logic, the seed file) is untouched.

The BYML writer is used when a mod is built, so that part does run for players. It produces the same bytes, which I checked two ways:

  • Every BYML in the game, 148,727 files in 10,453 packs, writes back the same with the old and the new writer. Nine files don't round-trip to their original game bytes, and that is unchanged from before.
  • Five preset seeds (default, easy, full_shuffle, keysanity, open_world) build mod folders that are byte for byte the same as before.

Because of the writer change, builds are faster for players too: a default seed takes 20 s instead of 33 s, and Full Shuffle 50 s instead of 78 s.

Checklist

  • Release build has no warnings
  • Full tests pass with the game tests on (2436 passed, 0 failed)
  • No settings added or changed
  • Not tested in the game. The built mods are byte for byte the same as before, so there is nothing new to see in the game.

Questions for reviewers

  1. Is a new dev-dependency (mimalloc, with libmimalloc-sys and cc) OK? Without it the suite still gets about 25% faster from the writer alone.
  2. Should the shipped ootrr binary use mimalloc too? A single seed build went from 48 s to 30 s with it. I left it out because it changes the release build.

Happy to split the writer change and the test changes into separate PRs if that is easier to review.

Writing a BYML took 17 times longer than reading it. The writer found
repeated containers by serializing every subtree once per ancestor, and
sorted map keys by building a new folded key on every comparison.

Containers now get a shape id once, bottom up, and the sort compares the
folded keys without allocating. Strings are borrowed instead of cloned.

ActorInfo writes in 77 ms instead of 308 ms. Every BYML in the game
(148,727 of them) writes back the same as with the old writer, and five
preset seeds build byte for byte the same mods. A default seed builds in
20 s instead of 33 s and Full Shuffle in 50 s instead of 78 s.
The core and cosmetics test binaries use mimalloc. The system allocator
on Windows slows down when many tests allocate at once: 24 of the
heaviest tests took 278 s with it and 176 s with mimalloc. It is a
dev-dependency behind cfg(test), so the shipped builds do not change.

The sfx bank test builds its two seeds on two threads.
@REALAZK
REALAZK merged commit ac2c244 into ootrando:nightly Nov 26, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants