Repository navigation
Conversation
… merge) Co-Authored-By: Claude Opus 4.8 <[email protected]>
…-regions # Conflicts: # src/DataTypes/Serializations/ISerialization.h # src/DataTypes/Serializations/SerializationObjectTypedSharedData.h # src/Interpreters/FileCache/FileCache.cpp # src/Interpreters/TemporaryDataOnDisk.cpp # src/Interpreters/TemporaryDataOnDisk.h # src/Storages/MergeTree/IMergeTreeDataPart.h # src/Storages/MergeTree/IMergeTreeDataPartInfoForReader.h # src/Storages/MergeTree/LoadedMergeTreeDataPartInfoForReader.h # src/Storages/MergeTree/MergeTreeDataPartWriterWide.h # src/Storages/MergeTree/tests/gtest_merge_tree_marks_loader.cpp
…-regions Resolve the conflict with PR 131011 in MergeTreeReaderWide: take the resolved substreams, keep the stream keys of views for the stream map, the prefetched set and the average value size hints. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Workflow [PR], commit [f33e3fd] Summary: ❌
AI ReviewSummaryAdds the Consumer scope for the new representation: whole-column reads, merges, mutations, and wide sub-objects retain the plain layout; path/subcolumn and narrow sub-object readers translate their streams to region views. Findings❌ Blockers
Tests
Final VerdictStatus: ❌ Block Gate new-format writes, bound or explicitly track the malformed-marks allocation, correct private-spill recovery on zero-copy disks, and provide performance evidence. The dismissed threads were left unchanged; no duplicate inline comments were posted. |
- `no-fasttest` for the tests 05457 and 05479 that enable fail points, as the style check `failpoint_tests_are_isolated` requires. - `TemporaryDataReadBuffer` takes its seekable reader from the holder after the move, for clang 23 `-Wlifetime-safety-dangling-field-moved`. - `[[nodiscard]]` and initialized variables for clang-tidy. CI report: https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=132369&sha=43fc440b32d8c7989f17246009cdf1de04b495ba&name_0=PR PR: #132369 Co-Authored-By: Claude Opus 5.5 <[email protected]>
Metadata streams load no marks now, so a read of a `JSON` or `Dynamic` column loads and opens fewer marks files: 05109 loads 16 marks files instead of 22 (the object structure and the dynamic structures of its 5 paths), and 03198 opens 7 files instead of 8 (the marks of `d.dynamic_structure`). CI report: https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=132369&sha=e20e2f51e6cf7b403047f02a133c29463feb09ba&name_0=PR&name_1=Fast%20test PR: #132369 Co-Authored-By: Claude Opus 5.5 <[email protected]>
Build profile diff (arm_release)Comparing Binary sizes
The official master build is compiled with Object file sizes
|
| Object file | Master | PR | Δ |
|---|---|---|---|
src/CMakeFiles/dbms.dir/DataTypes/Serializations/SerializationObjectTypedSharedData.cpp.o |
283.11 KiB | 547.45 KiB | +264.34 KiB (+93.37%) |
src/CMakeFiles/dbms.dir/DataTypes/Serializations/SerializationSpiller.cpp.o |
new | 101.89 KiB | +101.89 KiB |
src/CMakeFiles/clickhouse_common_io.dir/IO/PiecewiseWriteBuffer.cpp.o |
new | 60.17 KiB | +60.17 KiB |
src/CMakeFiles/dbms.dir/DataTypes/Serializations/SerializationObject.cpp.o |
637.39 KiB | 692.61 KiB | +55.21 KiB (+8.66%) |
src/CMakeFiles/dbms.dir/Storages/MergeTree/MergeTreeReaderWide.cpp.o |
463.65 KiB | 515.61 KiB | +51.96 KiB (+11.21%) |
src/CMakeFiles/dbms.dir/DataTypes/Serializations/SerializationObjectSharedData.cpp.o |
658.27 KiB | 698.30 KiB | +40.04 KiB (+6.08%) |
src/CMakeFiles/dbms.dir/DataTypes/Serializations/SerializationObjectTypedSharedDataPath.cpp.o |
135.70 KiB | 174.50 KiB | +38.80 KiB (+28.59%) |
src/CMakeFiles/dbms.dir/DataTypes/Serializations/SerializationSubObjectTypedSharedData.cpp.o |
130.73 KiB | 168.03 KiB | +37.30 KiB (+28.54%) |
src/CMakeFiles/dbms.dir/Storages/MergeTree/IMergeTreeDataPart.cpp.o |
1.62 MiB | 1.65 MiB | +33.67 KiB (+2.03%) |
src/CMakeFiles/dbms.dir/Interpreters/TemporaryDataOnDisk.cpp.o |
275.38 KiB | 306.55 KiB | +31.16 KiB (+11.32%) |
src/CMakeFiles/dbms.dir/Storages/MergeTree/MergeTreeDataPartWriterWide.cpp.o |
404.39 KiB | 434.75 KiB | +30.36 KiB (+7.51%) |
src/CMakeFiles/dbms.dir/Core/SettingsEnums.cpp.o |
2.50 MiB | 2.52 MiB | +24.78 KiB (+0.97%) |
src/CMakeFiles/dbms.dir/Interpreters/Context.cpp.o |
3.67 MiB | 3.69 MiB | +24.15 KiB (+0.64%) |
src/CMakeFiles/dbms.dir/DataTypes/Serializations/SerializationVariant.cpp.o |
423.36 KiB | 446.06 KiB | +22.70 KiB (+5.36%) |
src/CMakeFiles/dbms.dir/Storages/MergeTree/MergeTreeData.cpp.o |
4.73 MiB | 4.75 MiB | +20.50 KiB (+0.42%) |
src/CMakeFiles/dbms.dir/DataTypes/Serializations/SerializationMap.cpp.o |
1.81 MiB | 1.83 MiB | +19.25 KiB (+1.04%) |
src/CMakeFiles/dbms.dir/Storages/MergeTree/MergedBlockOutputStream.cpp.o |
316.61 KiB | 333.31 KiB | +16.71 KiB (+5.28%) |
src/CMakeFiles/dbms.dir/Storages/MergeTree/MergeTreeSettings.cpp.o |
1.21 MiB | 1.22 MiB | +16.47 KiB (+1.33%) |
716 more object files are built by the master warmup baseline only (it builds every object-file target, a pull request build only clickhouse-bundle) and not compared.
Compile time of recompiled translation units
3955 translation units recompiled, 15496 s compile time in total, 3953 of them have a recent master baseline.
Symbol sizes
| Binary | Symbol | Master | PR | Δ |
|---|---|---|---|---|
programs/clickhouse |
ProfileEvents::global_counters_storage |
14.69 MiB | 14.75 MiB | +64.00 KiB (+0.43%) |
CI fixes: - `05182` reference: metadata streams no longer load marks, so a read loads 15 marks files, not 21. - `FileSegment::reserve` grew an unbound segment's range by the written data plus the request, but a reserve-ahead leaves reserved space unwritten and `size_to_reserve` was already reduced by it, so the range could end below `reserved_size` and the next reserve aborted. Grow it to cover the reservation. - `05475` inserts 100000 rows instead of 400000: the same layout is exercised and the test no longer times out under a sanitizer. Hardening of the v2 header and spilled-segment decode: - Bound the per-path substream count read from the header before allocating. - Reject a decoded granule run that would exceed the part's granules, and check a spilled segment was consumed exactly, instead of looping or reading past it. CI report: https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=132369&sha=887cbf35cdfe6090ba2e7c03815cce3f8266915c&name_0=PR PR: #132369 Co-Authored-By: Claude Opus 4.8 <[email protected]>
- `GranuleOffsets::read` takes the size of the encoded data and rejects an entry count above it before allocating: each entry takes at least one byte. - 05458, 05488 and 05489 reset `max_block_size` before scanning `system.query_log`, which the tiny blocks of their reads would slow down. PR: #132369 Co-Authored-By: Claude Opus 5.5 <[email protected]>
- The caches a region read needs are lazily allocated: `columns_read_sizes` and `registered_mark_cache_keys` are unique_ptrs, null on parts that never read a region, so a part without a JSON column does not grow by them. - `getColumnReadSize` returns the column size directly for a column without dynamic subcolumns, instead of caching a value equal to it, so the cache is populated only on parts that have such a column. - 05474 checks only that the region's cached start is not aligned to the cache boundary. The end is dropped: its edge segment can be absent after prefetch or eviction, which made the check flaky, while the start is a stable witness that the bounds clamp the read on both of the stacked caches. PR: #132369 Co-Authored-By: Claude Opus 4.8 <[email protected]>
…-regions Conflicts with PR 128157 (now in master), PR 133356 (PREWHERE subcolumn sizing through the query's caches) and PR 121829 (mark cache key by part name): - subcolumn sizing keeps the streams cache of the regions and takes master's getColumnAndSubcolumnSizes, canCalculateSubcolumnSizeFromMemory and the read settings of getListOfStreamsForColumns; - the read sizes keep their lazily allocated cache; - the mark cache key of a slice extends master's key by part name; - 05457 takes master's faster version. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Master is at 26.12 now, so the settings history of the settings this branch adds must be recorded under it; the style check rejects the 26.11 records. CI report: https://d1k2gkhrlfqv31.cloudfront.net/clickhouse-test-reports-private/praktika.html?PR=84212&sha=61dba1ed234dd6bdc13309e7133c33badb3f22a0&name_0=PR&name_1=Style%20check PR: #132369 Co-Authored-By: Claude Opus 5.5 <[email protected]>
…-regions Conflicts in TemporaryDataOnDisk with PR 120906 (UBSan check of unsigned overflows): the scopes keep the reservation accounting of this branch, whose compare-and-add already leaves every scope unchanged when a limit refuses; master's getTemporaryFileReserveSize is kept. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Related: #127000
Related: #128157
Adds version
v2of the storage of theSHAREDtyped paths ofJSON, selected by the MergeTree settingobject_typed_shared_data_serialization_version = 'v2'(the default staysv1). In Wide parts, the data of everySHAREDpath is also stored apart for the whole part, so a query that reads a fewSHAREDpaths reads only their bytes instead of the shared data of all paths.v1: all
SHAREDpaths in one streamIn
v1(#127000) theSHAREDpaths of a part live in a constant number of files: granule by granule, the data of every path one after another, with a marks entry per granule pointing at the start of each path's piece. The piece of a path holds all its substreams.A read of one path takes its piece from every granule and appends each substream to its part of the column. The pieces are scattered over the whole file, between the data of the other paths. What such a read pays:
v2: a region per substream of every path
A Wide part in
v2keeps the plain layout and also stores every substream of everySHAREDpath as a region: the substream's bytes for the whole part, cut into compressed blocks at granules, with a mark per granule. A region has the same layout as a column file of a Wide part. All regions are in one.paths_region_datafile, and the marks of each region are a slice of one.paths_region_marksfile, so the number of files stays constant. The.headerrecords, per path and substream, the sizes of its region and of its marks slice.The plain layout stays for reads of the whole column, merges and mutations. The cost is that the
SHAREDdata of a Wide part is stored twice. Compact parts, and typed shared data nested inside a path, keepv1.Reading a path through views of its regions
The prefix read (the
.header) tells the reader where the regions of the requested paths are.MergeTreeReaderWideopens each region as a view: a byte range of.paths_region_datawith its slice of.paths_region_marks, opened as an ordinaryMergeTreeReaderStreamoverReadBufferFromFileView, with the slice loaded through the mark cache. From then on a region is read like a separate column file: seeks to marks, skipped granules, prefetch and the mark cache work unchanged.The view also passes its byte range down as read bounds (
ReadBuffer::setReadBounds).FileCache::getOrSetuses them to keep the alignment of its segments within the region, so the cache does not download the neighbouring regions.Regions are used by reads of a
SHAREDpath, of a subcolumn of one, and of a sub-object with at mostobject_shared_data_max_sub_object_paths_to_read_separately(32) paths. A read of the whole column, or of a wider sub-object, uses the plain layout.A read through regions has none of the problems of the plain layout listed above, while the number of files stays constant: its data is contiguous, bounded, cached and prefetched as a separate column file, with its own marks and compressed blocks. Reads of the whole column, merges and mutations read every path anyway and use the plain layout; a sub-object with more paths than the limit uses it too and pays its costs.
Writing the regions, and temporary data
The regions are written at the end of the part, after all granules. A part written from one block, which is every insert, serializes them straight from the block. Merges and mutations see the data granule by granule, so they buffer each substream of each path in memory until the end of the part.
When the buffers of a part write exceed
serialization_spill_max_bytes_to_buffer, the largest buffer is spilled as one segment: the data plus the granule offsets that cut it into blocks and marks at the end. The budget is shared by all JSON columns of the part write.Spills go first to the server's temporary storage (
tmp_path,tmp_policy, or the filesystem cache oftemporary_data_in_cache). Space is reserved ahead in steps of 64 MiB, so a lack of space is a refusal before writing, not a failed write. When the storage refuses, or a limit is reached, the part write moves its spills to the part's disk: atmp_data_<uuid>directory of the table. The directory is removed when the part write ends, and by the cleanup oftmp_directories at the table's startup after a crash. At the end of the part, the segments of every substream are read back in order and written into its region with the part's codec.serialization_spill_max_bytes_to_buffer0buffers everything in memory.serialization_spill_max_temporary_data_size00means no limit of its own.max_temporary_data_on_disk_size_for_serialization_spills00means the ratio below.max_temporary_data_on_disk_ratio_for_serialization_spills0.3serialization_spill_to_part_disk_onlyfalseserialization_spill_error_modethrowthrowfails the part write,skipwrites the part without the regions, which is then read from the plain layout.The limits are within
max_temporary_data_on_disk_size. An error on the part's disk always fails the part write.Benchmark
Reads of
SHAREDtyped paths inv1andv2, on one ClickHouse Cloud service (a replica of 32 GiB,max_threads8), each table merged to one part. S1: 50 M rows, 100 paths in 10 prefixes (UInt64, String, Float64, Array). S2: 5 M rows, 1000 paths in 100 prefixes (UInt64, String). Cold: the filesystem, mark and uncompressed caches dropped before each run; warm: after a warm-up run. Medians of 3 cold and 5 warm runs. The sub-object isjson.^g3(S1) andjson.^g42(S2), 10 paths each.Cold:
Warm:
Other changes
MergeTreeReaderWideopens the streams listed by the deserialized prefixes before the read, so that their marks load in parallel. Metadata streams load no marks, and cached subcolumn streams are prefetched.TemporaryDataOnDiskcan reserve space ahead (tryReserveMore) and has a scope for serialization spills with its own limit.ObjectTypedSharedDataRegionReads,ObjectTypedSharedDataPlainLayoutReads,SerializationSpilledSegments,SerializationSpilledBytes,SerializationSpilledUncompressedBytes,SerializationSpillFiles,SerializationSpilledToPartDisk,SerializationSpillErrors. New metric:TemporaryFilesForSerializationSpills.Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Add version
v2of the storage of theSHAREDtyped paths ofJSON(MergeTree settingobject_typed_shared_data_serialization_version = 'v2'). In Wide parts, the data of eachSHAREDpath is also stored separately for the whole part, so a query that reads a fewSHAREDpaths reads only their data instead of the shared data of all paths. Merges and mutations buffer this data in memory and spill it to the temporary storage or to the part's disk beyondserialization_spill_max_bytes_to_buffer.Workflow [PR]
Sync PR [sync-upstream/pr/132369]