Repository navigation
Conversation
MergeTextIndexesTask::adjustPartOffsets rewrote every posting row id from a source part's numbering into the merged part's numbering one row id at a time, through a random-access lookup in PackedPartOffsets. A posting list is a sorted, usually dense run of row ids, and a part whose rows a merge did not interleave maps affinely, so the page lookup and the per-row-id bound check are paid for and never used. The report on ClickHouse#120802 measures 12.9% of self time in a profile of an ngrams(3) merge of 9 parts on an arm64 host. That profile is not reproduced here; what is measured here is the effect: removing the per-row-id work moves a whole ngrams(3) merge of disjoint parts by -8.74% [-10.92, -6.56]. PackedPartOffsets now tracks whether its pages hold a single consecutive run and offers mapOffsets, which remaps a whole array of offsets: by adding one constant when the map is affine, by resolving each page once per run of offsets on it when the posting list is dense, and one offset at a time otherwise. A sparse posting list would end a run after a few offsets while the per-offset path is already cheap, which is why it keeps that path. adjustPartOffsets checks the UInt32 bound once, on the last row id, which adds no assumption: checkRowIdsInPart already reduces the part-rows bound check on the same arrays to the last row id, because the row ids are sorted by the format, and the map is monotonically increasing by construction, so the last row id is remapped to the largest value. A merged part with more than UInt32::max rows still throws, also on the affine path, because every mapped value is at least the first one, so if the largest does not fit then neither does the value the check looks at. mapOffsets returns for every offset exactly what operator[] returns, so the merged index is byte-identical. The new unit tests pin that against every page layout the structure can build, for dense and for sparse posting lists. Related: ClickHouse#120802
Keep the invariants a reader cannot derive (contiguity, page completeness, mapOffsets preconditions, the unsigned page-window wrap, the merge order), drop the narration of the fix itself.
Internal second-model review: adjudication log (bulk remap round) (click to expand)Pre-publication review by an independent model (engine: codex, full pass over the three changed files) plus my own cold review of the resulting code, written before reading any implementation evidence. Neither pass found a defect in the mechanism: I re-derived the four mapping strategies against Two fix rounds were bounced; neither changed a tracked file. The published tree differs from the reviewed one by a comment trim only, proven comment-only by a preprocessor-stripped comparison of every changed file.
Also noticed and not raised: the in-tree performance test has no Severity: ❌ blocker / Session id: cron:clickhouse-review-slot-10:20260925-133700 |
|
Workflow [PR], commit [af9aa78] Summary: ❌
AI ReviewSummaryThis PR adds a bulk remap path for text-index posting row ids during merges by teaching Final Verdict✅ No blocking or major issues found in the current PR head ( LLVM Coverage ReportMeasured on commit af9aa78.
Changed lines: Changed C/C++ lines covered: 48/48 (100.00%) · Uncovered code |
Build (arm_tidy) failed the compile of gtest_merged_part_offsets.cpp: bugprone-random-generator-seed is promoted to an error by WarningsAsErrors: '*', and MapOffsetsUnsortedOffsets seeds mt19937 with a constant on purpose, so that a shuffle failure is reproducible. Suppress the check on that line, which is the in-tree pattern for a deterministic test seed (src/Common/tests/gtest_bit_packed_uint64_array.cpp:70, src/Compression/tests/gtest_pfor.cpp:101).
|
📊 Cloud Performance Report ✅ AI verdict: no significant changes detected. K_source=6 K_base=30 flagged=0/65 clickbench🟢 No significant changes tpch_adapted_1_official🟢 No significant changes Debug info
|
CI finish ledger - af9aa78Every failure below has an owner: a fixing PR (mine or external), or a full-effort fix task
All 173 check runs completed (146 pass, 19 not selected, 8 red), Session id: cron:our-pr-ci-monitor:20260925-230059 |
|
Fixing PR for the Performance Comparison shards that failed with 'performance dashboard verdict unavailable' created: #122369 |
The REPORT-stage uploads of a performance shard probed CIDB once and
skipped the whole step when that probe failed ("CIDB not ready -
skipping"), and a failed INSERT was not retried either. That was fine
while the tables were informational (ClickHouse#108712), but since ClickHouse#120927 the
performance dashboard computes the master_head verdict from exactly
these tables. A CIDB refusal of seconds or an overload of minutes
therefore dropped the shard's rows, and perf_dashboard_gate then waited
600 s for data that was never sent and failed the shard with "dashboard
did not serve this shard within 600s", blaming the dashboard.
Measured: ClickHouse#113589 arm 6/6 skipped all three uploads on "Connection
refused" and failed after 614 s. On 2026-09-25 a CIDB overload
(TOO_MANY_SIMULTANEOUS_QUERIES, read timeouts) failed 70 shards on 21
PRs and master. In 74 of the 76 occurrences since 2026-09-22 that are
not the time zone shape fixed by ClickHouse#121847, an upload was skipped or
failed. The same run of ClickHouse#122252 is the control: amd 1/6 uploaded and
got its verdict in 2 s, while arm 6/6 skipped the uploads and failed.
Now one helper runs all four INSERT sites. In master_head mode the
three tables the verdict is computed from (query_metric_runs_v1,
query_metrics_v2, perf_test_times_v1) are retried every 60 s until one
600 s deadline, which is taken when the uploads start and shared with
the gate's wait. The other tables keep a single attempt, and nothing is
sent after the deadline. Every attempt carries the same
insert_deduplication_token, because some INSERTs that timed out on the
client had committed on the server. If one of the three inputs was not
uploaded, the gate fails at once and names it instead of polling the
dashboard. A shard without a verdict still fails, as ClickHouse#120927 designed,
and release_base keeps its single call.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Dear @CurtizJ, 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. |
Related: #120802
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Merging parts of a table with a text index now remaps a whole posting list at once instead of looking up one row id at a time, which makes such merges up to 10% faster. The produced index is unchanged.
Description
Merging a text index remaps every posting row id into the merged part's numbering. After #120982 that is still one
PackedPartOffsets::operator[]per (row, token) pair plus oneUInt32check each, although a posting list is a sorted, usually dense run of row ids and a part whose rows the merge did not interleave maps affinely.PackedPartOffsetsnow records whether its pages hold a single consecutive run, and gainsmapOffsets, which remaps a whole list: one addition per row id for an affine map, one page resolution per run of row ids sharing a page for a dense list, and the per-row-id lookup otherwise, since a sparse list ends a run after a few row ids while that path is already cheap.adjustPartOffsetschecks theUInt32bound once, on the last row id, which adds no assumption:checkRowIdsInPartalready reduces the part-rows check on the same arrays to that row id, and the map is increasing, so the last row id maps to the largest value.Measured with
OPTIMIZE ... DRY RUN PARTSover thevocabularyandmultiblocklayouts oftests/performance/text_index_merge.xmlplus anngrams(3)pair, 20 paired repetitions, arm order rotated, base run twice as an A/A null: disjoint parts -3.5% to -10.6% (ngrams(3)-8.7%), interleaved -2.8% to -4.6%, 95% CIs excluding zero; two layouts inside the null; nothing slower; CPU tracks wall clock. The fixtures are rebuilt here because thevocabularyfill usesrand(id * 15 + x), whose argument is ignored, so running it per arm would merge different data.The index is byte-identical: over 18 merge layouts every merged part file equals master's, 112 of them
skp_idx_*, and query results match. The same rig with that offset off by one reports differing index files. New unit tests pinmapOffsetsagainstoperator[]for every page layout the structure builds.Workflow [PR]
Sync PR [sync-upstream/pr/122252]