Skip to content

Reuse Ruby builds when static gem extensions are unchanged - #669

Draft
ledsun wants to merge 1 commit into
ruby:mainfrom
ledsun:cache-static-gem-extensions
Draft

ledsun wants to merge 1 commit into
ruby:mainfrom
ledsun:cache-static-gem-extensions

Conversation

@ledsun

@ledsun ledsun commented Oct 17, 2026

Copy link
Copy Markdown
Contributor

rake npm:ruby-head-wasm-wasi currently forces a Ruby rebuild on every run, repeating linking and Asyncify even when the statically linked gem extensions have not changed.

Add an ExtensionCache that uses the existing extension cache_key methods and stores the input hash beside the Ruby archive. Reuse the archive when the hash matches, and remove the unconditional --remake from npm packaging. Explicit --remake, --reconfigure, and --clean still force a build.

Invalidate the previous record before building, and save a new record only after a successful build whose extension inputs stayed unchanged. Existing archives with extensions but no record are rebuilt once; archives without extra extensions retain their existing reuse behavior. Ruby source, compiler, and build-setting changes still require a manual rebuild.

Validation

  • Extension cache tests: 8 tests, 13 assertions passed.
  • bundle exec steep check: passed.
  • Concrete ruby-head-wasm-wasi package built successfully. With BINARYEN_CORES=1, a rebuilding run took 3m52.19s and a repeated run took 46.78s; both Ruby packaging invocations reused the archive on the repeated run.
  • Generated Wasm unit tests: both runs passed 68 tests and 371 assertions.
  • Vitest: 44 tests across 7 files passed.
  • Browser E2E was not run.

This branch has not been deployed

No deployments
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