Skip to content

Make test 01035_avg four times cheaper - #124000

Merged
azat merged 1 commit into
ClickHouse:masterfrom
groeneai:groeneai/speed-up-test-01035-avg
Oct 5, 2026
Merged

azat merged 1 commit into
ClickHouse:masterfrom
groeneai:groeneai/speed-up-test-01035-avg

Conversation

@groeneai

@groeneai groeneai commented Oct 5, 2026 •

Copy link
Copy Markdown
Collaborator

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

Related: #116101

01035_avg fails with Test runs too long (> 180s) in Stateless tests (amd_tsan, s3 storage, targeted): 192 s on #116101 and 248 s twice on #118721. On master over 30 days it ran over 180 s 20 times in amd_tsan, s3 storage, parallel (max 439 s, p99 213 s) and reached 185 s in amd_msan, parallel.

The test inserts 1,000,000 rows of 18 wide computed columns (Int256, UInt256, Decimal256 defaults, about 79 MiB compressed) and scans them four times, so its cost is linear in the row count. In the slow targeted runs the big scan read S3 at 1-5 MB/s instead of 100-600 MB/s in other runs of the same job; I did not isolate why (the profiles are in the S3 HTTP body read path that #116222 rewrites), and this PR does not change it.

The test now inserts 250,000 rows; reference lines 2-5 are regenerated, the empty-table and Int8 overflow lines are unchanged. The assertions are the same exact averages over the same expressions and types: 8 and 16 bit columns still wrap (250,000 > 65,536), and a local-disk read still uses 2 or more streams (32 marks; 100,000 rows would drop to one stream).

Validation: the new reference values match a direct recomputation from numbers(250000) without MergeTree (the same query reproduces the old reference for 1,000,000 rows). 50/50 randomized runs pass. With the tsan binary from #116101 on a local disk, the test takes 2.6-3.4 s instead of 8.7-11.9 s.


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

Version info

  • Merged into: 26.10.1.1621-master (included in 26.10 and later)
  • Backported to: 26.9.26.27, 26.8.35.24, 26.3.61.20

The test inserted 1,000,000 rows of 18 wide computed columns (Int256,
UInt256, Decimal256 defaults, about 79 MiB compressed) and scanned them
four times. Under tsan with s3 storage it exceeded the 180 s budget of
the targeted lane (192 s on ClickHouse#116101, 248 s on ClickHouse#118721) and ran over
180 s 20 times on master in 30 days in `amd_tsan, s3 storage, parallel`.

Insert 250,000 rows instead and regenerate reference lines 2-5. The
assertions stay exact averages over the same expressions and types:
8 and 16 bit columns still wrap, and a local-disk read still uses at
least 2 streams (32 marks, above the 24-mark concurrent-read minimum).
The new values match a direct recomputation from numbers(250000).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@groeneai groeneai added can be tested Allows running workflows for external contributors groeneai-origin-request PR origin: a maintainer pinged or directed groeneai labels Oct 5, 2026
@groeneai

groeneai commented Oct 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, no action).

# Sev Finding Verdict Evidence / action
1 💡 "32 marks" vs the 31 data marks the concurrent-read check counts DROPPED Both exceed the 24-mark minimum; system.parts.marks reports 32 as stated.

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

Session id: cron:clickhouse-review-slot-10:20261005-101100

@groeneai

groeneai commented Oct 5, 2026

Copy link
Copy Markdown
Collaborator Author
Pre-PR validation gate (click to expand)
# Question Answer
a Deterministic repro? The cost is deterministic and linear in rows: with the tsan binary from #116101 on a local disk the INSERT takes 7.4-8.8 s for 1,000,000 rows and 1.8-2.0 s for 250,000, every run. The 180 s verdict is the CI lane's own measurement (3 targeted-lane failures, 20 master runs over 180 s in 30 days).
b Root cause explained? The test inserts 1,000,000 rows of 18 wide computed columns and scans about 79 MiB four times; under tsan with a slow randomized S3 read (1-5 MB/s in the failing runs) or msan CPU cost, one run exceeds 180 s.
c Fix matches root cause? It removes three quarters of the work without changing what is asserted. No tags, pins or exemptions.
d Test intent preserved / new tests added? Same exact averages over the same 18 expressions and types; 8/16 bit wrap-around, Decimal conversion values, multi-stream merge and the empty-table and Int8 overflow checks are all kept.
e Both directions demonstrated? Old 8.7-11.9 s vs new 2.6-3.4 s on the CI tsan binary; both outputs match their references byte for byte.
f Fix is general across code paths? N/A (test-only change).
g Fix generalizes across inputs (params/datatypes/wrappers)? Same type matrix (Int8-Int256, UInt8-UInt256, Float32/64, Decimal32-256). 250,000 > 65,536 keeps the narrow types wrapping; all values are exact, so stream split and block size do not matter (50/50 randomized runs).
h Backward compatible? (maintainer-approved exception only) N/A (test-only change).
i Invariants and contracts preserved? Reference lines 1 and 6 are byte-identical; lines 2-5 match a direct recomputation from numbers(250000), and the same query reproduces the old reference for 1,000,000 rows. EXPLAIN PIPELINE shows 2 read streams at max_threads = 3 (100,000 rows would be 1).

Session id: cron:clickhouse-impl-slot-5:20261005-095600

@clickhouse-gh

clickhouse-gh Bot commented Oct 5, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [ff19ada]

Summary: ✅


AI Review

Summary

This PR makes tests/queries/0_stateless/01035_avg.sql cheaper by reducing the inserted fixture from 1,000,000 to 250,000 rows and regenerating the affected reference lines. I do not see a contract regression in the current diff: 250000 rows still preserve the narrow-type wrap-around and aggregate-expression coverage this test relies on, while materially reducing the amount of MergeTree data the targeted S3/TSan lane has to read and aggregate.

Final Verdict
  • Status: ✅ Approve

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

@azat azat left a comment

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.

Nothing in history says that it should scan that much rows, so OK

@azat azat self-assigned this Oct 5, 2026
@clickhouse-gh clickhouse-gh Bot added the comp-testing Test content only (no production code). label Oct 5, 2026
@azat
azat added this pull request to the merge queue Oct 5, 2026
Merged via the queue into ClickHouse:master with commit 289363a Oct 5, 2026
149 checks passed
@robot-clickhouse robot-clickhouse added the pr-synced-to-cloud The PR is synced to the cloud repo label Oct 5, 2026
@PedroTadim

Copy link
Copy Markdown
Member

Backporting to fix CI

@robot-ch-test-poll4 robot-ch-test-poll4 added the pr-backports-created Backport PRs are successfully created, it won't be processed by CI script anymore label Oct 29, 2026
@robot-clickhouse robot-clickhouse added the pr-must-backport-synced The `*-must-backport` labels are synced into the cloud Sync PR label Oct 29, 2026
clickhouse-gh Bot added a commit that referenced this pull request Oct 29, 2026
Backport #124000 to 26.9: Make test 01035_avg four times cheaper
clickhouse-gh Bot added a commit that referenced this pull request Oct 29, 2026
Backport #124000 to 26.8: Make test 01035_avg four times cheaper
PedroTadim added a commit that referenced this pull request Oct 29, 2026
Backport #124000 to 26.3: Make test 01035_avg four times cheaper
@clickhouse-gh clickhouse-gh Bot added comp-aggregate-functions Aggregate function implementations (sum, avg, count, quantile, combinators, 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-aggregate-functions Aggregate function implementations (sum, avg, count, quantile, combinators, etc.). groeneai-origin-request PR origin: a maintainer pinged or directed groeneai pr-backports-created Backport PRs are successfully created, it won't be processed by CI script anymore pr-ci pr-must-backport-synced The `*-must-backport` labels are synced into the cloud Sync PR pr-synced-to-cloud The PR is synced to the cloud repo v26.3-must-backport

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants