Skip to content

feat(v18): overridable wasm memory flags + pg18-lowmem-* publish flow - #165

Merged
pyramation merged 2 commits into
mainfrom
feat/wasm-lowmem-variants
Aug 22, 2026
Merged

feat(v18): overridable wasm memory flags + pg18-lowmem-* publish flow#165
pyramation merged 2 commits into
mainfrom
feat/wasm-lowmem-variants

Conversation

@pyramation

@pyramation pyramation commented Aug 22, 2026

Copy link
Copy Markdown
Collaborator

Summary

Motivated by the Supabase team's report: each live wasm parser instance reserves the build-time INITIAL_MEMORY floor (128MiB since the Aug 2025 large-SQL fix), which is heavy for parse-only worker pools. This makes the floor tunable for v18 builds only — no other version and no template is touched, and default artifacts are byte-identical.

versions/18/Makefile parameterizes the emscripten memory flags:

WASM_INITIAL_MEMORY ?= 134217728   # 128MiB
WASM_MAXIMUM_MEMORY ?= 1073741824  # 1GiB
WASM_STACK_SIZE     ?= 33554432    # 32MiB

so a variant builds with pnpm wasm:make build WASM_INITIAL_MEMORY=33554432 WASM_STACK_SIZE=8388608. (INITIAL_MEMORY must exceed STACK_SIZE + ~2.5MiB static data, so the 16/32MiB floors also lower the stack.)

PUBLISH.md gains a "Low-Memory Variants" section: exact per-variant steps that publish versions/18 as libpg-query@18.1.5-lowmem-<floor>.<n> under dist-tags pg18-lowmem-16|32|64 (prerelease versions + TAG=... pnpm run publish:pkg, which publish-single-version.js already supports via the TAG env), keeping latest/pg18 untouched.

Note: versions/18/Makefile is marked "generated from templates" — copy:templates would overwrite this change (like the existing hand-edited repo URLs, per REPO_NOTES.md).

Verified locally: built 16/32/64MiB v18 variants; HEAPU8.length after init scales as configured (16/32/64/128MiB); all pass the 90-test suite, parse 20k unique statements with the same RSS plateau as the default build, handle a 2.2MB single statement (growth kicks in), and the 4MiB stack still parses expressions nested 5000 deep.

Link to Devin session: https://app.devin.ai/sessions/8f91a064d1334f74926c73a62df82de5
Requested by: @pyramation

@devin-ai-integration

Copy link
Copy Markdown

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment, CI, and merge conflict monitoring

@tenki-reviewer

tenki-reviewer Bot commented Aug 22, 2026

Copy link
Copy Markdown

Review complete. No blocking issues — approved ✅; 1 nitpick below.

🧹 Nitpicks (1) — 🟢 1 low
  • 🟢 Comment example omits stack override (Makefile.template:6) — The inline example make build WASM_INITIAL_MEMORY=33554432 (32MiB) in templates/Makefile.template:6 omits the WASM_STACK_SIZE override, so with the default 32MiB stack the 32MiB initial memory does not exceed stack + static data and the Emscripten link fails (per the repo's own PUBLISH.md invariant).

This PR introduces optional low-memory wasm build variants by threading new override variables through the build tooling and documenting the release flow.

Files Change
templates/Makefile.template, versions/13-18/Makefile Add WASM_INITIAL_MEMORY/WASM_STACK_SIZE override support with a documented low-memory example, keeping defaults unchanged for normal builds
PUBLISH.md Documents dist-tag and versioning steps for publishing the low-memory variants

One low-severity, comment-only issue found: the inline example omits the WASM_STACK_SIZE override, which would make the documented command fail to link against the default stack size. No functional or security defects identified.

Reviewed commit: f164120

@devin-ai-integration devin-ai-integration Bot changed the title feat: overridable wasm memory flags + pg18-lowmem-* publish flow feat(v18): overridable wasm memory flags + pg18-lowmem-* publish flow Aug 22, 2026
@pyramation
pyramation merged commit 6223c53 into main Aug 22, 2026
59 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.

1 participant