Repository navigation
Bound Compact reads by the requested columns - #119763
rorylshanks wants to merge 17 commits into
Conversation
|
Workflow [PR], commit [f0fb8d5] Summary: ❌
AI ReviewSummaryPR #119763 bounds Missing context / blind spots
Final VerdictStatus: ✅ Approve, subject to the normal current-head CI checks. |
Build profile diff (arm_release)Comparing ✅ No significant changes. Binary sizes
The official master build is compiled with Compile time of recompiled translation units304 translation units recompiled, 3296 s compile time in total, 304 of them have a recent master baseline. |
Integrate upstream cb26a48. Preserve the existing PR history and feature scope while updating its base. Related: ClickHouse#119763 Audit: https://github.com/ClickHouse/ClickHouse/pulls/rorylshanks
The 16-case template repeatedly times out in flaky checks. One failed debug run spent 189 seconds in queries, including 131 seconds reading and 51 seconds inserting; dropping tables took only 4 seconds. Reading the 300 dynamic paths without substream marks accounts for most of the read cost. Use 16 paths with dynamic-path limits of 2 and 32. Keep all 16 combinations of packed storage, substream marks, per-column compression and dynamic vs shared JSON paths. Preserve missing-path, `PREWHERE`, full-document and following-column checks, updating their expected sums. All 80 output lines match the reference using the exact CI debug binary. Local time falls from 2.884 to 2.497 seconds; the CI timeout itself remains subject to verification under the flaky-check workload. ClickHouse#119763 https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=119763&sha=089ef83b07d2a142548d4d23b53e6e3a83190e45&name_0=PR https://github.com/ClickHouse/ClickHouse/pulls/rorylshanks
|
📊 Cloud Performance Report
Baseline selected using StressHouse version hint 26.9.1.38556; measured build ancestry could not be verified. Measured differences are not attributed to this PR. ⚙️ Latest matching master measurement is 11.1667 days before this PR's first measurement; an intervening master or environment epoch may explain directional differences. PR verdict: not_sure. 5 measured difference(s) not attributable to this PR. clickbench Q17: The measured difference cannot be attributed to this PR from the available source evidence. clickbench Q33: The measured difference cannot be attributed to this PR from the available source evidence. clickbench Q34: The measured difference cannot be attributed to this PR from the available source evidence. tpch_adapted_1_official Q7: The measured difference cannot be attributed to this PR from the available source evidence. tpch_adapted_1_official Q9: The measured difference cannot be attributed to this PR from the available source evidence. clickbenchFlagged queries (4 of 43)
Change = percent below ×2; the ratio of medians (×N faster/slower) beyond, where percent understates the scale. q-value = BH-FDR adjusted p; smaller is stronger evidence. MIRAI flags a query when q < fdr_q (default 0.10) — the value the verdict is based on. tpch_adapted_1_officialFlagged queries (2 of 22)
Change = percent below ×2; the ratio of medians (×N faster/slower) beyond, where percent understates the scale. q-value = BH-FDR adjusted p; smaller is stronger evidence. MIRAI flags a query when q < fdr_q (default 0.10) — the value the verdict is based on. Debug info
|
The limit intentionally includes every substream of the requested physical column. Exact `JSON` and `Dynamic` path streams require per-granule prefixes that are not available at stream initialization. Document this scope instead of claiming the top-level-column optimization eliminates subcolumn resets. No read behavior changes. ClickHouse#119763 (comment)
|
That looks great! @rienath maybe you can review this PR? It is completely green |
There was a problem hiding this comment.
We'd need an .xml performance benchmark. I measured locally and saw no speed-up. On parts written before 26.4 (no compress_per_column_in_compact_parts, all columns of a granule share one compressed block) it is a 2x slow-down. The bool threading is not a maintainable design.
The idea behind is good
Remember the last right mark in `MergeTreeReaderStream::adjustRightMark`. Marks and column bounds are immutable for a stream, so repeated reads of the same range need not scan the shared compressed-block boundary again. Keep the existing offset-extension and S3 byte-boundary behavior. Add a 28-query XML benchmark covering shared and per-column compression, first/middle/last/all-column projections, filtered and full scans, and packed parts. Run the same XML with local or S3-backed default storage. Validation: matched local builds, 112 exact-result checks, and five functional tests on both binaries. CPU-affinity-controlled repeats found no reproducible old-layout slowdown above 5%; selective S3 gains remained 24-27%. These are local results, not CI confirmation. Related: ClickHouse#119763
Remove the `include_shared_block` mode from `getRightOffsetOneColumn`. Keep actual read limits and buffer-size estimates as separate operations, sharing the included-mark calculation and stripe traversal. Preserve shared-block completion, multi-granule stripes, and `last_right_mark` reuse. Related: ClickHouse#119763 Related: ClickHouse#119763 (review)
Performance CI currently runs `compact_read_column_boundary` on local storage, so it cannot measure the reduced remote range over-read and connection reuse this change targets. Start the existing SeaweedFS fixture for opted-in performance tests and put this benchmark on a dynamic `S3` disk. Install `lsof`, which the fixture uses for its readiness check. ClickHouse#119763
|
Hey @rienath Thanks for reviewing! I added a perf test but as this specifically targets S3 disks there was not a repeatable performance improvement with the existing runner. I added seaweedfs to the perf runner but not sure if that's the correct approach to run performance tests with S3-backed disks. What do you think? Alternatively I could create new shards for the perf test that are specifically for S3 performance tests? |
|
You can check how we run local minio in functional tests. AFAIR we have it there and not only in integration tests. |
|
Heya @qoega, I checked and re-used the same seaweedfs image and scripts that is used elsewhere in tests. Unfortunately it was not configured in the performance test image though. I added it to the perf test image, but as its a CI change the bot removed the approval to run the tests. |
# Conflicts: # ci/jobs/performance_tests.py
Profile collection does not start object storage, so benchmarks marked `requires_s3` time out in the PGO and BOLT passes. Reuse the existing XML classification and skip them explicitly. Related: ClickHouse#119763 (comment)
|
🕵 @rienath, current |
…-column-boundary # Conflicts: # ci/jobs/performance_tests.py
…ed blocks In parts written with `compress_per_column_in_compact_parts` = false, the columns of a granule share compressed blocks, so a column boundary is not a compressed-block boundary and a tighter read limit cannot help. Instead of scanning forward through every column sharing the block on each `getRightOffsetOneColumn` call, detect the shared block from the next column's mark and bound the read by the last column, which is the behavior for reading all columns. This keeps the cost for such parts the same as before the change. Also correct the benchmark comment: the shared-block layout comes from `compress_per_column_in_compact_parts` = 0, not from parts written before 26.4 (they flushed a compressed block after every column). Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Dear @rienath, you haven't been active on this PR for 30 days. You will be unassigned. Will you continue working on it? If so, please feel free to reassign yourself. |
…-column-boundary # Conflicts: # ci/jobs/collect_clickhouse_profiles.py # ci/jobs/performance_tests.py
With `compress_per_column_in_compact_parts` = false a granule can still span several compressed blocks, split at `max_compress_block_size`. Instead of reading up to the end of the granule, stop at the first later column mark that starts a later compressed block. Cover granules split into small blocks in `04967_compact_read_column_boundary`. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…locks `MergeTreeDataPartWriterCompact` compresses through a `CompressedWriteBuffer` with the default 1 MiB buffer; `max_compress_block_size` only sizes the outer file buffer. The previous variant of `04967_compact_read_column_boundary` with `max_compress_block_size = 64` therefore never split a granule, and the search for a later column that starts a later block was not exercised. Replace it with a table whose granules overflow the compression buffer: `a` and `b` share the first block and `d` starts in a later one. The layout is asserted with `mergeTreeIndex` before the selective reads. Related: ClickHouse#119763 (comment) Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01E5v7QTSR65LdYnQEv9HJVu
…-column-boundary Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01E5v7QTSR65LdYnQEv9HJVu
The
Compactreader sets its read limit from the last stored column. Selective reads can leave unread response data and force a connection reset. Use the last requested physical column instead, including all its substreams and complete shared compressed blocks. Buffer-size estimation skips this scan to avoid quadratic work.For a subcolumn request, the limit remains the end of its physical column. This change does not claim to eliminate connection resets for selective
JSONorDynamicpaths. Their exact stream sets depend on per-granule deserialization prefixes, which are unavailable when the stream is initialized. The JSON tests check read correctness, not zero connection resets for subcolumns.Benchmark
The table had 100,000 packed Compact parts. The query read
sum(seq)with a partition-range filter. An S3-compatible proxy served local NVMe data. Both 26.8-based Release builds disabled LTO and had limits of 4 CPUs and 16 GiB. The shared host used a Ryzen 9 5950X.Metadata and statistics refresh, filesystem cache, and uncompressed cache were disabled. Values are medians of three queries with cached marks.
GET count stayed at 20,000 and peak query memory at 32.33 MiB for the larger case. Its baseline exhausted ephemeral ports; connection failures and retry waits amplified the wall-time difference.
The existing benchmark above reads the top-level
seqcolumn. The current JSON boundary test uses 16 paths and retains all 16 layout combinations; all 80 output lines match its reference on the CI debug binary.Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Reduce unnecessary connection resets when reading selected physical columns from
Compactparts on object storage.Closes: #122103
Workflow [PR]
Sync PR [sync-upstream/pr/119763]