Skip to content

Lower test concurrency on the azure ASan functional shard - #107441

Merged
alexey-milovidov merged 1 commit into
ClickHouse:masterfrom
groeneai:ci-azure-asan-lower-test-concurrency
Jun 14, 2026
Merged

alexey-milovidov merged 1 commit into
ClickHouse:masterfrom
groeneai:ci-azure-asan-lower-test-concurrency

Conversation

@groeneai

@groeneai groeneai commented Jun 14, 2026 •

Copy link
Copy Markdown
Collaborator

Related: #107414

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

The Stateless tests (arm_asan_ubsan, azure, parallel) shard fell through to the default worker count (cpu_count() * 0.6, ~19 on the ARM_MEDIUM runner) with no memory-aware reduction, unlike MSan and DatabaseReplicated (both * 0.4).

That shard runs only under ASan (resident set roughly tripled) plus azurite. With ~19 heavy queries co-scheduled the aggregate hits the shared server cap (current RSS: 53.69 GiB, maximum: 53.69 GiB) and the OvercommitTracker stops queries across all concurrent tests at once, knocking out several unrelated tests in one ~30s window.

CIDB over the last ~28 days, excluding the 2026-06-09/06-10 Azure outage days: 187 OvercommitTracker / RSS-cap failures across 148 distinct tests and 59 PRs (00084_external_aggregation alone on 6 PRs).

Fix: apply the same lever already accepted for MSan (commit e1705ed, "reduce number of tests in parallel for MSan, from 19 to 12") to the azure ASan shard, cpu_count() * 0.4. On a 32-core runner this is 19 -> 12 workers; peak concurrent RSS stays under the cap. No other shard is affected.

Version info

  • Merged into: 26.6.1.794

The "Stateless tests (arm_asan_ubsan, azure, parallel)" shard fell through to
the default worker count (cpu_count() * 0.6, ~19 on the ARM_MEDIUM runner). It
got no memory-aware concurrency reduction, unlike MSan and DatabaseReplicated
(both cpu_count() * 0.4).

That shard runs only under ASan, where each query's resident set is roughly
tripled, and azurite (the local Azure blob emulator) adds further pressure.
With ~19 heavy queries co-scheduled, the aggregate hits the shared server
memory cap (current RSS: 53.69 GiB, maximum: 53.69 GiB) and the
OvercommitTracker starts stopping queries across all concurrent tests at once,
knocking out several unrelated tests in the same ~30s window. CIDB shows this
cascade over the last ~28 days excluding the 2026-06-09/06-10 Azure outage
days: 187 OvercommitTracker/RSS-cap failures across 148 distinct tests and 59
PRs (00084_external_aggregation alone on 6 PRs).

Apply the same lever already accepted for MSan in commit e1705ed ("ci:
reduce number of tests in parallel for MSan, from 19 to 12"): set the azure FT
worker count to cpu_count() * 0.4, so peak concurrent RSS stays under the cap.
On a 32-core runner this is 19 -> 12 workers. No other shard is affected; the
azure sequential shard (already on the smaller ARM_SMALL_MEM runner) also
narrows from 19 to 12, which is harmless for serialized tests.

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

Copy link
Copy Markdown
Collaborator Author

Pre-PR validation gate

# Question Answer
a Deterministic repro? This is a CI concurrency change, not a code bug. The mechanism is deterministic: on the azure ASan shard the worker count is cpu_count() * 0.6 (~19 on a 32-core runner). A standalone simulation of the exact nproc elif-chain confirms 19 -> 12 workers after the change, and 0 change for every other shard (amd_debug, non-azure arm_asan_ubsan, msan, binary, DatabaseReplicated).
b Root cause explained? The shard runs only under ASan (resident set ~3x) plus azurite. ~19 co-scheduled heavy queries (2-3.5 GiB each per CIDB) exceed the shared server cap (current RSS: 53.69 GiB, maximum: 53.69 GiB); the OvercommitTracker then stops queries across all concurrent tests at once, the cascade in #107414. The shard had no memory-aware reduction, unlike MSan / DatabaseReplicated (* 0.4).
c Fix matches root cause? Yes. The root cause is too many concurrent heavy queries vs the server memory cap; the fix lowers the worker count (* 0.4), reducing peak concurrent RSS so it stays under the cap. It does not widen any limit or mask failures. Identical lever to the accepted MSan precedent e1705ed.
d Test intent preserved / new tests added? N/A — no test assertions changed and no test is disabled or skipped. Every test still runs with full coverage, only fewer at a time. A standalone CI-config regression test is not warranted for a one-line concurrency divisor.
e Both directions demonstrated? Simulation of the elif-chain: BEFORE = 19 workers (the over-commit condition), AFTER = 12 workers (matches the MSan-accepted level), and no other parametrization changes. CIDB sizes the BEFORE problem: 187 OvercommitTracker/RSS-cap failures / 148 tests / 59 PRs over 28 days excluding the 06-09/06-10 outage days.
f Fix is general, not a narrow patch? Yes. It fixes the cause (host-level concurrency vs cap) for the whole shard, not one hog test. It does not tag or disable individual tests (e.g. 00084_external_aggregation), so it covers all 148 affected tests and any future ones. Sibling memory-pressure shards (MSan, DatabaseReplicated) already use the same * 0.4; this brings the azure ASan shard in line.

Session id: cron:clickhouse-worker-slot-1:20260614-161500

@groeneai

Copy link
Copy Markdown
Collaborator Author

cc @maxknv for CI-infra review: lowers the azure ASan functional shard to cpu_count() * 0.4 (19 -> 12 workers), mirroring the MSan precedent e1705ed, to stop the OvercommitTracker cascade on that shard. Requested by @alexey-milovidov in #107414.

@alexey-milovidov alexey-milovidov added the can be tested Allows running workflows for external contributors label Jun 14, 2026
@clickhouse-gh

clickhouse-gh Bot commented Jun 14, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [536f6a3]

Summary: ✅


AI Review

Summary

This PR lowers the worker count for the current azure functional-test surface, which is only Stateless tests (arm_asan_ubsan, azure, parallel) and Stateless tests (arm_asan_ubsan, azure, sequential), from cpu_count() * 0.6 to cpu_count() * 0.4. The change is scoped to CI scheduling, matches the existing reduced-concurrency pattern for other sanitizer/memory-pressure shards, and I did not find a code-level issue that warrants an inline review comment.

Missing context / blind spots
  • ⚠️ The current PR CI report did not execute the target Stateless tests (arm_asan_ubsan, azure, parallel) shard, so this review validates the configuration logic and the related #107414 failure signature but not a before/after target-shard run. A targeted run of that shard after this change would close the loop.
Final Verdict

Status: ✅ Approve

@clickhouse-gh clickhouse-gh Bot added the pr-ci label Jun 14, 2026
@alexey-milovidov

Copy link
Copy Markdown
Member

Which exact queries were heavy? So 19 of them break the barrier?

@groeneai

Copy link
Copy Markdown
Collaborator Author

Not a single heavy query, it is the aggregate of ~19 concurrent ASan workers.

CIDB on Stateless tests (arm_asan_ubsan, azure, parallel), last 28 days excluding the 06-09/06-10 Azure outage: 188 Code-241 (total) memory limit exceeded failures over 149 tests / 60 PRs, every one quoting the shared server cap current RSS: 53.69 GiB, maximum: 53.69 GiB.

No single query gets near that cap. Across every killed query in those logs the query's own ask is median 0.76 GiB, p90 4.70 GiB, max 7.39 GiB, and 0 ask >= 10 GiB. The barrier is broken by the sum, not by one query.

The genuinely heavy ones (5-7 GiB peak each, ASan roughly 3x RSS): 01603_read_with_backoff_bug (7.4), 00084_external_aggregation (GROUP BY URL on test.hits), the TPC-H/TPC-DS set (04040_tpc_h_q08, 04033_tpc_ds_q01/q40/q61/q66/q74/q78), large joins (03742_nested_loop_join_long, 03748_join_on_complex_condition_result_memory), 00906_low_cardinality_cache, 00945_bloom_filter_index, 03291_json_big_structure_deserialization. About 19 such medium/heavy workers co-scheduled, plus azurite, sum past 53.69 GiB.

The kill is then shared: 86.6% of the 149 affected tests appear exactly once. They are not heavy, they are whatever the OvercommitTracker happened to stop when total RSS hit the cap (Query was selected to stop by OvercommitTracker).

So yes, the count is the lever, not one query. Lowering 19 to 12 (cpu_count() * 0.4, the MSan level) keeps peak concurrent RSS under the cap without tagging any individual test.

Reports:

@alexey-milovidov

Copy link
Copy Markdown
Member

How much memory do TPC-H and TPC-DS queries spend?

@groeneai

Copy link
Copy Markdown
Collaborator Author

Concrete per-query peaks on that shard (each query's own MemoryTracker at the moment the OvercommitTracker selected it as the victim):

TPC-DS, the heavy ones:

  • q61 ~5.07, q01 ~4.83, q78 ~4.74, q09 ~4.45, q24 ~4.32, q04 ~4.31, q16 ~4.27, q11 ~4.20, q23 ~3.85 GiB

TPC-DS, light (selected while small, i.e. innocent victims):

  • q74 ~0.7-1.1, q25 ~0.93, q40 ~0.77, q66 ~0.65, q84 ~0.60, q67 ~0.50 GiB

TPC-H:

  • q08 ~1.5-3.2 GiB across 3 runs, q21 small

The stateless test profile caps every query at max_memory_usage = 5G, so no single TPC query can exceed ~5 GiB. Even the heaviest (q61 ~5 GiB) is under 10% of the 53.69 GiB shared server cap. Every one of these kills quotes (total) memory limit exceeded ... current RSS: ~53.7 GiB, maximum: 53.69 GiB, never a per-query limit, so it is the aggregate of ~19 concurrent ASan workers that crosses the cap, not the TPC queries individually. Dropping to 12 keeps the concurrent sum under it.

Sample report (q61, 5.07 GiB, total-cap kill): https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=104545&sha=d92a147f5c1b1a8bd0389b804f8ed18659bff00e&name_0=PR&name_1=Stateless%20tests%20%28arm_asan_ubsan%2C%20azure%2C%20parallel%29

@alexey-milovidov

Copy link
Copy Markdown
Member

@groeneai, using certain disk-spill settings, can we make some of these queries lighter, ideally under 1 GB?

@groeneai

Copy link
Copy Markdown
Collaborator Author

Partly. Disk-spill only helps the GROUP BY / sort-dominated queries, which is about half of the heavy set.

Can be brought near or under 1 GiB with max_bytes_before_external_group_by (+ max_bytes_before_external_sort):

  • 00084_external_aggregation already does exactly this: max_bytes_before_external_group_by = 200M, max_memory_usage = 1.5G then 300M. It is already a spill test.
  • The heavy TPC-DS aggregations (q01, q09, q11, q16, q23, q24, q61, q78) and TPC-H q08 are GROUP BY + top-N ORDER BY. A few-hundred-MB external threshold makes the hash table spill; the result is unchanged so the references still match. These are the 4-5 GiB peaks, so they are the biggest win. The TPC settings.json files currently set no spill threshold, so today they run fully in memory.

Cannot be capped this way:

  • Joins 03742_nested_loop_join_long and 03748_join_on_complex_condition_result_memory do not spill through those thresholds (they need join_algorithm = 'grace_hash'/'partial_merge' + max_bytes_in_join), and 03748 exists to measure join result memory, so forcing a spill defeats the test.
  • 01603_read_with_backoff_bug (~7.4 GiB, the single largest) is a read/threading test with no aggregation to spill.
  • 00906_low_cardinality_cache (LC dictionary + 100M-row scan, trivial GROUP BY), 00945_bloom_filter_index (index structures), and 03291_json_big_structure_deserialization (JSON column state) have no spill path.

One caveat on the mechanism: the OvercommitTracker stops whatever is co-scheduled when the server total crosses 53.69 GiB, and 86.6% of the affected tests are innocent victims selected while small. Spilling the aggregation tail lowers how often the total crosses, but the non-spillable hitters (01603 at 7.4 GiB, the joins) remain. So disk-spill is a useful complementary patch on the aggregation subset, not a full replacement: 19 -> 12 raises the average per-worker budget from 2.83 to 4.47 GiB and covers every query type uniformly without editing any test.

Happy to add the external-group-by/sort settings to the TPC aggregation queries if you want that in addition to, or instead of, the concurrency change.

@alexey-milovidov alexey-milovidov self-assigned this Jun 14, 2026
@alexey-milovidov
alexey-milovidov added this pull request to the merge queue Jun 14, 2026
@alexey-milovidov

Copy link
Copy Markdown
Member

@groeneai, send a follow-up PR that will enable disk spill for GROUP BY, ORDER BY, and grace hash join in TPC-H and TPC-DS tests, aiming to lower memory usage under 1 GB whenever possible. This change will also improve our test coverage.

Merged via the queue into ClickHouse:master with commit 4ca6271 Jun 14, 2026
166 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 Jun 14, 2026
@groeneai

Copy link
Copy Markdown
Collaborator Author

Follow-up PR: #107461. It enables external GROUP BY, external sort and grace hash join in the TPC-H and TPC-DS functional tests.

Peak memory on SF1 (debug), before then after:

query before after
TPC-H q08 2.6 GiB 0.48 GiB
TPC-H q09 2.0 GiB 0.73 GiB
TPC-H q21 1.4 GiB 0.16 GiB
TPC-DS q01 2.6 GiB 0.10 GiB
TPC-DS q61 5.7 GiB 0.28 GiB
TPC-DS q78 4.7 GiB 0.81 GiB
TPC-DS q23 2.8 GiB 1.4 GiB

Most heavy queries drop well under 1 GiB. TPC-DS q23 holds most of its memory in IN (subquery) set state, which these thresholds do not spill, so it stays around 1.4 GiB. Output is byte-identical with and without spill for all 22 TPC-H queries and the verified TPC-DS subset.

The settings are in the shared .lib files, not settings.json, so the in-memory performance benchmarks (tests/performance/tpc{ds,h}.xml, which read the same settings.json) are unaffected.

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