Core: Cache PartitionData template in PartitionsTable to avoid rebuilding Avro schema per partition#16208
Open
Wenjun7J wants to merge 2 commits intoapache:mainfrom
Open
Core: Cache PartitionData template in PartitionsTable to avoid rebuilding Avro schema per partition#16208Wenjun7J wants to merge 2 commits intoapache:mainfrom
Wenjun7J wants to merge 2 commits intoapache:mainfrom
Conversation
Signed-off-by: SevenJ <wenjun7j@gmail.com>
Author
|
@RussellSpitzer @pvary could you please take a look? |
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.
What is changed
This change avoids rebuilding the same
PartitionDataAvro schema for every partition row when scanning thepartitionsmetadata table.Instead of creating a fresh
PartitionData(partitionType)for each partition value,PartitionsTablenow creates onePartitionDatatemplate per scan and reuses it throughcopyFor(key).A regression test is also added to verify that partition rows produced within the same scan reuse the same underlying Avro schema instance.
Why
PartitionsTablecurrently constructs partition rows like this:PartitionData(partitionType)When a table has many partition values, this repeats the same schema conversion over and over again, creating heavy allocation pressure in:
PartitionData.partitionDataSchemaAvroSchemaUtil.convertTypeToSchema$WithTypeToName.structThis is especially visible for wide partition specs and large metadata table scans.
External reproduction
Used a standalone repro app that scans the Iceberg
partitionsmetadata table for a table with:Before fix (origin/main)
After fix
Improvement