Skip to content

perf(codegen): preload assets in parallel using rayon#252

Draft
aspizu wants to merge 1 commit intomainfrom
perf/parallel-asset-preload
Draft

perf(codegen): preload assets in parallel using rayon#252
aspizu wants to merge 1 commit intomainfrom
perf/parallel-asset-preload

Conversation

@aspizu
Copy link
Owner

@aspizu aspizu commented Mar 18, 2026

Summary

Collect all unique asset paths (costumes + sounds) from the entire project upfront, before zip writing begins, and read + MD5-hash them concurrently via rayon::par_iter().

Subsequent load() calls during codegen just hit the pre-populated cache with zero I/O or hashing cost.

Changes

  • Cargo.toml: add rayon as a native-only dependency (excluded from WASM targets)
  • src/codegen/assets.rs: add AssetObjectStore::preload() method (cfg non-wasm32) that parallelises file reads and MD5 hashing
  • src/codegen/sb3.rs: call preload() at the start of Sb3::project() with all deduplicated asset paths

Effect

On projects with many assets the wall-clock compile time is reduced proportionally to the number of CPU cores available, since file I/O and hashing previously ran serially.

Collect all unique asset paths (costumes + sounds) upfront before
zip writing begins and hash them concurrently via rayon::par_iter().
Subsequent load() calls hit the pre-populated cache with no I/O or
MD5 cost, reducing compile time on asset-heavy projects.
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.

1 participant