Repository navigation
Cherry pick #127859 to 26.8: Do not re-create nested Tuple elements when creating a column for deserialization - #132311
Conversation
…erialization SerializationTuple::wrapColumnForDeserialization cloned every element with cloneEmpty() and rebuilt the ColumnTuple at each nesting level, so a column with k Tuple ancestors was created k + 1 times. IDataType::createColumn(serialization) runs once per block in row input formats (Block::cloneEmptyColumns), so for the depth-8 schema of #127427 (510 columns) every block paid 3076 extra column creations. It came with #111427, which replaced DataTypeTuple::createColumn(const ISerialization &). Wrap the elements in place instead: the input is the freshly created base column, whose elements are not shared, so each element is passed to its serialization's wrap and the result is stored back in the same slot. Release build, RowBinary, max_block_size = 1, 5000 rows, best of 5: depth 8: 1.558 s -> 0.478 s (26.7: 0.425 s) depth 4: 0.641 s -> 0.339 s (26.7: 0.308 s) flat: 0.333 s -> 0.332 s Taking the element through IColumn::mutate instead of assumeMutable gives 0.679 s at depth 8, because mutate walks the whole subtree again at every level. Extend tests/performance/parse_engine_file.xml with a small-block read of 16-deep nested Tuples (perf.py locally: 2.03 s -> 0.62 s). Closes #127427 Co-Authored-By: Claude Opus 5.5 <[email protected]>
Condense the wrapColumnForDeserialization comment to two lines and backtick SerializationNamed. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…wrapping them Replace `ISerialization::wrapColumnForDeserialization(MutableColumnPtr)` with `ISerialization::createColumnForDeserialization(const IDataType &)`, and route `IDataType::createColumn(const ISerialization &)` through it. The wrap took an already created column and rebuilt it into the layout the serialization deserializes into. For a Tuple that meant `cloneEmpty()` of every element (each clone materializing the element's whole subtree) and then a recursive rebuild of each clone, so a node under k Tuple levels was created k + 1 times per block. Row formats with small blocks (Kafka, async inserts) create a column per block, so deeply nested Tuples got up to 3x slower in 26.9. Now each serialization creates its own column from the type: the Tuple serialization creates every element from the element type with the element serialization, so every node is created exactly once and nothing is mutated or rebuilt afterwards. Sparse, Replicated and Detached create the nested column and wrap it; the wrapper forwards; the product quantization codebook creates its placeholder `ColumnConst` as before; VariantElement and DynamicElement peel the extraction-added `Nullable` off the type instead of off the column. This replaces the previous in-place wrap in this PR, which needed `assumeMutable` on tuple elements. The perf query moves from `parse_engine_file.xml` to its own file. Closes #127427 Co-Authored-By: Claude Opus 5.5 <[email protected]>
…-127427 # Conflicts: # src/DataTypes/Serializations/ISerialization.cpp
Do not re-create nested Tuple elements when creating a column for deserialization
|
The only conflict is one context line in On a 26.8 debug build, the depth-8 case from #127427 (5000 rows, 254 nested I cannot push to |
|
The |
0298f02 to
4699f65
Compare
Original pull-request #127859
Do not merge this PR manually
This pull-request is a first step of an automated backporting.
It contains changes similar to calling
git cherry-picklocally.If you intend to continue backporting the changes, then resolve all conflicts if any.
Otherwise, if you do not want to backport them, then just close this pull-request.
The check results does not matter at this step - you can safely ignore them.
Before you resolve anything
Conflicts are often caused by a prerequisite change that has not been backported yet, rather than by a real divergence. The bot re-tries this cherry-pick against the release branch on every run, so if that is the case here it will merge itself as soon as the prerequisite lands, and you will see a comment saying so. Manual resolution is only needed while the conflict persists.
Troubleshooting
If the conflicts were resolved in a wrong way
If this cherry-pick PR is completely screwed by a wrong conflicts resolution, and you want to recreate it:
pr-cherrypicklabel from the PRYou also need to check the Original pull-request for
pr-backports-createdlabel, and delete if it's presented thereThe PR source
The PR is created in the CI job