Skip to content

Speed up 04143_low_cardinality_single_dict_read_amplification in the flaky check - #125795

Merged
Algunenano merged 2 commits into
ClickHouse:masterfrom
groeneai:speed-up-04143-flaky-check
Oct 15, 2026
Merged

Algunenano merged 2 commits into
ClickHouse:masterfrom
groeneai:speed-up-04143-flaky-check

Conversation

@groeneai

@groeneai groeneai commented Oct 14, 2026 •

Copy link
Copy Markdown
Collaborator

Related: #115050

Changelog category (leave one):

  • CI Fix or Improvement (changelog entry is not required)

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

Not required (CI fix).

Description

The flaky check of #115050 fails 04143_low_cardinality_single_dict_read_amplification with Test runs too long (> 180s) at 182.5 s and 181.3 s (amd_debug report). Any PR that touches the file gets this red.

OPTIMIZE TABLE lc_single_dict_repro FINAL only rewrote the single part the INSERT had already written (the job's part_log shows the same 131072 rows and 8025952 bytes before and after). Under the flaky check's ThreadFuzzer it took 83-87% of each amd_debug run (140-157 s), 84-86% on amd_binary and 65% on amd_asan_ubsan. It is removed, so the queries read the inserted part (the same cause as 04073 in #125263). A new parts line asserts that the INSERT wrote the single part the queries rely on. The Tags line is unchanged, so this merges cleanly with #115050.

Validation: the read-amplification check still fails with the single-dictionary detection in SerializationLowCardinality disabled, and 50 runs pass on debug and ASan. Under the ThreadFuzzer with 8 concurrent copies on one machine, a run takes 49-62 s, where every run of the old file exceeded 760 s.


Workflow [PR]
Sync PR [sync-upstream/pr/125795]

Version info

  • Merged into: 26.10.1.2459-master (included in 26.10 and later)

…flaky check

`OPTIMIZE TABLE lc_single_dict_repro FINAL` rewrote the single part the
INSERT had already written: part_log of the failing amd_debug flaky check
of ClickHouse#115050 shows all_1_1_0 -> all_1_1_1 with the same 131072 rows and the
same 8025952 bytes. Under the flaky check's ThreadFuzzer it took 140-157 s
of each 165-181 s run on amd_debug (83-87%), 84-86% on amd_binary and 65%
on amd_asan_ubsan, so the test crossed the 180 s cap.

The queries now read the INSERT's part directly. Its layout is the same
(same rows and compressed bytes), the existing has_one_dict check still
asserts the single-dictionary precondition, and the reference is
unchanged. With the single-dictionary detection disabled in
SerializationLowCardinality the read-amplification line still turns 0
(ReadCompressedBytes / data_compressed_bytes 104.5 vs 0.935 with it).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@groeneai

Copy link
Copy Markdown
Collaborator Author
Internal second-model review: adjudication log (click to expand)

Pre-publication review by an independent model (engine: codex; 0 findings) plus my own cold review (1 nit, PR description only).

# Sev Finding Verdict Evidence / action
1 💡 The description did not say this is the same cause as 04073 in #125263 AGREE, fixed in the description one clause added

Severity: ❌ blocker / ⚠️ major / 💡 nit.

@clickhouse-gh

clickhouse-gh Bot commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [2f88bb4]

Summary: ❌

job_name test_name status info comment
Stateless tests (amd_debug, parallel) FAIL
03323_union_all_constants_bug FAIL cidb IGNORED

AI Review

Summary

The PR removes a redundant OPTIMIZE TABLE ... FINAL from 04143_low_cardinality_single_dict_read_amplification and asserts that the INSERT produced one active part. The dictionary-layout, correctness, and read-amplification assertions remain intact. No actionable findings in head 2f88bb46babdd575825b47c4de2048aa7dfdd169.

Missing context / blind spots
  • ⚠️ The latest-head CI run has not published the targeted flaky-check results yet. The PR description reports repeated debug/ASan passes, before/after ThreadFuzzer timings, and a negative control with single-dictionary detection disabled; these were not independently rerun because this checkout has no ClickHouse executable. Completed targeted CI would close this verification gap.
Final Verdict

Status: ✅ Approve. No code changes requested; normal CI completion remains pending.

@clickhouse-gh clickhouse-gh Bot added the pr-ci label Oct 14, 2026
@groeneai

groeneai commented Oct 14, 2026 •

Copy link
Copy Markdown
Collaborator Author

cc @Avogar, could you review this and add the can be tested label (I can no longer add it, so CI did not start)? It removes a no-op OPTIMIZE ... FINAL from 04143_low_cardinality_single_dict_read_amplification, which took most of each run in the flaky check of #115050 (the same cause as 04073 in #125263).

@clickhouse-gh clickhouse-gh Bot added the comp-testing Test content only (no production code). label Oct 14, 2026
@Algunenano Algunenano added the can be tested Allows running workflows for external contributors label Oct 14, 2026
@Algunenano Algunenano self-assigned this Oct 14, 2026
arrayMap(i -> repeat('8 bytes|', 16) || toString(number % 8000), range(20)),
if(intDiv(number, 32) % 2 = 0, 1, 0)
FROM numbers(128 * 1024);

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.

Don't we need to ensure somehow (settings, or checking + optimizing) that the table has, in fact, one part? I don't see what in the INSERT guarantees this, specially with randomized settings (maybe we don't randomize those that might affect)?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Nothing in the test asserted it, so I added a check in 2f88bb4: the test now prints the active part count right after the INSERT, and the reference expects parts 1.

Why it is one part today: the INSERT converts to the table types before squashing, so the squashed block is already LowCardinality. Its 131072 rows are below min_insert_block_size_rows (1048449) and its bytes are far below min_insert_block_size_bytes (256 MiB), so squashing emits a single block. Neither setting is randomized. The insert-related settings that are randomized or set by a CI job (max_insert_threads = 16, max_block_size = 8000, optimize_trivial_insert_select = 1, async_insert = 1) all still give one part. With min_insert_block_size_rows = 100000 the INSERT writes two parts, and the test now fails on the new line.

The removed `OPTIMIZE ... FINAL` used to merge the table into one part.
The INSERT already writes one part: its 131072 rows are below
`min_insert_block_size_rows` and the squashed `LowCardinality` block is far
below `min_insert_block_size_bytes`, so squashing emits a single block.
Neither setting is randomized. The randomized settings that touch this
INSERT (`max_insert_threads`, `max_block_size`,
`optimize_trivial_insert_select`) and `async_insert` still give one part.

Assert the part count instead of relying on it, as ClickHouse#125263 does for 04073.
With `min_insert_block_size_rows = 100000` the INSERT writes two parts and
the test now fails on this line.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@groeneai

Copy link
Copy Markdown
Collaborator Author

CI finish ledger - 2f88bb4

Every failure below has an owner: a fixing PR (mine or external), or a full-effort fix task
whose fixing-PR link will be posted here when it opens. Only CH Inc sync is exempt.

Check / test Reason Owner / fixing PR
Stateless tests (amd_debug, parallel) / 03323_union_all_constants_bug flaky, not reachable from this diff (it only changes 04143): the two UNION ALL rows tie on ORDER BY grade_name_id, so their order is unspecified; 313/313 same-settings reruns passed, and it failed the same way on one other unrelated PR today a fix task is created (fixing-PR link to follow here)
Mergeable Check, PR (rollup statuses) derived, they mirror the red job above a fix task is created (same row as above)
Sync - CH Inc sync (private, not actionable by me)

Session id: cron:our-pr-ci-monitor:20261014-203009

@groeneai

Copy link
Copy Markdown
Collaborator Author

Fixing PR for 03323_union_all_constants_bug (Stateless tests (amd_debug, parallel)) created: #125872

@Algunenano
Algunenano added this pull request to the merge queue Oct 15, 2026
Merged via the queue into ClickHouse:master with commit 2d7962a Oct 15, 2026
175 of 177 checks passed
@robot-ch-test-poll2 robot-ch-test-poll2 added the pr-synced-to-cloud The PR is synced to the cloud repo label Oct 15, 2026
alexey-milovidov added a commit that referenced this pull request Oct 18, 2026
`03173_row_binary_and_native_with_binary_encoded_types`, `04073_parallel_replicas_in_order_splits`,
`00223_shard_distributed_aggregation_memory_efficient` and `04143_low_cardinality_single_dict_read_amplification`
now average well below 60 s under MSan after fixture speedups on `master`
(#125263, #125795).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@clickhouse-gh clickhouse-gh Bot added comp-datatype-wrapper Type modifiers/wrappers (Nullable, LowCardinality, etc.). and removed comp-testing Test content only (no production code). labels Nov 22, 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 comp-datatype-wrapper Type modifiers/wrappers (Nullable, LowCardinality, etc.). pr-ci 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