Conversation
🦋 Changeset detectedLatest commit: 3cb8c6c The changes in this PR will be included in the next version bump. This PR includes changesets to release 30 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Contributor
Bundle Size AnalysisGenerated from PR build output; treat the content below as untrusted.
|
gcanti
force-pushed
the
schema-compiler
branch
2 times, most recently
from
September 7, 2026 06:51
035d2b3 to
3ab7d8a
Compare
gcanti
force-pushed
the
schema-compiler
branch
3 times, most recently
from
September 11, 2026 17:33
b1330e5 to
d303cc6
Compare
gcanti
force-pushed
the
schema-compiler
branch
from
September 14, 2026 07:21
241f340 to
193b9ce
Compare
gcanti
force-pushed
the
schema-compiler
branch
from
September 16, 2026 04:06
f21da9b to
5e9f0de
Compare
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.
Summary
Optimizes the Effect Schema interpreter and adds experimental JIT and AOT compilers. All three modes use the existing SchemaParser APIs and remain composable.
Usage
Enable lazy JIT compilation for the application:
Or enable one AST and its dependencies:
Generate and install AOT decoders:
Import the generated module at application startup. Decoding is included by default; encode, is, and make roots are opt-in. SchemaAOTCompiler.compile(targets) provides the lower-level source-generation API.
Design
The interpreter, JIT, AOT, and manually installed decoders share one registry keyed by AST identity. JIT compiles lazily and falls back to the interpreter when dynamic function construction is unavailable or compilation fails. AOT uses the same code generator without new Function, emits only the requested operations and their transitive dependencies, and shares decoder factories that generate identical code. Transformations and middleware run once.
Performance
Median time per operation on Node 24.12.0, V8 13.6, Apple M3. Measurements use five isolated rounds, 100 ms warmup, 300 ms measurement, and shared batch sizes. Effect uses public SchemaParser APIs. Valibot 1.5.0 uses parse and is. Zod 4.6.2 uses parse and validate with { jitless: true }, or z.compile(schema, { strict: true }). Lower is better. Bold values are within 5% of the fastest result in each row.
Interpreted
Compiled
Paired runs against main found no interpreter regressions. The 32-field transformation improved by 19.5%, and the invalid Moltar guard improved by 8%.
The construction rows are reference comparisons. Effect uses SchemaParser.make, while Valibot and Zod parse equivalent schemas because they have no separate construction API.
Zod compilation has no comparable result for trailing-rest tuples, strict oneOf, middleware, or recursive schemas.
Resource costs
Incremental costs are median per-schema slopes between 100 and 500 distinct schemas across five fresh-process rounds. Lower is better. Retained heap includes schemas, public parsers, and their runtime state. Fixed module imports and fixture inputs are excluded. Importing the JIT compiler retains about 118 KiB of additional fixed heap in this source-tree setup.
Preparation CPU includes adapter creation and the first call. AOT also includes importing and installing the generated module, but excludes build-time generation. Generated AOT source is operation-specific: 2.07 KiB/schema for Struct decode, 0.62 KiB/schema for guards, 2.90 KiB/schema for an Array of 32 Structs, 28.24 KiB/schema for 32 transformations, and 11.67 KiB/schema for 32-default construction. Sharing identical decoder factories and omitting unused dependency fast paths reduce an eight-member discriminated Union from 17.72 to 5.46 KiB/schema.
Retained JavaScript heap
Runtime preparation CPU
Bundle size
Across 15 stable Schema fixtures, the branch adds 0.25 to 0.44 KB gzip, averaging 0.33 KB.
Constraints
Detailed architecture, compatibility, memory, and benchmark notes are in packages/effect/SCHEMA.md.
Verification