Skip to content

Run the JSON(max_dynamic_paths = 4) and Dynamic queries of generate_random_json on half and a third of their rows - #132277

Merged
Algunenano merged 1 commit into
ClickHouse:masterfrom
groeneai:groeneai/perf-generate-random-json-fewer-rows
Nov 18, 2026
Merged

Algunenano merged 1 commit into
ClickHouse:masterfrom
groeneai:groeneai/perf-generate-random-json-fewer-rows

Conversation

@groeneai

@groeneai groeneai commented Nov 17, 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

Query 1 (JSON(max_dynamic_paths = 4), 3M rows) and query 2 (Dynamic, 300M rows) of generate_random_json.xml take 1.30 / 1.99 s on MasterCI amd and 0.95 / 1.44 s on arm. The time is generateRandom work on 8 / 12 threads; about a third of query 1's CPU is the contention on a shared reference counter that #122464 removes.

No existing query number or text changes: 2 queries are disabled and 2 copies appended as 5 and 6. The copies are the same queries with LIMIT 1500000 and LIMIT 100000000: the same seeds, schema and block size (1003 and 27777 rows), so each stream generates fewer identical blocks.

On two official master builds 7 weeks apart (2731aee, d076efd) the copies take 0.98-1.00 of their originals' user time per row. Query 1's copy keeps 0.95 / 0.99 of the original's growth in per-row CPU from 1 to 8 threads: that growth is the contention the open #122464 removes, which cut the user time to 0.66 amd / 0.67 arm in its CI run. Query 2 has not moved by 5% on both arches in any CI comparison since #107966 added it, so its copy is checked for the same per-row cost and the same absence of contention. Under perf.py the copies take 1.00-1.01 of the originals' per-row user time.

Projected copy medians: 0.65 / 0.67 s amd, 0.48 s arm; about 24 s (amd) and 17 s (arm) less query time per master perf job. The copies restart the history of 2 queries.

Validation: on the final file perf.py runs only queries 0 and 3-6 (also with --max-queries 10), no run trend.

🤖 Generated with Claude Code


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

Version info

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

…ate_random_json` on half and a third of their rows

No existing query number or text changes: 2 queries are disabled and 2 copies
appended as 5 and 6.

Query 1 (`JSON(max_dynamic_paths = 4)`, 3M rows) and query 2 (`Dynamic`, 300M
rows) take 1.30 / 1.99 s on MasterCI amd and 0.95 / 1.44 s on arm: generateRandom
work on 8 / 12 threads, a third of query 1's CPU being the shared reference
counter contention that ClickHouse#122464 removes.

The copies are the same queries with LIMIT 1500000 and LIMIT 100000000: the same
seeds, schema and block size (1003 / 27777 rows), so each stream generates fewer
identical blocks and the work per row is unchanged.

On the official master builds 2731aee and d076efd, per-row user time of the
copies is 0.975-1.000 of the originals' (clickhouse local) and 0.999-1.008 under
perf.py; query 1's copy keeps 0.951 / 0.987 of the original's per-row CPU growth
from 1 to 8 threads (the contention), query 2's copy stays at 1.00-1.02 (none).

Projected copy medians 0.65 / 0.67 s amd and 0.48 s arm: about 24 s (amd) and
17 s (arm) less query time per master perf job.

Related: ClickHouse#129258

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 review of the same diff (1 nit, fixed in the PR description).

Checked: perf.py keeps a disabled query in its list, so queries 0-4 keep their numbers; CIDB has never recorded a query index above 4 for this test, so 5 and 6 are fresh; in StorageGenerateRandom.cpp the schema comes from the seed and the block size from preferred_block_size_bytes and that schema, so the LIMIT only changes how many blocks each stream generates (the stream count clamp needs more than 1495 threads to apply to the copies).

Session id: cron:clickhouse-review-slot-10:20261117-070900

@groeneai

Copy link
Copy Markdown
Collaborator Author
Pre-PR validation gate (click to expand)
# Question Answer
a Deterministic repro? The cost: query 1 / 2 take 1.30 / 1.99 s on MasterCI amd, 1.20 / 1.68 s under a local perf.py pass on the official master build; the seeded generator returns the same rows every run.
b Root cause explained? generateRandom work over 3M JSON documents and 300M Dynamic values on 8 threads; a third of query 1's CPU is the shared reference counter contention #122464 removes.
c Fix matches root cause? The copies keep the seeds, schema and block size (1003 / 27777 rows, a prefix of the same rows on two builds) and only produce fewer blocks per stream. No setting, thread count or generator argument changes.
d Test intent preserved / new tests added? Per-row user time of the copies 0.98-1.00 (clickhouse local) and 1.00-1.01 (perf.py) of the originals; query 1's copy keeps 0.95 / 0.99 of the 1-to-8-thread contention; query 2's copy stays contention-free. No test of the harness.
e Both directions demonstrated? Originals 1.20 / 1.68 s vs copies 0.59-0.60 / 0.57 s locally; each checker reddens on a synthetic slow copy, a copy that loses the contention and a disabled query that runs.
f Fix is general across code paths? N/A (test-only). Every query of the file above 1 s is handled; queries 0, 3, 4 are below 1 s.
g Fix generalizes across inputs (params/datatypes/wrappers)? Two master builds 7 weeks apart, CI's run policy with and without --max-queries 10; arm by projection (same work per row on 12 threads).
h Backward compatible? (maintainer-approved exception only) No setting, format or compatibility surface; queries 0-4 keep their numbers and text, the copies take fresh numbers 5 and 6.
i Invariants and contracts preserved? perf.py --print-queries lists master's 5 queries first, byte-identical; the disabled queries never reach a query log; every measured run used 8 threads.

Session id: cron:clickhouse-impl-slot-6:20261117-064800

@clickhouse-gh

clickhouse-gh Bot commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [f0e6f12]

Summary: ✅


AI Review

Summary

PR #132277, head f0e6f1288b3571d6f094f60a1ae1d0b4603b1791, shortens the JSON(max_dynamic_paths = 4) and Dynamic performance workloads by disabling their original entries and appending smaller equivalents. The change preserves existing query indexes and the generator's schema, block size, and CI concurrency. No actionable findings.

Missing context / blind spots
  • ⚠️ Timing and contention-retention measurements are author-reported in the PR description. They were not independently rerun: this checkout has no ClickHouse binary or perf.py dependencies, and performance.ci has no completed run for this PR. A completed performance comparison would provide independent timing confirmation.
Final Verdict

Status: ✅ Approve

@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 17, 2026
@Algunenano Algunenano self-assigned this Nov 18, 2026
@Algunenano
Algunenano added this pull request to the merge queue Nov 18, 2026
Merged via the queue into ClickHouse:master with commit 86f3303 Nov 18, 2026
571 of 573 checks passed
@robot-clickhouse robot-clickhouse added the pr-synced-to-cloud The PR is synced to the cloud repo label Nov 18, 2026
@clickhouse-gh clickhouse-gh Bot added comp-json-datatype JSON/Dynamic/Object datatype: semi-structured column storage, typed and dynamic paths, sub-object... 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-json-datatype JSON/Dynamic/Object datatype: semi-structured column storage, typed and dynamic paths, sub-object... 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