Repository navigation
Conversation
On the RE2 path, run the regexp once per distinct haystack value within a block and copy the cached result for repeats: adjacent duplicates are caught by comparing with the previous row, non-adjacent ones by a hash map. The map is switched off for blocks of mostly distinct values. The JIT path is unchanged, as a compiled match is about as cheap as the hash table probe it would save.
|
Workflow [PR], commit [5b59788] Summary: ✅
AI ReviewSummaryThe PR caches RE2 replacement results for repeated Final VerdictStatus: ✅ Approve |
…ReplaceRegexpImpl `bool inserted;` was left uninitialized in the deduplication loop, tripping clang-tidy's cppcoreguidelines-init-variables check as an error and failing the arm_tidy build (PR ClickHouse#111005). Also lower `next_distinct_ratio_check`'s initial value from 4096 to 256, per review feedback: the old value meant blocks smaller than 4096 rows never triggered the ratio check, so the mostly-distinct guard never kicked in for small `max_block_size` settings or naturally short blocks. Added a performance-test query with `max_block_size = 500` to cover this.
|
📊 Cloud Performance Report ✅ AI verdict: no significant changes detected. K_source=6 K_base=30 flagged=0/65 clickbench🟢 No significant changes tpch_adapted_1_official🟢 No significant changes Debug info
|
Resolve the conflict in ReplaceRegexpImpl.h: master threaded a ReplaceCancellationBudget through processString and processStringJIT, this branch split vectorConstantConstant into a JIT loop and a deduplicating RE2 loop. Both loops now charge the budget per row and pass it down, and the cached-result copy charges the bytes it moves.
LLVM Coverage Report
Changed lines: Changed C/C++ lines covered: 52/52 (100.00%) · Uncovered code |
Address review: the per-block deduplication only covered `vectorConstantConstant`, while `FunctionStringReplace::executeImpl` routes `FixedString` haystacks to `vectorFixedConstantConstant`, which kept the old per-row RE2 loop. Move the loop into `processStringsDeduplicated`, parameterized by how a row is addressed, and use it from both entry points. Co-Authored-By: Claude Opus 5 <[email protected]>
Cases 13 and 21 fed one repeated value to `replaceRegexpAll` and relied on the regexp running once per row. With per-block deduplication the regexp runs once for the whole block and the other rows are memcpy copies, so the work no longer outlasts the deadline and case 21 reported `stored expression: no timeout`. Vary the tail of each haystack, which keeps the per-row work the same and the values distinct. Also record the deduplication's cached-result copy in the note listing the charged sites that have no case of their own: it moves at memcpy speed over an output the 5GiB test memory profile already bounds, and the per-row charge at the top of the same loop bounds the loop regardless. Report: https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=111005&sha=34785926a56d91fbb2765d71512ad56f962687ef&name_0=PR&name_1=Stateless%20tests%20%28arm_binary%2C%20sequential%29 PR: ClickHouse#111005 Co-Authored-By: Claude Opus 5 <[email protected]>
`Fast test` failed on a hang in `04512_length_fixedstring_parallel_replicas`, which does not call `replaceRegexpOne` or `replaceRegexpAll` and cannot reach the changed code: the test has 15751 passes and this one failure over the last 30 days. Its failure gated the rest of the workflow, so there is nothing else to read yet. `CH Inc sync` reported `config failed`, which is not one of the states that can be resolved from the public repository. Report: https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=111005&sha=8b5803f549b89d3cfe796398eb62c6b4ffee8635&name_0=PR&name_1=Fast%20test PR: ClickHouse#111005 Co-Authored-By: Claude Opus 5 <[email protected]>
…dget rename Merging master renamed `ReplaceCancellationBudget` to `CancellationBudget` and moved it to its own header. The merge was textually clean because master never touched `processStringsDeduplicated`, but that function still referred to the old name and the merged tree did not compile. `04650_replace_cancellation.sh` is being removed as flaky, so the deduplication gets a test of its own that does not depend on timing. A constant pattern takes the deduplicating path while a `materialize`d one does not, so the two forms of the same call have to agree row for row. The cases cover non-adjacent repeats, adjacent repeats, blocks distinct enough to switch the map off, repeats arriving after that, repeats within small blocks, cached ranges of length zero, results of differing length, `replaceRegexpOne` and the `FixedString` entry point. Every case that can be affected was checked against a build with a deliberate off-by-one in the cached copy, and fails there. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Build profile diff (arm_release)Commit See the job log for details. |
# Conflicts: # tests/queries/0_stateless/04650_replace_cancellation.sh
A row the regexp does not match comes out identical to its input, so caching it saves only the match attempt, and for short-circuiting patterns such as '^missing' that attempt is cheaper than hashing the haystack: benchmarked against the plain loop, `replaceRegexpOne(url, '^missing', 'X')` over repetitive haystacks was 10% slower on 90-byte rows and 47% slower on 500-byte rows. Track how many rows matched, and once a block proves to be almost entirely non-matching, run a capture-free existence check first and copy rejected rows through directly. This restores the plain loop's cost for rejected rows (measured at parity or slightly faster, since the existence check skips capture extraction) while keeping the cache for rows that do match, and leaves the mostly-matching wins unchanged (2.9x on cheap anchored matches, 22x on the domain-extraction pattern). ClickHouse#111005 (comment)
The match-ratio checkpoint was gated on `map_enabled`, so once the distinct-ratio guard disabled the cache, `precheck_non_matching` could never turn itself off, and a matching suffix behind a rejecting prefix paid the capture-free pre-check plus the full match for every remaining row of the block. Decouple the checkpoint from `map_enabled` so the pre-check re-evaluates itself, and cover the reject-prefix / matching-suffix shape with a perf case and a functional test. ClickHouse#111005 (comment) Co-Authored-By: Claude Fable 5 <[email protected]> Claude-Session: https://claude.ai/code/session_014HRQrtSS2WFur32VEy83WU
|
🕵 The failure of |
|
Update to #111005 (comment): #112966 is closed as superseded by #112890. #126191 (merged) fixed the conversion, but master |
|
🕵 Thanks @groeneai for the update. The |
|
🕵 I merged the latest |
|
🕵 I merged the latest
|
|
🕵 @groeneai, investigate the failure: https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=111005&sha=949a740fe7687e91cb0b69a18bd0e7a13419dd16&name_0=PR&name_1=Build%20profile%20diff and provide a fix in a separate PR. If the fix is already in progress, link it here. It is the only failure at |
|
The The fix is already in progress in my PR #126200 (related to #120462): a readiness probe that the server rejects for its own load (exception code 202 or 241) ends the job like a read rejected for load, i.e. green with #126200 only stops the job from failing during such an outage. The memory exhaustion of the read-only service itself is on the cluster side and needs someone with access to it. |
|
🕵 Thanks @groeneai. The only red check at |
|
🕵 I merged the latest |
|
🕵 I merged the latest |
|
🕵 I merged the latest |
`clang-tidy` (`modernize-use-nodiscard`) failed the `arm_tidy` builds on `carriedWindow`, `useCache` and `usePrecheck`. https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=111005&sha=latest&name_0=PR&name_1=Build%20(arm_tidy%2C%204%2F4) PR: ClickHouse#111005 Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
🕵 The |
|
🕵 @groeneai, investigate the failure: https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=111005&sha=cad1895f6a539186b5d6f92f6576136808dbd783&name_0=PR&name_1=Performance%20Comparison%20%28amd_release%2C%20master_head%2C%202%2F6%29 and provide a fix in a separate PR. If the fix is already in progress, link it here. The only red check at |
|
Acknowledged. I'm investigating why |
|
I opened #132468, which disables The red here comes from the code layout of each build, not from this PR: in this job both servers ran the same work (7.333G vs 7.337G instructions), but this PR's binary took one extra branch miss per row in the JSON hash loop (4.143M vs 0.125M over 4M rows). ASLR is off in the job, so the slow mode is fixed per binary: the confirmation reruns at three stack placements and the dashboard reruns all reproduced it, and the job's two binaries reproduce it locally (0.495 vs 0.595 s). #124728 made this rarer but did not remove it. One correction to the list: my #129615 does change the code path of |
…rmance test Query 1 (sipHash64 over a JSON column) failed Performance Comparison (amd_release) on PRs that do not touch its code path (ClickHouse#111005: 0.526 -> 0.611 s, and another PR: 0.534 -> 0.660 s) and is marked slower on master runs. Both servers execute the same work (7.333G vs 7.337G instructions in the ClickHouse#111005 job, within 0.15% in 18 of the 19 profiled runs; the 19th is a PR that changes this loop), but the per-row loop through SerializationObject, SerializationDynamic, path iteration and four hash-map lookups lands in a slow mode in some builds: one or two extra branch misses per row (0.125M vs 4.143M over 4M rows in the ClickHouse#111005 job), or more cycles at equal misses. ASLR is off, so the mode is fixed per binary: the confirmation reruns at three stack placements and the dashboard reruns all reproduced +16.5%. The red job's two binaries reproduce it locally (0.495 vs 0.595 s, same instructions, 1M vs 21M branch misses over 5 runs). Shortening the loop does not remove the dependence (the remaining frames are about 30% slower in the slow builds too), so the query is disabled with disabled="1", which keeps the numbers and history of queries 0 and 2, and the json_values table that only it read is removed. Query 0 still measures the row-by-row serialization branch of executeGeneric, query 2 the aggregate-state path. Related: ClickHouse#111005 Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
🕵 Thanks @groeneai. #132468, which disables the unstable |
replaceRegexpOneandreplaceRegexpAll(REGEXP_REPLACE) with a constant pattern can now evaluate the regexp only once per distinct haystack value within a block on the RE2 path, copying the cached result for repeats (adjacent duplicates by comparing with the previous row, others through a hash map). Real-world string columns such as URLs and referers are highly repetitive, so this is up to an order of magnitude faster on such data. Applies toStringandFixedStringhaystacks; the JIT-compiled regexp path is unchanged.Whether the cache pays off depends on how the cost of the regexp compares with hashing the haystack, which the share of repeats alone does not tell: a cheap regexp such as
^[a-z]over long haystacks is slower with the cache even when many rows repeat, while a full scan such as[0-9]{50}wins with few repeats. So the rows are processed in windows of 32, the time per byte of each window is measured, and the cheaper of the cached and the plain mode is kept, with the other one probed again at exponentially growing intervals. The state is carried from block to block, so short blocks also reach a decision. The result never depends on the choice.Also:
^(e.g.httpfor^https?://) cannot match and are copied through without running the regexp.^that have capturing groups, for which RE2 would otherwise reject through a slower engine than its DFA.Cases 13 and 21 of
04650_replace_cancellationfed one repeated value toreplaceRegexpAlland relied on the regexp running once per row to outlast the deadline. They now vary the tail of each haystack, which keeps the per-row work the same and the values distinct.Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
replaceRegexpOneandreplaceRegexpAllwith a constant pattern evaluate the regexp only once per distinct haystack value within a block when that is measured to be cheaper. This speeds up replacement over repetitive string columns (such as URLs) when the pattern is not covered by the regexp JIT.Workflow [PR]
Sync PR [sync-upstream/pr/111005]