Split deserializer constructor to avoid JVM code-too-large error#601
Open
nikhil-zlai wants to merge 1 commit intolinkedin:masterfrom
Open
Split deserializer constructor to avoid JVM code-too-large error#601nikhil-zlai wants to merge 1 commit intolinkedin:masterfrom
nikhil-zlai wants to merge 1 commit intolinkedin:masterfrom
Conversation
When a schema has many fields with distinct complex types (e.g., 1000+ fields each containing a unique record type in a union), the generated FastDeserializer constructor can exceed the JVM's 64KB method bytecode limit, causing a "code too large" compilation error. The existing method-splitting logic (populate_ helpers) only applies to the deserialization methods, not the constructor. This change applies the same splitting pattern to the constructor: every 500 schema variable declarations, a new initSchemaFields_N() helper method is created, and the constructor delegates to these helpers. Changes: - Add SCHEMA_VARS_PER_CONSTRUCTOR_METHOD constant (500) - Track constructor body separately to redirect assignments to helpers - Drop FINAL modifier on schema fields to allow assignment in helpers - Add test with 1000 fields × 5 sub-fields of distinct record types
nikhil-zlai
added a commit
to zipline-ai/chronon
that referenced
this pull request
Mar 24, 2026
LinkedIn's fastserde generates a deserializer constructor that exceeds JVM's 64KB method bytecode limit for schemas with many distinct complex fields (e.g., 1000+ fields each with a unique record type). This causes runtime compilation failure and a TimeoutException in the fetcher. Vendor a patched build of avro-fastserde (0.4.39-SNAPSHOT) that splits the constructor into initSchemaFields_N() helper methods every 500 schema variables, mirroring the existing populate_ splitting pattern. Upstream PR: linkedin/avro-util#601
3 tasks
piyush-zlai
approved these changes
Mar 24, 2026
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
When a schema has many fields with distinct complex types (e.g., 1000+ fields each containing a unique record type in a union), the generated
FastDeserializerconstructor can exceed the JVM's 64KB method bytecode limit, causing a "code too large" compilation error at runtime.The existing method-splitting logic (
populate_helpers, PRs #251, #507, #514, #525) only applies to the deserialization methods, not the constructor. The constructor assignsthis.fieldN = readerSchema.getField("...").schema()for every unique schema encountered, and each assignment generates ~14 bytes of bytecode. With 5000+ unique schema vars this exceeds 64KB.Changes
SCHEMA_VARS_PER_CONSTRUCTOR_METHODconstant (500) to control the split thresholdinitSchemaFields_N(Schema readerSchema)helper methodFINALmodifier on schema fields to allow assignment in helper methods (these are private fields on generated classes — no functional or performance impact)Test
Added
shouldBeAbleToReadVeryLargeSchemaWithDistinctRecordFields: creates a schema with 1000 fields × 5 sub-fields, each field a union of[null, uniqueRecordType]. Without the fix,WARM_FAST_AVROfails withFastSerdeGeneratorException: Unable to compile. With the fix, all three implementations pass.Test plan
shouldBeAbleToReadVeryLargeSchemaWithDistinctRecordFieldspasses (all 3 variants)avro-fastserde-tests111test suite passes