Repository navigation
perf(core): reduce JSON shape validation allocations - #230
Merged
Merged
Conversation
Lojhan
marked this pull request as ready for review
October 29, 2026 00:31
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.
JSON result guards allocate callbacks while recursively checking arrays, tuples and unions. Replace those callbacks with loops that retain the previous short-circuit order, captured lengths and absent-index handling. The preceding finite JSON validation pass and all shape, depth and value-count checks remain unchanged.
A separate SQLite allocation run on Apple M3 Pro / Node 24.11.1 sampled 26.5% fewer allocated bytes for compiled JSON queries and 30.1% fewer for parsed-policy SQL-file queries (5,000 calls each). Matched ordinary timing trials do not establish a latency improvement: compiled JSON is 25.93 → 25.79 µs while raw/Reylo controls drift slightly slower. No claim of closing the Reylo latency gap.
The evidence directory preserves raw timings, compressed V8 heap profiles, source/patch identities, methodology and a derived summary. Only the JSON validator changes production behavior; there is no new API or dependency.
Validation: full
pnpm verifypassed, including package tests and coverage, TypeScript builds, packed-consumer/editor contracts, documentation build, and performance/soak budgets. GitHub CI and CodeQL passed, including packed real-database consumers and packaged editor tests on Linux, macOS and Windows. The first source-quality attempt failed the unchanged editor schema-churn p99 budget (454.88 ms against 120 ms); one clean retry of the same source passed at 12.71 ms. No code or budget changes were made to obtain that retry result. CI evidence: https://github.com/Lojhan/typed-sql/actions/runs/40793109552/attempts/2.