Skip to content

feat: add swap-size parameter for Wasm builds that need more memory#64

Open
georgeharker wants to merge 1 commit into
tree-sitter:mainfrom
georgeharker:add-swap-size-parameter
Open

feat: add swap-size parameter for Wasm builds that need more memory#64
georgeharker wants to merge 1 commit into
tree-sitter:mainfrom
georgeharker:add-swap-size-parameter

Conversation

@georgeharker
Copy link
Copy Markdown

Some grammars (e.g. tree-sitter-zsh) exceed available memory during Wasm compilation on GitHub Actions runners. Currently consumers work around this by maintaining local copies of release.yml and package-npm.yml with a swap resize step injected before the Wasm build — which means tracking upstream changes manually.

This PR adds an optional swap-size input to both workflows:

  • Default: normal — skips the resize entirely; no behaviour change for existing consumers.
  • Set to e.g. 64G — allocates that much swap before the Wasm build step.

Usage

# release.yml
jobs:
  release:
    uses: tree-sitter/workflows/.github/workflows/release.yml@main
    with:
      swap-size: 64G

# publish.yml
jobs:
  npm:
    uses: tree-sitter/workflows/.github/workflows/package-npm.yml@main
    with:
      swap-size: 64G

Changes

  • .github/workflows/release.yml - New swap-size input; conditional "Increase swap space" step before "Build Wasm binaries"
  • .github/workflows/package-npm.yml - Same — swap-size input and conditional swap step in the build_wasm job

Why not just fix the compiler?

This may become unnecessary if upstream changes decrease appetite for memory for wasm compiles. It's also likely that grammar optimization may help. However, this allows folks with issues to keep using the official treesitter workflows rather than having to copy and modify them.

Some grammars (e.g. tree-sitter-zsh) exceed available memory during Wasm
compilation on GitHub Actions runners.  Rather than forcing consumers to
maintain local copies of these workflows just to insert a swap resize
step, expose an optional `swap-size` input on the release and
package-npm workflows.

The default value `normal` skips the resize entirely, keeping existing
behaviour unchanged.  Setting it to a size like `64G` allocates that
much swap before the Wasm build step.
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