Skip to content

perf: Assign dereferenced schemas to local vars - #1139

Merged
jbelkins merged 6 commits into
mainfrom
jbe/schema_local_vars
Aug 7, 2026
Merged

perf: Assign dereferenced schemas to local vars#1139
jbelkins merged 6 commits into
mainfrom
jbe/schema_local_vars

Conversation

@jbelkins

@jbelkins jbelkins commented Aug 5, 2026

Copy link
Copy Markdown
Collaborator

Description of changes

In struct & union serialize / deserialize codegen, dereferenced schemas are assigned to local variables before being captured in consumer blocks. This reduces the amount of work that has to be done in the block versus the current approach, which is to chain long references together.

Variable names are appended with a depth so that nested collections don't shadow the enclosing collection's schema and use the wrong one for serde of the inner collection

In testing, I see measurable performance gains when deserializing nested collections. For simple structures, performance remains largely unchanged.

Tests are added for deeply nested serde as well. Tests are JSON-only since they are primarily intended to test code generation, not any particular encoding.

Scope

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@jbelkins
jbelkins marked this pull request as ready for review August 5, 2026 21:12
@jbelkins
jbelkins requested a review from a team as a code owner August 5, 2026 21:12
@jbelkins
jbelkins requested a review from sichanyoo August 5, 2026 21:22
@jbelkins
jbelkins merged commit d1cb61d into main Aug 7, 2026
45 checks passed
@jbelkins
jbelkins deleted the jbe/schema_local_vars branch August 7, 2026 21:52
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.

2 participants