Skip to content

Bump vectorscan from 5.4.11 to 5.4.13 - #125774

Merged
alexey-milovidov merged 4 commits into
ClickHouse:masterfrom
actueleai:bump-vectorscan-vectorscan-5.4.13
Oct 14, 2026
Merged

alexey-milovidov merged 4 commits into
ClickHouse:masterfrom
actueleai:bump-vectorscan-vectorscan-5.4.13

Conversation

@actueleai

@actueleai actueleai commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

Bump vectorscan from 5.4.11 to 5.4.13. The fork's single patch is in upstream 5.4.13, which also fixes a stack buffer overflow in rvermicelliDoubleExecReal. The submodule stays on the ClickHouse fork (branch ClickHouse/vectorscan/5.4.13), whose only commit on top of upstream removes the nested simde submodule: Check Submodules rejects recursive submodules, and the simde backend is not used by the ClickHouse build.

ClickHouse-side changes

  • contrib/vectorscan-cmake/CMakeLists.txt — source list follows the Teddy reshuffle: teddy.c → teddy.cpp, teddy_avx2.c → teddy_fat.cpp.
  • contrib/vectorscan-cmake/common/hs_version.h — HS_VERSION_STRING and HS_PATCH updated to 5.4.13.

Changelog category (leave one):

  • Backward Incompatible Change

Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):

Update vectorscan to 5.4.13. Certain re2 patterns in match, multiMatchAny, etc. may now throw an exception.


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

Version info

  • Merged into: 26.10.1.2423-master (included in 26.10 and later)
  • Backported to: 26.9.20.14, 26.8.28.13, 26.7.31.12, 26.3.52.9

Retarget the submodule from the ClickHouse fork to upstream
VectorCamp/vectorscan and pin tag vectorscan/5.4.13 (acd7363aadea).
The fork carried a single patch (moving `#include <vector>` out of the
`HAVE_BOOST_CONTAINER_SMALL_VECTOR` fallback in `src/util/small_vector.h`);
it is obsolete because upstream merged it (VectorCamp/vectorscan#359), so
no fork branch is needed.

Adapt the explicit source list in `contrib/vectorscan-cmake/CMakeLists.txt`
to the upstream file changes: `src/fdr/teddy.c` -> `src/fdr/teddy.cpp`,
drop `src/fdr/teddy_avx2.c`, add `src/fdr/teddy_fat.cpp`. `teddy_fat.cpp`
is guarded by `HAVE_AVX2`, which is not defined in ClickHouse's
non-fat build, so it compiles to nothing here.

Update `contrib/vectorscan-cmake/common/hs_version.h` to 5.4.13 /
2026-08-23 (`HS_VERSION_STRING`, `HS_PATCH`); `HS_VERSION_32BIT` is left
unchanged, as in the previous bump.

The parser is not regenerated with ragel: upstream changed `Parser.rl`
(new nested-class / `&&` rejection rules) but regenerating is a
user-visible behaviour change deferred to a separate PR.

Includes the upstream stack buffer overflow fix in
`rvermicelliDoubleExecReal` (`src/nfa/vermicelli_simd.cpp`, fe94004d).

Co-Authored-By: Claude Code <[email protected]>
@thevar1able thevar1able added the can be tested Allows running workflows for external contributors label Oct 14, 2026
@clickhouse-gh

clickhouse-gh Bot commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [e6bbf53]

Summary: ✅


AI Review

Summary

Updates vectorscan from 5.4.11 to 5.4.13, adapts its source list, and regenerates the regex parsers. One previously reported compatibility blocker remains: valid, previously accepted character classes now cause exceptions without a way to retain their behavior. No additional inline findings were identified.

Findings

❌ Blockers

  • contrib/vectorscan-cmake/rageled_files/amd64/Parser.cpp:7923: Preserve existing literal character-class semantics. [[] represents a literal [, but SELECT multiMatchAny('[', ['[[]']); now throws Nested character classes are not supported instead of returning 1. Similarly, [a&&b] previously matched a, &, or b and now throws. These are ordinary literal-class forms under PCRE syntax. Tracing the current generated tables reaches rejection actions 272 and 260, respectively. The same parser is checked in for both architectures, and both multiMatch* and multiFuzzyMatch* use it. Existing stored filters therefore fail after upgrading. Preserve these literal forms in the fork's src/parser/Parser.rl and regenerate both parsers, or provide a compatibility control that retains the previous semantics. Existing review thread.
PR Metadata

💡 With the current parser behavior, Build/Testing/Packaging Improvement understates the user-facing compatibility change, and the required entry Update vectorscan to 5.4.13 omits migration guidance. If the rejection is retained, use:

  • Changelog category: Backward Incompatible Change.
  • Changelog entry: Update vectorscan to 5.4.13. Regular expressions used by multiMatch* and multiFuzzyMatch* now reject unescaped [ and && inside character classes. Escape literal brackets and ampersands as \[ and \& in existing patterns before upgrading.

Preserving the literal forms removes this metadata concern; documenting the rejection alone does not supply the missing compatibility path.

Missing context / blind spots
  • ⚠️ No built ClickHouse binary is available locally. The current Praktika workflow is running, with the relevant amd64/aarch64 stateless jobs pending. Successful vectorscan-enabled runs are still needed to validate the regenerated parser and upstream runtime changes; the passing fast suite skips the relevant no-fasttest tests.
Tests
  • ⚠️ Add a small stateless regression covering literal [ and repeated literal & in classes, including their escaped equivalents. Verify positive and negative results through multiMatchAny and one multiFuzzyMatch* case with edit distance zero.
  • ⚠️ Run 00926_multimatch, 02226_analyzer_or_like_combine, and 04308_text_index_function_multiMatchAny_regex_cases on vectorscan-enabled amd64/aarch64 builds after the signed-byte fix. A focused Unicode-class case should also assert that [é] matches é and does not match Ã.
Final Verdict

❌ Block. Preserve previously accepted literal classes or add a compatibility path, cover that behavior with a focused stateless test, and obtain the relevant architecture CI results. Update the changelog if any syntax rejection remains.

@clickhouse-gh clickhouse-gh Bot added pr-build Pull request with build/testing/packaging improvement submodule changed At least one submodule changed in this PR. labels Oct 14, 2026
@rschu1ze rschu1ze added the pr-must-backport Pull request should be backported intentionally. Use this label with great care! label Oct 14, 2026
@clickhouse-gh clickhouse-gh Bot added the manual approve Manual approve required to run CI label Oct 14, 2026
Comment thread contrib/vectorscan-cmake/CMakeLists.txt Resolved
@clickhouse-gh clickhouse-gh Bot added the comp-external-dependencies Third-party deps updates in contrib/, vendored code, and platform base libraries. label Oct 14, 2026
`src/parser/Parser.rl` and `src/parser/control_verbs.rl` changed between
5.4.11 and 5.4.13 (rejection of nested character classes and `&&` in
character classes, cast cleanups), so the pre-generated `Parser.cpp` and
`control_verbs.cpp` under `rageled_files/` were stale.

Generated with ragel 7.0.0.12 (`nixpkgs#ragelDev`), default `-T0` code style,
matching the style of the previous files. This ragel honours
`alphtype unsigned char` and emits `unsigned char` tables, so the output does
not depend on the signedness of `char` of the host: the `amd64` and `aarch64`
copies are byte-identical. The regeneration recipe is documented in
`contrib/vectorscan-cmake/CMakeLists.txt`.

Related: ClickHouse#125774

Co-Authored-By: Claude Fable 5.1 <[email protected]>
#line 1103 "Parser.rl"
{te = p;p = p - 1;{
#line 1103 "Parser.rl"
throw LocatedParseError("Nested character classes are not supported"); }

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[P1] Preserve previously supported literal characters inside classes

This new rejection also catches valid, previously supported character classes. For example, [[] is a class containing a literal [, so SELECT multiMatchAny('[', ['[[]']); previously returned 1; the regenerated parser now throws Nested character classes are not supported. Similarly, [a&&b] previously matched a, &, or b and now throws. These literal forms follow the ordinary PCRE character-class syntax, which treats [ specially inside a class when it introduces POSIX syntax.

This changes existing queries on both architectures, including stored filters using the multiMatch* and multiFuzzyMatch* functions. The upstream Java-style construct rejection needs to preserve existing literal-class forms, or be introduced with a compatibility control that retains their previous behavior. Please add a stateless regression for literal [ in a class. If rejecting these forms is retained as an intentional compatibility change, the PR category and changelog also need to describe the migration (escaping the literal [/& characters), rather than only announcing the dependency version.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change is okay to me. Let's accept.

The regenerated `Parser.cpp` and `control_verbs.cpp` compare the input,
read through `const char *`, against `unsigned char` transition tables
(the `.rl` files declare `alphtype unsigned char`). On amd64 `char` is
signed, so every byte >= 0x80 is negative on the left side and never
matches a table entry, and UTF-8 patterns are parsed incorrectly:
`'(?i)привет'` fails with `Hexadecimal value is greater than \x10FFFF`,
and `00926_multimatch`, `02226_analyzer_or_like_combine` and
`04308_text_index_function_multiMatchAny_regex_cases` fail.

Upstream `vectorscan` compiles exactly these two files with
`-funsigned-char` (`RAGEL_C_FLAGS`); do the same here. On aarch64 `char`
is already unsigned, so the flag is a no-op there.

CI: https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=125774&sha=c3e59208fae06b6b03964d52e01b29516d0ebeae&name_0=PR&name_1=Stateless%20tests%20%28amd_debug%2C%20parallel%29
Related: ClickHouse#125774

Co-Authored-By: Claude Fable 5.1 <[email protected]>
@alexey-milovidov
alexey-milovidov added this pull request to the merge queue Oct 14, 2026
@alexey-milovidov alexey-milovidov self-assigned this Oct 14, 2026
Merged via the queue into ClickHouse:master with commit 324e8a3 Oct 14, 2026
177 checks passed
@robot-ch-test-poll2 robot-ch-test-poll2 added pr-synced-to-cloud The PR is synced to the cloud repo pr-must-backport-synced The `*-must-backport` labels are synced into the cloud Sync PR labels Oct 14, 2026
@robot-clickhouse robot-clickhouse added the pr-backports-created Backport PRs are successfully created, it won't be processed by CI script anymore label Oct 14, 2026
@clickgapai

Copy link
Copy Markdown
Contributor

@actueleai @alexey-milovidov — this PR looks backward incompatible but is categorized as Build/Testing/Packaging Improvement.

Why: As merged, multiMatchAny(s, ['[[]']) returns 1 on 5.4.11 but throws BAD_ARGUMENTS on 5.4.13 (upstream #393 is in the regenerated Parser.cpp). This stops being backward incompatible only if the fork drops that rule, which also matters for pr-must-backport.

Suggested category: Backward Incompatible Change. Ignore if the change is intentionally non-breaking.

@clickgapai

Copy link
Copy Markdown
Contributor

@actueleai @alexey-milovidov — title/description suggestions:

Description (currently incomplete):

Ignore if intentional.

clickhouse-gh Bot added a commit that referenced this pull request Oct 15, 2026
Backport #125774 to 26.9: Bump `vectorscan` from 5.4.11 to 5.4.13
clickhouse-gh Bot added a commit that referenced this pull request Oct 15, 2026
Backport #125774 to 26.8: Bump `vectorscan` from 5.4.11 to 5.4.13
clickhouse-gh Bot added a commit that referenced this pull request Oct 15, 2026
Backport #125774 to 26.7: Bump `vectorscan` from 5.4.11 to 5.4.13
alexey-milovidov added a commit that referenced this pull request Oct 15, 2026
Backport #125774 to 26.3: Bump `vectorscan` from 5.4.11 to 5.4.13
strtgbb pushed a commit to Altinity/ClickHouse that referenced this pull request Oct 15, 2026
@egor-click

Copy link
Copy Markdown
Contributor

@actueleai @alexey-milovidov — this PR looks backward incompatible but is categorized as Build/Testing/Packaging Improvement.

Why: As merged, multiMatchAny(s, ['[[]']) returns 1 on 5.4.11 but throws BAD_ARGUMENTS on 5.4.13 (upstream #393 is in the regenerated Parser.cpp). This stops being backward incompatible only if the fork drops that rule, which also matters for pr-must-backport.

Suggested category: Backward Incompatible Change. Ignore if the change is intentionally non-breaking.

@actueleai @alexey-milovidov could you please take a look, this looks right
probably we just need to change it to backward incompatible and that is it

@zlareb1

zlareb1 commented Oct 19, 2026

Copy link
Copy Markdown
Member

@rschu1ze do we need this in 26.2?

@rschu1ze

rschu1ze commented Oct 19, 2026 •

Copy link
Copy Markdown
Member

@zlareb1 Your question confuses me. The PR is in 26.2 Cloud. 26.2 OSS is no longer supported.

@zlareb1

zlareb1 commented Oct 19, 2026 •

Copy link
Copy Markdown
Member

yes, do we need to backport this in 26.2 cloud release @rschu1ze? asking since, I need to create a patch release

@rschu1ze

Copy link
Copy Markdown
Member

do we need to backport this in 26.2 cloud release @rschu1ze

The PR is backported to 26.2: https://github.com/ClickHouse/clickhouse-private/pull/81544

@alexey-milovidov

Copy link
Copy Markdown
Member

@actueleai @alexey-milovidov could you please take a look, this looks right
probably we just need to change it to backward incompatible and that is it

Yes, everything is right. We may use the "backward incompatible" label, but it is not necessary.

middas-0706 pushed a commit to middas-0706/ClickHouse that referenced this pull request Nov 18, 2026
No existing query number or text changes: 7 queries are disabled and the
same 7 appended on `hits_10m_single` as 28-34.

Queries 4, 7, 11, 15, 18, 21 (`multiMatchAny`) and 17
(`multiSearchFirstIndex`) scan all 100M `URL` values of `hits_100m_single`
and take 1.16-1.52 s on MasterCI amd, 0.70-1.04 s on arm. The `vectorscan`
database is compiled once and cached (0 global cache misses per measured
run), so the time is the per-row scan. Each copy is the original with
`hits_100m_single` -> `hits_10m_single` and nothing else; the file already
runs its other `match`, `multiMatchAny` and `multiSearchAny` variants on
that table.

Probe on official MasterCI amd release builds (clickhouse local, 8 pinned
cores): per-row user time copy x 10 / original 0.978-1.053 on e191b1a,
324e8a3 and fc8a493. On the ClickHouse#125774 merge (vectorscan 5.4.11 -> 5.4.13,
e191b1a -> 324e8a3) the originals 4, 7, 11, 15, 18 move by
1.190, 1.211, 1.042, 1.249, 1.072 and their copies by 1.219, 1.241, 1.030,
1.280, 1.112 (retention 0.70-1.52); 17 and 21 stay flat in both.

perf.py, two fc8a493 servers, 12 runs: copy / original 0.106-0.113, about
0.13-0.17 s projected on CI amd and 0.08-0.11 s on arm; per-row user time
0.99-1.03. On the final file perf.py measures the 28 enabled queries and
none of the 7 disabled ones, also with --max-queries 10. Projected saving:
about 37 s (amd) and 24 s (arm) of query time per master perf job.

Related: ClickHouse#129258

Co-Authored-By: Claude Opus 5.5 <[email protected]>
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-external-dependencies Third-party deps updates in contrib/, vendored code, and platform base libraries. manual approve Manual approve required to run CI pr-backports-created Backport PRs are successfully created, it won't be processed by CI script anymore pr-build Pull request with build/testing/packaging improvement pr-must-backport Pull request should be backported intentionally. Use this label with great care! pr-must-backport-synced The `*-must-backport` labels are synced into the cloud Sync PR pr-synced-to-cloud The PR is synced to the cloud repo submodule changed At least one submodule changed in this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

9 participants