Repository navigation
Conversation
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Completed standalone scanners retain their Wasm input allocation and the largest patch-buffer capacity until disposal or garbage collection. Applications that keep finished scanners for their values or field queries continue to hold that scratch space.
Release the Wasm input buffer on finalization and shrink unused patch capacity after successful validation. The parser handle, final patches, values, and field queries remain usable, including repeated
finish()calls and trailing-whitespace pushes. The runtime change is two Rust lines plus the regenerated embedded Wasm; no JavaScript API changes.Added a memory regression test that fails on main and lifecycle tests for numeric completion patches, snapshot modes, repeated operations, and terminal errors. Added a reproducible
bench:finished-memorycommand.Memory validation
Compared with main at
3965515, retaining 32 completed scanners with 2,000 nested records each (219,790 bytes per input):Both live and immutable modes produced these results. The metric is Wasm linear-memory high-water allocation, not JS heap or process RSS. Pooled readers already dispose completed parsers; the retained-memory benefit applies to standalone scanners kept alive after
finish().Environment: Node 23.11.0, macOS arm64, Apple M1. Three alternating trials per implementation, snapshot mode, and delivery size, each in a fresh process with zero warmups. The p95 is the maximum of the three trials. The benchmark checks final values, field queries, and subsequent operations.
Validation
pnpm check: 199 JavaScript tests, 11 Rust tests, type/syntax checks, formatting and clippy.pnpm pack:check.pnpm test:browserwith the documented installed-Chrome override.pnpm bench:finished-memory /tmp/streamfold-finished-buffers-baseline-3965515/packages/core/src/index.js.pnpm benchandpnpm bench:sdk.Also combined this branch with #94 in an isolated test copy: all 123 core tests passed. The PRs remain independent changes based on main.