Skip to content

Revert some changes from #109105, add performance test that shows the degradation. - #110714

Closed
Avogar wants to merge 1 commit into
masterfrom
revert-cow-safe-deserialize-sweep
Closed

Avogar wants to merge 1 commit into
masterfrom
revert-cow-safe-deserialize-sweep

Conversation

@Avogar

@Avogar Avogar commented Jul 16, 2026

Copy link
Copy Markdown
Member

Revert part of the changes in serializations from #109105, add performance test that clearly shows the performance degradation after these changes.

Changelog category (leave one):

  • Not for changelog (changelog entry is not required)

Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):

...

…egression

PR #109105 replaced assumeMutable with IColumn::mutate in serialization code.
In ISerialization::deserializeBinaryBulkWithMultipleStreams this caused a severe
performance regression (3-4x slower) because columns are intentionally shared
via the substreams cache between multiple readers (e.g. reading both a full
Tuple column and its named subcolumns). IColumn::mutate clones the column when
use_count > 1, defeating the cache and causing unnecessary copies on every
readRows call.

MergeTree readers return a set of constant columns that are not mutated after
reading, so sharing subcolumns via the same ColumnPtr is safe and assumeMutable
is the correct approach in the base deserialization path.

Keep IColumn::mutate in the other four call sites where the column is not shared
via the cache:
- ISerialization::insertDataFromCachedColumn
- SerializationArrayOffsets (rows_offset > 0 path, cache stores cut() copy)
- SerializationStringSize (rows_offset > 0 path, cache stores cut() copy)
- SerializationVariant discriminators (rows_offset > 0 path, cache stores cut() copy)

Also adds a performance test for Tuple subcolumn deserialization covering both
wide parts (with alternating granule skipping via minmax index) and compact
parts (with nested Tuple to exercise substream cache sharing).

Co-Authored-By: Claude Opus 4.6 <[email protected]>
@clickhouse-gh

clickhouse-gh Bot commented Jul 16, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [f3f1444]

Summary: ✅


AI Review

Summary

This PR partially reverts the IColumn::mutate change in the base deserialization path to recover tuple-subcolumn read performance and adds a benchmark for wide and compact MergeTree parts. I did not find a new correctness regression in the reverted serialization paths, but the new compact benchmark still depends on an ambient table default, so its compact-path coverage is weaker than the PR description claims.

Missing context / blind spots
  • ⚠️ I could not validate the claimed 3-4x regression/fix with CI measurements: the current PR report has only a small subset of checks completed, and the performance-comparison shards were skipped because the PR is not labeled pr-performance. A perf-comparison report or local before/after benchmark would close this gap.
Findings
⚠️ Majors
  • [tests/performance/tuple_subcolumn_deserialization.xml:45-48] The compact benchmark says it covers subcolumn sharing through the compact reader’s substream cache, but it leaves write_marks_for_substreams_in_compact_parts implicit. Existing compact-part subcolumn tests pin this setting to 1; if the default/profile differs, the reader falls back to reading the whole column once and extracting subcolumns in memory, so this benchmark no longer exercises the regression path this PR is meant to guard.
    Suggested fix: add write_marks_for_substreams_in_compact_parts = 1 to tuple_deser_compact.
Final Verdict
  • Status: ⚠️ Request changes

@clickhouse-gh clickhouse-gh Bot added the pr-not-for-changelog This PR should not be mentioned in the changelog label Jul 16, 2026
@clickhouse-gh

clickhouse-gh Bot commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

LLVM Coverage Report

Metric Baseline Current Δ
Lines 85.90% 86.00% +0.10%
Functions 92.70% 92.70% +0.00%
Branches 78.10% 78.10% +0.00%

Changed lines: Changed C/C++ lines covered: 12/24 (50.00%) · Uncovered code

Full report · Diff report

@Avogar

Avogar commented Jul 17, 2026 •

Copy link
Copy Markdown
Member Author
Screenshot 2026-07-17 at 10 27 41

@Avogar Avogar closed this Sep 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr-not-for-changelog This PR should not be mentioned in the changelog

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant