Skip to content

Hash pre-built JSON values in the hashing_serialized_values performance test - #124728

Merged
alexey-milovidov merged 1 commit into
ClickHouse:masterfrom
groeneai:hashing-serialized-values-prebuilt-json
Oct 9, 2026
Merged

alexey-milovidov merged 1 commit into
ClickHouse:masterfrom
groeneai:hashing-serialized-values-prebuilt-json

Conversation

@groeneai

@groeneai groeneai commented Oct 8, 2026 •

Copy link
Copy Markdown
Collaborator

Related: #117318

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

Query #1 of the hashing_serialized_values performance test now hashes JSON values built at fill time instead of casting strings to JSON inside the measured query.

Description

Performance Comparison (arm_release, master_head, 5/6) failed on #117318 with hashing_serialized_values #1 (+15.8%) as its only blocker (report), although #117318 only changes MergeTreeIndexBloomFilter.cpp. Since 2026-09-25 this query is 10% or more slower on the tested side in about 2% of arm runs, master-vs-master runs included.

Query #1 cast a String to JSON inside the measured query, so in that job's CPU profile about 80% of its time was the JSON parser and about 12% the hash the test is about. The parse has a per-server-process slow mode: in the same jobs new_json_type #0, which only parses JSON, moves together with it (r = 0.89 on arm, 0.90 on amd), while #0 and #2 of this test do not. In the red run the tested server drew it on all 7 runs (1.78-1.88 s vs 1.58 s); after the confirmation restart it ran 1.56-1.57 s.

Now the JSON column is built once at fill time in a Memory table, and #1 hashes the stored column with max_threads = 1 (single-threaded, as before and as #2). #0 and #2 are unchanged; JSON parsing stays measured by new_json_type.

Validated with the official master release build (amd): under the CPU profiler the old #1 is 72% parse and 26% hash, the new one has no parse samples and 99% hash, at 0.49 s per run. perf.py --stop-merges on two servers runs the test without errors, every run under 2 s. The slow mode did not appear on my x86 host (old #1 p10-p90 spread 1.4% across 24 fresh servers), so the variance drop is for arm CI to confirm.

🤖 Generated with Claude Code


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

Version info

  • Merged into: 26.10.1.1975-master (included in 26.10 and later)

…ce test

Query ClickHouse#1 cast a String to JSON inside the measured query, so most of its
CPU (about 80% in the arm CI profile, 72% on x86 locally) went to the
JSON parser rather than to the serializing hash the test exists for. The
parse has a per-server-process slow mode, so a slow draw on the tested
server read as a hashing regression and turned unrelated PRs red
(Performance Comparison on ClickHouse#117318: +15.8%, gone after a server restart).

Build the JSON column once at fill time in a Memory table and hash the
stored column, single-threaded as before and as in query ClickHouse#2. JSON parsing
itself stays measured by new_json_type.

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 8, 2026
@groeneai

groeneai commented Oct 8, 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 💡 Query #0 of this test runs about 2.06 s on arm, above the report's 2 s single-run budget AGREE, not in this PR Listed as "too long" only; it never fails a shard (report.py keeps it out of the error count). Unrelated to the #1 red.

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

Session id: cron:clickhouse-review-slot-11:20261008-200200

@groeneai

groeneai commented Oct 8, 2026

Copy link
Copy Markdown
Collaborator Author
Pre-PR validation gate (click to expand)
# Question Answer
a Deterministic repro? The defect (the query measures the parser) reproduces on every run: under the CPU profiler, old #1 is 71.5% parse samples on the official master release build (amd). The per-process slow draw itself cannot be produced on demand off arm and did not appear on my x86 host.
b Root cause explained? #1 cast String to JSON inside the measured query (about 80% of CPU in the red job's profile), and that parse has a per-server-process slow mode, so a slow draw on the tested server reads as a hashing regression.
c Fix matches root cause? Yes: the parse moves to fill time, so the parser's per-process mode no longer reaches #1. No widened bound, tag or harness change.
d Test intent preserved / new tests added? #1 still hashes one JSON value per row through the serializing hash (98.8% of its samples). Test-only change, no new test needed.
e Both directions demonstrated? Old #1: 71.5% parse / 25.6% hash, 0.93 s. New #1: 0 parse samples / 98.8% hash, 0.49 s. Variance direction not measurable locally (old #1 spread 1.4% across 24 fresh servers).
f Fix is general across code paths? #0 (Variant cast) and #2 (fill-time states) carry no parse and are quiet in CI; JSON parsing stays measured by new_json_type.
g Fix generalizes across inputs (params/datatypes/wrappers)? Same JSON shape as before (one path a, Int64); 4M rows keep the run inside [0.10, 1.0] s.
h Backward compatible? (maintainer-approved exception only) Test-only; no settings, formats or defaults change.
i Invariants and contracts preserved? Query indexes 0/1/2 unchanged, create/fill/drop symmetric, {{/}} escaping kept; perf.py --stop-merges runs the XML on two servers without errors.

Session id: cron:clickhouse-impl-slot-6:20261008-191900

@clickhouse-gh

clickhouse-gh Bot commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [cc3bb2a]

Summary: ✅


AI Review

Summary

This PR changes tests/performance/hashing_serialized_values.xml so query #1 hashes prebuilt JSON values from a Memory table instead of casting strings to JSON inside the measured query. I did not find any correctness or benchmark-contract problems in the current diff: the measured expression still uses the non-contiguous JSON hash path (serializeForHashCalculation), setup and teardown stay symmetric, and the PR metadata matches a CI Fix or Improvement.

Final Verdict
  • Status: ✅ Approve

@clickhouse-gh clickhouse-gh Bot added the pr-ci label Oct 8, 2026
@groeneai
groeneai requested a review from egor-click October 8, 2026 20:33
@clickhouse-gh clickhouse-gh Bot added the comp-testing Test content only (no production code). label Oct 8, 2026
@alexey-milovidov alexey-milovidov self-assigned this Oct 9, 2026
@alexey-milovidov
alexey-milovidov added this pull request to the merge queue Oct 9, 2026
Merged via the queue into ClickHouse:master with commit 201282f Oct 9, 2026
152 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 Oct 9, 2026
@clickhouse-gh clickhouse-gh Bot added comp-regular-function Regular scalar functions: string processing, data conversion, arithmetic, math, comparison, condi... 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-regular-function Regular scalar functions: string processing, data conversion, arithmetic, math, comparison, condi... groeneai-origin-request PR origin: a maintainer pinged or directed groeneai 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