Skip to content

[0.18] Memoize schemas in DynamicSchemaIndex compilation - #2026

Draft
kubukoz wants to merge 2 commits into
series/0.18from
dynamic-memoize-schemas-0.18
Draft

kubukoz wants to merge 2 commits into
series/0.18from
dynamic-memoize-schemas-0.18

Conversation

@kubukoz

@kubukoz kubukoz commented Nov 18, 2026

Copy link
Copy Markdown
Member

Backport of #2025 to series/0.18.

DynamicSchemaIndex.load didn't memoize the Eval[Schema] of each shape, so every reference to a shape re-ran the whole computation of its target. In models where shapes are referenced from multiple places this is exponential in the depth of the sharing. The fix .memoizes the schema stored for each shape. See #2025 for the full write-up and numbers (measured on 0.19, where the compiler code is the same): on a large production model with ~25k schemas, load went from ~7.2s to ~0.45s.

Differences from #2025:

  • SchemaSharingSpec matches Schema.OptionSchema(underlying), since OptionSchema has a single field on 0.18.
  • The changelog entry goes under 0.18.60.

🤖 Generated with Claude Code

kubukoz and others added 2 commits November 18, 2026 12:24
Each shape's schema was an un-memoized Eval chain, so every reference to
a shape re-ran the whole computation of its target. In models where
shapes are referenced from several places, this made loading exponential
in the depth of the sharing. Schemas are now computed once per shape and
shared.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

This branch has not been deployed

No deployments
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