Skip to content

Run the long sparse_grams performance queries on fewer rows - #129628

Merged
egor-click merged 1 commit into
ClickHouse:masterfrom
groeneai:groeneai/perf-sparse-grams-disabled
Nov 12, 2026
Merged

egor-click merged 1 commit into
ClickHouse:masterfrom
groeneai:groeneai/perf-sparse-grams-disabled

Conversation

@groeneai

@groeneai groeneai commented Nov 5, 2026 •

Copy link
Copy Markdown
Collaborator

Related: #129258

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

...

Description

Part of #129258 (queries longer than 1 second). On MasterCI (14-day medians, amd), 4 of the 6 sparse_grams queries take 4.3-8.3 s and all 5 sparse_grams_index_build queries take 1.0-5.1 s; the two tests take about 294 s and 129 s per perf job.

No existing query number or text changes: 9 queries are disabled (4 in sparse_grams, 5 in sparse_grams_index_build) and the same 9 are appended on fewer rows. The new queries keep the function, string generator and length, index definitions, granularity and settings; only the row count changes (numbers() 10M -> 1M / 1M / 700k and 4M -> 250k; index build 150_000 -> 60_000 rows, text-index INSERT LIMIT 30_000 -> LIMIT 2_500). The 150_000-row sg_src, read only by the disabled queries, is replaced by a 60_000-row sg_src_small from the same generator. Bloom-filter parts stay Wide and text-index parts Compact; at 2_500 rows more text-index posting lists are small enough to be embedded in the dictionary (index bytes per row 1873 -> 2196).

Projected CI times of the new queries (local release build on 8 pinned cores with max_threads = 8, CI medians scaled by the local new/old ratio): 0.45-0.66 s amd, 0.40-0.59 s arm. That saves about 4.4 minutes (sparse_grams) and 1.5 minutes (sparse_grams_index_build) per amd job (local per-file time 262 -> 27 s and 126 -> 35 s).

This PR's own perf run uses the new file on both servers, so it shows no speed-up.

Validation: perf.py --print-queries keeps queries 0-5 and 0-4 identical to master; 6 interleaved local A/A runs (old, new) with CI's perf.py arguments ran exactly the enabled queries, with absolute noise thresholds no higher than before, and the iceberg_local configuration of sparse_grams_index_build passes.

🤖 Generated with Claude Code


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

Version info

  • Merged into: 26.11.1.2139-master (included in 26.11 and later)

9 of the 11 queries of sparse_grams and sparse_grams_index_build ran
1-8.3 s on the CI amd runner (14-day MasterCI medians). Following the
disabled-marker rule for performance tests (no existing query text or
number changes), the 9 long queries get disabled="1" and the same 9
queries are appended on fewer rows:

- sparse_grams: ClickHouse#1/ClickHouse#2 10M -> 1M rows (ClickHouse#6/ClickHouse#7), ClickHouse#4 10M -> 700k (ClickHouse#8),
  ClickHouse#5 4M -> 250k (ClickHouse#9).
- sparse_grams_index_build: #0-ClickHouse#4 run again as ClickHouse#5-ClickHouse#9 on a 60_000-row
  sg_src_small (same randomPrintableASCII(200) generator) instead of the
  150_000-row sg_src; the text-index INSERT takes LIMIT 2_500 instead of
  30_000. sg_src was read only by the disabled queries, so its create,
  fill and drop are replaced by sg_src_small's.

Function, string generator and length, index definitions, granularity and
settings are unchanged; only the row counts change.

Related: ClickHouse#129258

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

groeneai commented Nov 5, 2026

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

# Sev Finding Verdict Evidence / action
1 💡 tests/performance/docs/iceberg_vs_mergetree.md still lists the old sparse_grams_index_build timings DISAGREE a dated measurement snapshot that no CI step reads; no action

Severity: ❌ blocker / ⚠️ major / 💡 nit. DISAGREE verdicts carry recorded evidence and are terminal per finding.

Session id: cron:clickhouse-review-slot-8:20261105-220800

@groeneai

groeneai commented Nov 5, 2026

Copy link
Copy Markdown
Collaborator Author
Pre-PR validation gate (click to expand)
# Question Answer
a Deterministic repro? Yes. With CI's perf.py arguments on a local release build (8 pinned cores, max_threads = 8), every run of the old files takes 0.94-7.8 s for the 9 queries (MasterCI 14-day amd medians 1.0-8.3 s); every run of the new files takes 0.41-0.62 s for their replacements.
b Root cause explained? Each long query is a single-threaded scan, so its time is rows x per-row function cost: numbers(10000000) / numbers(4000000) is one stream, and the index-build queries read a 150_000-row Memory table with max_threads = 1. The row counts were sized for the per-query timeout, not for 1 s.
c Fix matches root cause? Only the row counts change; function, string generator and length, index definitions, granularity and settings stay the same. The old queries are disabled and re-added, so no query number or text changes.
d Test intent preserved / new tests added? Each appended query measures the same path as the one it replaces: bloom-filter parts stay Wide, text-index parts Compact (checked in system.parts). Test-only change, no new test file.
e Both directions demonstrated? 6 interleaved A/A runs (old, new, old, new, old, new): per-file time 262 -> 27 s and 126 -> 35 s; every new query projects to 0.45-0.66 s amd and 0.40-0.59 s arm; absolute noise thresholds 0.05-0.50 x the old ones.
f Fix is general across code paths? N/A (no code). Both files of this audit item are covered, and the iceberg_local configuration of sparse_grams_index_build passes.
g Fix generalizes across inputs (params/datatypes/wrappers)? The ASCII and UTF-8 variants, both bloom-filter parameter sets (3, 8) and (3, 100), and the text index are all kept.
h Backward compatible? (maintainer-approved exception only) Yes. No query number or text changes; the old queries are disabled, not deleted; no settings and no product code.
i Invariants and contracts preserved? 6 and 5 enabled queries are within --max-queries 10, so every enabled query runs in every job. system.query_log shows no run of a disabled query, and teardown-complete is printed on every run.

Session id: cron:clickhouse-impl-slot-40:20261105-210705

@groeneai

groeneai commented Nov 5, 2026

Copy link
Copy Markdown
Collaborator Author

cc @egor-click, could you review this and add the can be tested label so CI runs? Following the disabled approach from #129366: the 9 sparse_grams / sparse_grams_index_build queries over 1 s are disabled and appended again on fewer rows, and the 150_000-row sg_src, now read only by disabled queries, is replaced by a 60_000-row sg_src_small; no existing query number or text changes.

@clickhouse-gh

clickhouse-gh Bot commented Nov 5, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [7357602]

Summary: ✅


AI Review

Summary

Replaces nine slow performance queries with smaller workloads, preserving the disabled originals and their history indices, and shrinks the index-build source table. No actionable findings at head 735760223700aa29806475f6a222ab4a96c23d42. Static contract checks passed; the reported interleaved A/A measurements support the runtime reduction and acceptable measurement noise.

Missing context / blind spots
  • ⚠️ Runtime benchmarks were not independently reproduced: this checkout has no ClickHouse binary or benchmark Python dependencies. At review time, ARM performance CI was pending and AMD performance CI was skipped. Completed performance CI would provide independent confirmation of the author's measurements and engine compatibility.
Final Verdict

Status: ✅ Approve. No changes requested.

@clickhouse-gh clickhouse-gh Bot added pr-ci can be tested Allows running workflows for external contributors comp-testing Test content only (no production code). labels Nov 5, 2026
@egor-click

Copy link
Copy Markdown
Contributor

i am not sure about this part, i think longer tests still make sense if they are good, so time alone shouldn’t be a metric

if coverage based selection if tests to run experiment will work, this would not be necessary

correct me if i am understanding this pr wrong

@groeneai

groeneai commented Nov 5, 2026

Copy link
Copy Markdown
Collaborator Author

The selection was by time only (> 1 s, from @ Algunenano's ask on #129176, tracked in #129258), but nothing is dropped: each of the 9 queries runs again with the same text on fewer rows, and the long version stays in the file as disabled. They are single-threaded scans, so 10M rows instead of 1M only repeat the same per-row work; in local A/A runs the noise thresholds of the new queries were 1-6% (old 1-5%). The one shift in what is measured is the text-index build: at 2_500 rows more posting lists are embedded in the dictionary.

If you'd rather keep the long versions running until the coverage-based selection has results, I'll leave this PR as it is; that's for you and @ Algunenano to decide.

@egor-click
egor-click added this pull request to the merge queue Nov 12, 2026
Merged via the queue into ClickHouse:master with commit 97f9031 Nov 12, 2026
548 of 550 checks passed
@robot-clickhouse-ci-2 robot-clickhouse-ci-2 added the pr-synced-to-cloud The PR is synced to the cloud repo label Nov 12, 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-testing Test content only (no production code). 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