Skip to content

Run the all-unique-pattern queries of re2_regex_caching on a quarter of their rows - #132233

Merged
Algunenano merged 1 commit into
ClickHouse:masterfrom
groeneai:groeneai/perf-re2-regex-caching-quarter-copies
Nov 18, 2026
Merged

Algunenano merged 1 commit into
ClickHouse:masterfrom
groeneai:groeneai/perf-re2-regex-caching-quarter-copies

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

The like and match queries of re2_regex_caching.xml with an all-unique non-constant pattern (entries 2 and 5) take 1.79 / 1.57 s on MasterCI amd and 1.30 / 1.15 s on arm. Both compile one regexp per row, the miss path of the local regexp cache the file was written for (#37544); every other entry takes 0.01-0.04 s.

No existing query number or text changes: 2 queries (entries 2-7) are disabled and 4 (6 entries) appended as 8-13. The marker covers all expansions, so the four low-distinctness patterns return verbatim as 9, 10, 12, 13 through two new substitutions, and the all-unique ones run on every 4th number of the same range with max_block_size = 16384: the same 23 blocks, a quarter of the rows each, still one compilation per row.

Per row the copies take 0.97-1.01 of the originals' user time. The two MasterCI comparisons that moved both entries on both arches, the merges of #119039 (stack canaries, 1.03-1.05) and #117346 (clang 23, 0.97-0.99), moved the originals locally by 1.028-1.029 and 0.960-0.976, the copies by 1.027 and 0.964-0.970 (official builds, paired user time, 12 runs).

In a local perf.py run the copies take 0.25 of the originals' time: projected about 0.45 / 0.40 s on amd and 0.33 / 0.29 s on arm, so about 30 s (amd) and 22 s (arm) less query time per master perf job. They restart the history of these 6 entries.

Validation: on the final file perf.py runs only entries 0, 1 and 8-13 (also with --max-queries 10 --soft-max-queries), with 375000 regexp cache misses per execution of 8 and 11.

🤖 Generated with Claude Code


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

Version info

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

…r of their rows

No existing query number or text changes: 2 queries (entries 2-7) are
disabled and 4 (6 entries) appended as 8-13. The `disabled` marker covers
every expansion of a query, so the four low-distinctness patterns return
verbatim as 9, 10, 12, 13 through two new substitutions.

Entries 2 and 5 (`like` / `match` with an all-unique non-constant
pattern) compile one regexp per row of `numbers_mt(1500000)` and take
1.79 / 1.57 s on MasterCI amd, 1.30 / 1.15 s on arm. Their copies (8, 11)
run on every 4th number of the same range, `numbers_mt(0, 1500000, 4)`,
with `max_block_size = 16384`: the same 23 blocks, a quarter of the rows
each, one compilation per row (375000 regexp cache misses) and a full
1000-bucket local cache per block.

Probe on official builds (paired user time, n = 12): per row the copies
take 0.97-1.01 of the originals' user time; the ClickHouse#119039 merge moved the
originals by 1.029 / 1.028 and the copies by 1.027 / 1.027, the ClickHouse#117346
merge 0.960 / 0.976 and 0.964 / 0.970 (MasterCI: 1.03-1.05 and 0.97-0.99).

In a local perf.py run the copies take 0.253 / 0.254 of the originals'
time; projected onto MasterCI that is 0.45 / 0.40 s on amd and
0.33 / 0.29 s on arm, about 30 s (amd) and 22 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 cold review (0 findings). Nothing to adjudicate.

Session id: cron:clickhouse-review-slot-9:20261117-044101

@groeneai

Copy link
Copy Markdown
Collaborator Author
Pre-PR validation gate (click to expand)
# Question Answer
a Deterministic repro? The cost is deterministic: entries 2 and 5 take 2.39 / 2.05 s in a local perf.py pass on the official master build (CI medians 1.79 / 1.57 s amd), with 1500000 regexp cache misses per execution on every commit; their copies 0.61 / 0.52 s on the same servers.
b Root cause explained? Each row of numbers_mt(1500000) builds a different pattern, so every row compiles one regexp (the local cache's miss path, 8.9 / 7.8 us of user time per row on CI amd), over 23 blocks of 65409 rows on 8 threads: 3 rounds on amd, 2 on arm's 12 threads. Time is linear in rows; nothing regressed (stable since April).
c Fix matches root cause? Test-only: the row count is the cost, so the copies run the same per-row work on every 4th number of the same range. The two {needle_*} queries are disabled, not changed.
d Test intent preserved / new tests added? Same path: the same numbers, digit lengths and pattern shapes, the same 23 blocks (16384 rows each), one compilation per row (375000 misses) and a full 1000-bucket cache per block; per-row user time 0.97-1.01 of the originals'. The four low-distinctness (hit path) patterns run verbatim as 9, 10, 12, 13 with the same 230 misses.
e Both directions demonstrated? Master's file runs entries 0-7, the final file 0, 1 and 8-13 and never 2-7 (also with --max-queries 10 --soft-max-queries). On the two real build pairs that moved both entries on MasterCI the copies move like the originals: #119039 1.027 / 1.027 vs 1.029 / 1.028 (CI 1.03-1.05), #117346 0.964 / 0.970 vs 0.960 / 0.976 (CI 0.97-0.99); paired user time, 12 runs.
f Fix is general across code paths? Both functions (like, match) and all six patterns still run; only the row count and block size of the two all-unique copies change.
g Fix generalizes across inputs (params/datatypes/wrappers)? N/A (performance test change); the patterns, haystacks and functions are unchanged.
h Backward compatible? (maintainer-approved exception only) No setting, format, perf.py or CI change; entries 8-13 are fresh history keys (highest ever recorded: 7), 2-7 end their series.
i Invariants and contracts preserved? Entries 0-7 keep their text and number (perf.py --print-queries identical), {numbers}, {needle_like} and {needle_match} are unchanged, the copies follow the last query, no create or fill added; 8 enabled entries before and after.

Session id: cron:clickhouse-impl-slot-5:20261117-043000

@clickhouse-gh

clickhouse-gh Bot commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [435df0a]

Summary: ✅


AI Review

Summary

The PR reduces the all-unique-pattern like and match benchmarks to 375,000 rows, preserves existing query history IDs, and restores all four low-distinctness cases verbatim. No actionable findings; the documented paired benchmark results support the workload reduction.

Missing context / blind spots
  • ⚠️ No ClickHouse binary is available locally. Query expansion and selection checks passed, but timings and RegexpLocalCacheMiss counts rely on the PR's reported measurements. A focused perf.py run would independently confirm those results.
Final Verdict

Status: ✅ Approve

@clickhouse-gh clickhouse-gh Bot added the pr-ci label Nov 17, 2026
@clickhouse-gh clickhouse-gh Bot added 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 3f8a4d3 Nov 18, 2026
385 of 386 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-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... 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