Repository navigation
Walk the schema for the minimum encoded record size without recursion - #41
Merged
PedroTadim merged 1 commit intoOct 6, 2026
Merged
Conversation
`readHeader` computes a lower bound on a record's encoded size with
`MinEncodedBytesWalker`, which recursed through every record field and
union branch, following named references. A schema can chain named types
to any depth while staying shallow as text: define each `A_k { x: A_{k-1} }`
inside an array field, which the walk does not descend, and reach the whole
chain from a last field `["null", "A_n"]`. Neither the memo nor the cycle
cut bounds that depth, so 100000 such types overflowed the thread stack
while the header was parsed.
The walk now keeps its own stack of frames on the heap. It visits leaves in
the same order, memoises the same nodes and cuts the same cycles, so the
bound is the same for every schema.
Reported in ClickHouse/ClickHouse#123998.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Member
|
I have to accept this |
groeneai
added a commit
to groeneai/ClickHouse
that referenced
this pull request
Oct 6, 2026
ClickHouse/avro#41 was merged as d8ff6d9c9fe4 on the avro master branch. Its tree is identical to the previously pinned PR head fcc115b5c42e, so the compiled code does not change; the pin now points at a commit on the avro master branch instead of the fork branch. Co-Authored-By: Claude Opus 5.5 <[email protected]>
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.
readHeaderrunsMinEncodedBytesWalkerfor every file. It recursed through each record field and union branch, so a schema that chains named types deeply overflowed the thread stack:A_k { x: A_(k-1) }for k up to 100000, eachA_kdefined inside an array field (shallow as text, and not descended by the walk), reached by a last field["null", "A_n"]. Reported in ClickHouse/ClickHouse#123998.The walk now keeps its own stack of frames on the heap. It visits leaves in the same order and keeps the memo and the cycle cut, so it returns the same bound for every schema.
Checked with a temporary build computing both walks in
readHeader: no difference over 854 reads of 428 generated schemas (DAGs, self, mutual and required cycles, unions,fixed, every codec) and 944 reads in ClickHouse's Avro and Iceberg stateless tests. ClickHouse PR: ClickHouse/ClickHouse#124053.