Skip to content

perf(core): reduce JSON shape validation allocations - #230

Merged
Lojhan merged 2 commits into
mainfrom
perf/json-shape-traversal
Oct 29, 2026
Merged

Lojhan merged 2 commits into
mainfrom
perf/json-shape-traversal

Conversation

@Lojhan

@Lojhan Lojhan commented Oct 29, 2026 •

Copy link
Copy Markdown
Owner

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 verify passed, 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.

@Lojhan
Lojhan marked this pull request as ready for review October 29, 2026 00:31
@Lojhan
Lojhan enabled auto-merge (squash) October 29, 2026 01:05
@Lojhan
Lojhan merged commit bc4068e into main Oct 29, 2026
22 checks passed
@Lojhan
Lojhan deleted the perf/json-shape-traversal branch October 29, 2026 01:11
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