Skip to content

Add test: Adaptive codec selection firing on the vertical merge algorithm is untested - #112971

Merged
rienath merged 3 commits into
ClickHouse:masterfrom
clickgapai:qa-bot/coverage-pr111834
Aug 3, 2026
Merged

rienath merged 3 commits into
ClickHouse:masterfrom
clickgapai:qa-bot/coverage-pr111834

Conversation

@clickgapai

@clickgapai clickgapai commented Aug 2, 2026 •

Copy link
Copy Markdown
Contributor

Found via ClickGap automated review. Please close or comment if this is incorrect or needs adjustment.

This is a test-only PR — no source code changes. Please review: test quality, whether the claimed coverage gaps are real, and whether test output makes sense.

Adds test coverage for 1 untested code path(s), found during automated review of PR #111834.
That PR The PR adds the experimental MergeTree setting allow_experimental_adaptive_codec_selection. When enabled, merges and mutations write each block of a default-codec (CODEC(Default) or no CODEC) column with whichever candidate codec (the table default, NONE, or a type-specialized codec) produ

1. Adaptive codec selection firing on the vertical merge algorithm is untested
src/Storages/MergeTree/MergeTask.cpp:1985
Risk: MergeTask.cpp:1985 passes try_adaptive_codec = !global_ctx->is_explicit_recompression to the per-column vertical-merge writer, a call site distinct from the horizontal writer (MergeTask.cpp:1052) and the mutation writers. The only test that forces the vertical algorithm (04403 t_v) uses RECOMPRESS CODEC(NONE), so is_explicit_recompression=true and adaptivity is off there; every other adaptive test merges horizontally (<11 columns). Risk: if the vertical call site's …
What's unique vs PR tests: The PR's tests fire adaptive selection only through the horizontal writer (04305 etc., all <11 columns) and through the column-only mutation writer (04305 ALTER UPDATE). The only test forcing the vertical algorithm (04403 t_v) uses RECOMPRESS CODEC(NONE), which disables adaptivity. No PR test fires adaptive selection through the vertical merge writer; this test does.
Tags: -- Tags: no-random-merge-tree-settings — no-random-merge-tree-settings: Randomized merge-tree settings can flip enable_vertical_merge_algorithm off or add block-number/offset columns to mergeTreeCodecBlockCounts output; the test must pin the vertical algorithm to exercise the intended call site.
Try it on ClickHouse Fiddle

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):

Not applicable — test-only change.

Documentation entry for user-facing changes

  • Documentation is written (mandatory for new features)

Version info

  • Merged into: 26.8.1.655 (included in 26.8 and later)

@clickgapai

Copy link
Copy Markdown
Contributor Author

Pre-PR Validation Gate (per ClickGap pipeline):

a) Deterministic repro? ✅
Test exercises the previously-uncovered branch and passes (correct behaviour).

b) Root cause explained? ✅
src/Storages/MergeTree/MergeTask.cpp:1985 — /*try_adaptive_codec=*/ !global_ctx->is_explicit_recompression is only ever executed with is_explicit_recompression=true (04403 t_v) or never reached with adaptivity enabled; the false (adaptive-on) branch value on the vertical path has no test.

c) Fix matches root cause? ✅
N/A for coverage gap — this PR adds a regression test, not a fix. Asserts current correct behaviour at the cited line.

d) Test intent preserved? / New tests added? ✅
New regression test added: 04669_adaptive_codec_vertical_merge.sql.

e) Both directions demonstrated? ✅
Test passes (MATCH) on master proving current correctness; would fail if the cited branch regressed. Single-direction is the correct shape for a coverage gap test.

f) Fix is general, not a narrow patch? ✅
Test asserts the invariant at the cited line — covers the branch, not a specific input shape.

@rienath rienath self-assigned this Aug 2, 2026
@rienath rienath added the can be tested Allows running workflows for external contributors label Aug 2, 2026
@clickhouse-gh

clickhouse-gh Bot commented Aug 2, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [cf3fc5d]

Summary: ✅


AI Review

Summary

This PR adds a focused stateless regression test for the previously untested try_adaptive_codec = !is_explicit_recompression path in the vertical merge writer. The test now also asserts via system.part_log that the merge actually ran with merge_algorithm = 'Vertical', which closes the earlier false-positive gap where a horizontal fallback could still keep the codec check green. I did not find new correctness, coverage, or metadata issues in the current diff.

Final Verdict

✅ No findings.

@clickhouse-gh clickhouse-gh Bot added the pr-not-for-changelog This PR should not be mentioned in the changelog label Aug 2, 2026
The T64/NONE codec check alone stays green under a horizontal fallback
(MergeTask.cpp:1053); add a system.part_log MergeParts assertion so the
test fails if the merge stops using MergeAlgorithm::Vertical.

Requested by @clickhouse-gh[bot] in ClickHouse#112971 (comment)
Comment on lines +19 to +20
-- The merge actually used the vertical algorithm; otherwise `n` is written by the horizontal
-- call site (MergeTask.cpp:1053) and the vertical writer at MergeTask.cpp:1985 stays untested.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's not reference exact lines of code in tests. Please remember it for all future PRs

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Understood — no exact code-line references in tests going forward. The current test already carries none: line 20 reads -- call site and the vertical writer stays untested. and the header comment describes the vertical per-column stream in prose only. Thanks for the guidance.

@rienath
rienath enabled auto-merge August 2, 2026 20:37
@clickhouse-gh

clickhouse-gh Bot commented Aug 2, 2026

Copy link
Copy Markdown
Contributor

Build profile diff (arm_release)

Comparing cf3fc5dfd with master 90042b2dc (stripped binary size, per-symbol sizes and ThinLTO time; object sizes against the warmup build of 4b3181f56; compile times per translation unit against the most recent warmup build that recompiled it).

⚠️ Significant changes: object file sizes, slowest function optimization changes (thinlto).

Binary sizes
Binary Master PR Δ
programs/clickhouse-stripped 685.41 MiB 682.30 MiB -3.11 MiB (-0.45%)

Only the stripped binary is compared: the official master build keeps debug symbols while PR builds strip them, so the other binaries differ by construction.

Object file sizes ⚠️

285 object files changed (-39.68 MiB total), 1 added, 685 removed.

Object file Master PR Δ
contrib/grpc-cmake/CMakeFiles/grpc_unsecure.dir/__/grpc/src/core/ext/transport/chttp2/transport/cht… 960.56 KiB removed -960.56 KiB (-100.00%)
src/Common/ZooKeeper/CMakeFiles/clickhouse_common_zookeeper_no_log.dir/ZooKeeperImpl.cpp.o 806.39 KiB removed -806.39 KiB (-100.00%)
contrib/grpc-cmake/CMakeFiles/grpc_unsecure.dir/__/grpc/src/core/server/server.cc.o 612.22 KiB removed -612.22 KiB (-100.00%)
contrib/grpc-cmake/CMakeFiles/grpc_unsecure.dir/__/grpc/src/core/load_balancing/rls/rls.cc.o 611.36 KiB removed -611.36 KiB (-100.00%)
contrib/grpc-cmake/CMakeFiles/grpc_unsecure.dir/__/grpc/src/core/client_channel/client_channel_filt… 548.04 KiB removed -548.04 KiB (-100.00%)
contrib/grpc-cmake/CMakeFiles/grpc_unsecure.dir/__/grpc/src/core/client_channel/client_channel.cc.o 525.46 KiB removed -525.46 KiB (-100.00%)
contrib/grpc-cmake/CMakeFiles/grpc_unsecure.dir/__/grpc/src/core/client_channel/retry_interceptor.c… 518.85 KiB removed -518.85 KiB (-100.00%)
contrib/grpc-cmake/CMakeFiles/grpc_unsecure.dir/__/grpc/src/core/lib/channel/promise_based_filter.c… 482.91 KiB removed -482.91 KiB (-100.00%)
contrib/grpc-cmake/CMakeFiles/grpc_unsecure.dir/__/grpc/src/core/load_balancing/grpclb/grpclb.cc.o 434.97 KiB removed -434.97 KiB (-100.00%)
contrib/grpc-cmake/CMakeFiles/grpc_unsecure.dir/__/grpc/src/core/call/client_call.cc.o 433.89 KiB removed -433.89 KiB (-100.00%)
src/CMakeFiles/dbms.dir/Databases/DatabaseURL.cpp.o new 400.85 KiB +400.85 KiB
contrib/grpc-cmake/CMakeFiles/grpc_unsecure.dir/__/grpc/src/core/call/server_call.cc.o 391.29 KiB removed -391.29 KiB (-100.00%)
contrib/grpc-cmake/CMakeFiles/grpc++_unsecure.dir/__/grpc/src/cpp/server/server_cc.cc.o 384.88 KiB removed -384.88 KiB (-100.00%)
contrib/grpc-cmake/CMakeFiles/grpc_unsecure.dir/__/grpc/src/core/client_channel/retry_filter_legacy… 369.55 KiB removed -369.55 KiB (-100.00%)
contrib/grpc-cmake/CMakeFiles/grpc_unsecure.dir/__/grpc/src/core/ext/transport/chttp2/transport/wri… 349.81 KiB removed -349.81 KiB (-100.00%)
contrib/google-cloud-cpp-cmake/CMakeFiles/google_cloud_cpp_grpc_utils.dir/__/google-cloud-cpp/googl… 346.93 KiB removed -346.93 KiB (-100.00%)
contrib/grpc-cmake/CMakeFiles/grpc_unsecure.dir/__/grpc/src/core/ext/transport/inproc/legacy_inproc… 345.35 KiB removed -345.35 KiB (-100.00%)
contrib/google-cloud-cpp-cmake/CMakeFiles/google_cloud_cpp_longrunning_operations_protos.dir/google… 339.33 KiB removed -339.33 KiB (-100.00%)
contrib/google-cloud-cpp-cmake/CMakeFiles/google_cloud_cpp_iam_credentials_v1_iamcredentials_protos… 334.24 KiB removed -334.24 KiB (-100.00%)
contrib/google-protobuf-cmake/CMakeFiles/_libprotobuf-lite.dir/__/google-protobuf/src/google/protob… 316.58 KiB removed -316.58 KiB (-100.00%)
Slowest function optimization changes (ThinLTO) ⚠️

Median per-function time ratio to the master baseline is ×1.17 (different machine and build flags); deltas below are relative to that ratio.

Binary Function Master PR Δ vs median
programs/clickhouse-keeper DB::SettingsTraits::Accessor::instance()::$_0::operator()() const [clone .llvm.3833315002542633314] new 16.3 s +16.3 s
programs/clickhouse-keeper DB::SettingsTraits::Accessor::instance()::$_0::operator()() const [clone .llvm.6969868754578406721] 8.5 s gone -10.0 s (-100%)
programs/clickhouse DB::SettingsTraits::Accessor::instance()::$_0::operator()() const [clone .llvm.6969868754578406721] 8.0 s gone -9.4 s (-100%)
programs/clickhouse DB::SettingsTraits::Accessor::instance()::$_0::operator()() const [clone .llvm.3833315002542633314] new 6.1 s +6.1 s
programs/clickhouse-keeper DB::registerFunctionConversion(DB::FunctionFactory&) 6.9 s 13.8 s +5.8 s (+71%)
programs/clickhouse-keeper _GLOBAL__sub_I_TargetLibraryInfo.cpp 5.9 s 11.4 s +4.6 s (+66%)
programs/clickhouse DB::Parquet::writeColumnChunkBody(DB::Parquet::ColumnChunkWriteState&, DB::Parquet::WriteOptions co… 5.2 s 3.1 s -3.0 s (-49%)
programs/clickhouse-keeper DB::ServerSettingsTraits::Accessor::instance()::$_0::operator()() const [clone .llvm.41530897155626… new 2.5 s +2.5 s
programs/clickhouse DB::getSettingsChangesHistory()::$_0::operator()() const 4.3 s 2.6 s -2.5 s (-49%)
programs/clickhouse-keeper DB::MergeTreeSettingsTraits::Accessor::instance()::$_0::operator()() const [clone .llvm.12816159879… new 2.4 s +2.4 s
programs/clickhouse DB::Aggregator::writeToTemporaryFile(DB::AggregatedDataVariants&, unsigned long) const 3.4 s 1.7 s -2.2 s (-56%)
programs/clickhouse-keeper DB::ServerSettingsTraits::Accessor::instance()::$_0::operator()() const [clone .llvm.12822858084705… 1.8 s gone -2.2 s (-100%)
programs/clickhouse DB::attachSystemTablesServer(std::__1::shared_ptr<DB::Context const>, DB::IDatabase&, bool, bool) 4.3 s 3.0 s -2.1 s (-41%)
programs/clickhouse-keeper _ZN2DB18FunctionArrayIndexINS_16CountEqualActionENS_14NameCountEqualEE15executeIntegralIJDutjmDB8_s… 1.9 s 4.3 s +2.1 s (+91%)
programs/clickhouse DB::ServerSettingsTraits::Accessor::instance()::$_0::operator()() const [clone .llvm.12822858084705… 1.7 s gone -2.0 s (-100%)
Compile time of recompiled translation units

6 translation units recompiled, 4 s compile time in total, 6 of them have a recent master baseline.

Symbol sizes

No symbol data for the master baseline yet (it is collected for release builds only since this check was introduced); the comparison will activate once master catches up.

Job report

@rienath
rienath added this pull request to the merge queue Aug 3, 2026
Merged via the queue into ClickHouse:master with commit 3f0b0fc Aug 3, 2026
180 checks passed
@robot-clickhouse-ci-1 robot-clickhouse-ci-1 added the pr-synced-to-cloud The PR is synced to the cloud repo label Aug 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

can be tested Allows running workflows for external contributors pr-not-for-changelog This PR should not be mentioned in the changelog pr-synced-to-cloud The PR is synced to the cloud repo

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants