Skip to content

Add an AArch64 NEON path for hasAll on integer arrays - #116224

Closed
groeneai wants to merge 6 commits into
ClickHouse:masterfrom
groeneai:neon-hasall-integer-arrays
Closed

groeneai wants to merge 6 commits into
ClickHouse:masterfrom
groeneai:neon-hasall-integer-arrays

Conversation

@groeneai

@groeneai groeneai commented Aug 25, 2026 •

Copy link
Copy Markdown
Collaborator

Changelog category (leave one):

  • Performance Improvement

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

hasAll on arrays of 8, 16, 32 and 64-bit integers is now much faster on AArch64 (ARM) servers, where it previously ran an unaccelerated element-by-element search. Queries over long integer arrays benefit the most.

Description

Closes: #116069

The patch is @ egor-click's, taken from the issue body, measured by him on AArch64, credited in the commit message. He asked for a PR; I verified it.

Cause. All four vectorised specialisations in sliceHasImplAnyAll.h sit inside one #if defined(__AVX2__) block, as does the dispatcher's selection chain. With no #elif, AArch64 falls through to sliceHasImplAnyAllGenericImpl, a per-needle linear scan. Over 5524 CI (test, queryIndex) pairs (ARM/AMD duration medians, 10 days, master) the fleet-wide median ratio is 0.87 (ARM normally ~13% faster), while has_all query 5 is 13.4x, rank 1 of 5524.

Change. An #elif defined(__aarch64__) && defined(__ARM_NEON) arm: neonEqualMask, sliceHasImplAnyAllImplNeon, and a dispatcher arm guarded the same way. The x86 lane-rotation algorithm is deliberately not ported (it can only leave the inner scan once every lane has been found), so this vectorises only the haystack scan and keeps the scalar loop's early exit. NEON is unconditional at ClickHouse's AArch64 baseline, so no runtime dispatch; null maps and short haystacks take the existing scalar loop before any vector load.

Validation. His AArch64 A/B (32-core Neoverse, 11 interleaved runs/side): the ten affected queries 10.72 s to 3.81 s (2.82x), medium_Int16 5.20x, controls flat. I have no AArch64 hardware, so that is his number; the authoritative one is this PR's Performance Comparison (arm_release). I did verify x86 is bit-identical (disassembly of the three affected TUs, with a deliberate AVX2-side change as the control) and that the kernel matches an independent reference on 76,408 cases under qemu.

Trade-off he discloses. A needle found in the first few elements of a long haystack pays a reduction where the scalar loop needs one compare: 1.76x at depth 0, against 40-100 us saved at the depths these queries see. I swept a 0/2/4/8 scalar prefix and rejected it; the penalty is independent of P.


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

groeneai and others added 4 commits August 24, 2026 16:33
The four vectorised set-intersection specialisations in
src/Functions/GatherUtils/sliceHasImplAnyAll.h all sit inside a single
"#if defined(__AVX2__)" block, and the dispatcher's if-constexpr selection
chain sits inside a second one. There is no #elif and no #else, so on
AArch64, and on any other non-AVX2 target, every hasAll call falls through
to sliceHasImplAnyAllGenericImpl: a linear scan of the haystack per needle.

Measured over 5524 CI (test, queryIndex) pairs, comparing ARM and AMD
test_duration_ms medians on master across a 10-day window, the fleet-wide
median ratio is 0.87, i.e. the ARM runner is normally about 13% faster.
Against that baseline has_all query 5 (test_table_medium_Int16) is 13.4x
slower on ARM, which is rank 1 of all 5524 pairs, and has_all holds five
more places in the top twelve. All twelve queries of that test are
affected.

This adds an "#elif defined(__aarch64__)" arm with neonEqualMask and
sliceHasImplAnyAllImplNeon, plus the matching dispatcher arm guarded the
same way as the AVX2 one. NEON is unconditionally available at
ClickHouse's AArch64 baseline (cmake/cpu_features.cmake passes
-march=armv8.2-a+simd+...), so no runtime dispatch or feature detection is
required. x86 is unaffected by construction: with __AVX2__ defined the
preprocessor takes the AVX2 branch and the added text never reaches the
compiler. This was verified by comparing the disassembly of all three
translation units that include the header, before and after, and the same
comparison reports 234 differing instructions when a change is deliberately
made inside the AVX2 block.

The patch was written and measured on AArch64 hardware by Egor Romanov
(egor-click), who reported the problem in
ClickHouse#116069 and asked for it to
be opened as a pull request. On a 32-core Neoverse-class machine, with 11
interleaved runs per side and both binaries from the same checkout, the ten
affected queries go from 10.72 s to 3.81 s, a 2.82x improvement, with
medium_Int16 at 5.20x; hasAny and arraySum controls, which cannot enter the
changed code, did not move in the same session.

A known trade-off is documented in the issue and kept as it is: a long
haystack whose needles are found within the first two to four elements
still takes the vector path and pays one horizontal reduction where the
scalar loop needs a single compare, up to 1.76x slower at match depth 0.
In absolute terms that is 0.48 us on a call the scalar loop finished in
0.63 us, against 40 to 100 us saved per call at the depths these queries
actually see. A scalar prefix of 0, 2, 4 and 8 elements was swept as a
possible remedy and none was adopted: at the depth that is worst for a
given prefix length P the kernel does P compares plus one reduction while
the scalar scan does P+1 compares, so the absolute penalty is independent
of P and a prefix relocates the peak to depth P rather than removing it,
while charging P compares per needle at every greater depth.

Correctness was checked by cross-compiling the kernel for AArch64 and
running it under qemu, for correctness only and never for timing, against
an independent reference implementation: 76,408 cases per build covering
all eight integer widths, every hit index across the loop boundaries, 14
match depths, all four null-map shapes with and without a NULL present,
type extremes, duplicates, and 4000 randomised cases per type. Results
agree in every case, and instrumentation counters confirm the NEON path
was entered rather than skipped. Null maps and haystacks shorter than
max(32, 4 * lanes) are diverted to hasAllIntegralLoopRemainder, the same
scalar loop the x86 specialisations use for their own remainders, before
any vector load; a bounds oracle over 1,223,598 vector loads found none
outside the slice.

Co-authored-by: Egor Romanov <[email protected]>
The three new preprocessor guards now test __ARM_NEON alongside __aarch64__,
matching every other NEON site in the tree (src/Columns/ColumnsCommon.h,
src/Common/StringSearcher.h, src/Common/UTF8Helpers.h, src/Common/memcpySmall.h,
src/Compression/LZ4_decompress_faster.cpp). __ARM_NEON is defined under both
-march profiles ClickHouse passes on AArch64, so no build ClickHouse produces
changes behaviour; a target built with +nosimd now falls back to the generic
scan instead of failing to compile on the missing intrinsics.

The threshold comment no longer names a pull request. The property it needs to
state is that a horizontal reduction only pays for itself once the haystack is
long enough to amortise it, which stands on its own; the number that was there
pointed at a closed, never-merged PR rather than at the merged change that
caused the regression it described, so it sent a reader looking for history
that does not exist.
The long-Nullable block asserted that it proves NULL slots are diverted
before any vector load and that its two sides exercise different code.
Neither holds: hasAll receives no null map from arrayAllAny, because
Source::getWhole() returns by value and the null-map-carrying sliceHas
overloads take non-const lvalue references, so the plain overload is the
only viable candidate and passes nullptr for both maps. arrayFilter also
preserves Nullable, so both sides of the comparison are routed
identically. The assertion still pins the answer, which is worth keeping,
so only the comment changes.
…y type

Two comments in 04946_has_all_integer_arrays.sql claimed coverage the entry
threshold refutes. The short Nullable block said Nullable arrays take the
scalar path as a class; nullability is not the reason those calls are diverted
(their haystacks are 3 and 4 elements, under the 32-element threshold), and the
long Nullable block 15 lines below runs the same type above the threshold, so
the claim is also false as stated. The boundary-values block said a kernel
mishandling the sign bit fails there; its haystacks are 2 to 3 elements, below
the threshold for every width, so no kernel defect can redden it - it pins the
pre-existing scalar remainder loop, and the block after it repeats the extremes
at a length that does reach the kernel.

Comments only. No assertion, row or reference output changes.
@groeneai groeneai added can be tested Allows running workflows for external contributors groeneai-origin-request PR origin: a maintainer pinged or directed groeneai labels Aug 25, 2026
@groeneai

Copy link
Copy Markdown
Collaborator Author
Internal second-model review - four rounds, 8 findings adjudicated (5 agreed, 3 disagreed)

Four review rounds over this diff (a cold read plus a second model each round),
adjudicated against the recorded evidence. No finding required a change to the
kernel
; four changed comments or a guard, two corrected this description, and
one turned out to be a pre-existing bug unrelated to this PR. The final round's
second-model pass returned no findings.

❌ Agreed and fixed in this PR

A stale citation in the new block comment. The comment credited a regression
to #108183. That PR is closed and was never merged - it was a proposed fix;
the regression came from #104228. Rather than swap the number I deleted the
sentence: the useful part is why the threshold exists, which the comment now
states on its own terms.

The NEON guards now also test __ARM_NEON. All three read
defined(__aarch64__) && defined(__ARM_NEON), matching every other NEON site in
the tree. __ARM_NEON is defined under both AArch64 profiles ClickHouse builds,
so no shipped build changes behaviour; a hypothetical +nosimd consumer now
falls back to the generic scan instead of failing to compile.

Two test comments claimed detection the entry threshold refutes. One said
Nullable arrays take the scalar path as a class, and one said a kernel
mishandling the sign bit would fail at the short boundary arrays. Both blocks sit
below max(32, 4 * lanes), so they are diverted on length, and no kernel defect
can redden them - they pin the pre-existing scalar remainder loop. The assertions
are worth keeping and were left untouched; only the claims changed, and the
comments now point at the block that does reach the kernel.

Two attribution errors in this description. It linked "asked for a PR" to my
own acknowledgement comment rather than to egor-click's request, in the one
sentence whose job is to credit the patch to him; and it described the scalar
prefix sweep passively under a heading crediting him, when that sweep is mine (the
issue does not mention a prefix). Both corrected above.

This description said #elif defined(__aarch64__) after the guards were
widened. Corrected above.

⚠️ Agreed, but a pre-existing bug - deliberately not fixed here

One finding pointed at the Nullable test block, and following it up produced
something bigger than a test gap: hasAll/hasAny never receive a null map at
all today.

arrayAllAny (Algorithms.h:692) is their only caller and passes
first.getWhole() / second.getWhole(), which return by value - rvalues. The
three null-map-carrying overloads (Algorithms.h:652, :664, :676) take
non-const lvalue references, so they cannot bind; NullableSlice derives from the
plain slice, so the plain overload at :622 wins and passes nullptr, nullptr.
Every null-map branch in sliceHasImplAnyAll.h is therefore unreachable in
production, and the value physically stored underneath a NULL slot is compared
as an ordinary value:

CREATE TABLE ord (id UInt32, v Array(Nullable(Int32))) ENGINE = MergeTree ORDER BY id;
INSERT INTO ord VALUES (1, [NULL, 5, 7]), (2, [3, 5, 7]);
SELECT id, hasAll(v, [0]), has(v, 0) FROM ord ORDER BY id;
-- 1  1  0   <- hasAll matches a value that is not in the array
-- 2  0  0

Reproduced on master and on release 26.9.1.35, and the overload resolution
reproduces standalone on clang-21 and gcc-13 (an lvalue arm selects the nullable
overload, an rvalue arm does not). The overload shapes date to #11071.

Not fixed in this PR, on purpose. It is a correctness change to shared
null-map handling on every architecture, it needs its own equivalence matrix and a
Bug Fix changelog entry, and it would alter the very kernel the AArch64 numbers
above were measured against. Filed separately. This PR's own code sits behind
#elif defined(__aarch64__) && defined(__ARM_NEON) and cannot compile on x86,
where the bug reproduces, so the two are independent.

Consequence for this PR's tests, stated plainly: the Nullable assertions
verify the delegation guard as written, and that guard is correct, but they
cannot detect its degradation - deleting the guard's null-map term leaves them
unchanged, because no null map ever arrives. That is a real coverage gap and I am
not claiming otherwise. It is also not closable in SQL today: any oracle that
distinguishes the guard needs a live null map, and the payload-collision assertion
I tried first returns the wrong answer on current master for the reason above, so
shipping it would either fail immediately or freeze the bug into a .reference
file as expected behaviour. What does cover the guard is the off-tree equivalence
harness, where mutating exactly that term reddens 98 of 76,408 cases. I have also
dropped the over-strong "proves nulls are diverted" wording from the validation
notes rather than leave a claim the shipped test cannot support.

💡 Disagreed, with evidence

"High-bit values are untested for 7 of the 8 widths." The short boundary
arrays are indeed below the vector threshold, but the main block runs all eight
widths at lengths 64/65/127/128/129/200 - above every threshold
(max(32, 4 * lanes)). The specific combination of long length and extreme
values for the non-Int64 widths is covered off-tree: the equivalence harness
sweeps min/max/0/-1 per type across those lengths (76,408 cases), and its
wrong-intrinsic-width mutation reddens 32 cases, which is exactly the defect class
this finding posits.

"The LowCardinality assertions are redundant." Correct that arrayMap
strips LowCardinality from the lambda return type, so those two rows reduce to
plain Array(Int32) coverage. They are redundant, not wrong. LowCardinality is
not a carrier here: sources are built over TypeListNumberWithUUID and the new
dispatcher arm requires NumericArraySlice<IntN> exactly, so such an argument
never reaches the new kernel - it is a negative case.

"Prove the shallow-hit regression on ARM and cost the alternatives." Both are
already done and quoted in the issue: both kernels measured on AArch64 at depths
0/1/4/250/499 with the crossover at depth 2-4, and a scalar prefix swept over
{0,2,4,8} and rejected because the penalty does not depend on P. I also declined
to add a shallow-hit query to has_all.xml: it would park a permanent standing
regression in CI for a case this description already quantifies, and would move
the baseline the ranking was computed against.

@groeneai

Copy link
Copy Markdown
Collaborator Author
Pre-PR validation gate (click to expand)
# Question Answer
a Deterministic repro? Yes, and it is a compile-time property rather than a race: grep -c '__aarch64__|arm_neon' on the pre-patch header returns 0, so every AArch64 hasAll reaches sliceHasImplAnyAllGenericImpl. Shown on demand by an extracted-kernel A/B (-mavx2 vs -march=x86-64-v2: Int16 500x500 387.7 ms to 1867.2 ms, 4.82x) and by the harness counters (neon_entered 0 vs 15578).
b Root cause explained? Yes. All four vectorised specialisations sit in one #if defined(__AVX2__) block, and the dispatcher's if constexpr chain sits in a second one. There is no #elif and no #else, so every non-AVX2 target falls through to the per-needle linear scan.
c Fix matches root cause? Yes. It adds the missing target arm at exactly the layer that is absent. No widened bound, no no-random-* tag, no defensive check, no threshold constant.
d Test intent preserved / new tests added? Yes. Nothing existing weakened or removed, tests/performance/has_all.xml untouched. New stateless test 04946_has_all_integer_arrays, parallel-safe, no no-parallel, pure SQL. Its liveness is proven: breaking the remainder handoff makes it fail across several blocks.
e Both directions demonstrated? Yes. Base build enters the generic path (neon_entered=0, generic_cmp=6223646), patched build enters NEON (neon_entered=15578); both agree with the reference on all 76,408 cases. Four deliberate mutations redden the harness and the stateless test.
f Fix is general across code paths? Yes. One kernel covers all four widths plus the unsigned counterparts. hasAny and hasSubstr are deliberately unchanged (the new dispatcher arm requires All, exactly as the AVX2 arm does) and are covered by tests. Non-AVX2 x86, ppc64le and RISC-V keep the generic scan, disclosed in the description.
g Fix generalizes across inputs (params/datatypes/wrappers)? Yes. Eight integer widths x every hit index across the loop boundaries (31/32/33, 63/64/65, lanes and 2*lanes +/-1) x 14 match depths x all four null-map shapes with and without a NULL present x type extremes and duplicates, plus 4000 fuzz cases per type. SQL covers Nullable, mixed widths, Date/DateTime/Date32/Bool, and Float64/Decimal/String/UUID/IPv4/nested arrays as negative cases. The two LowCardinality rows are redundant rather than load-bearing: arrayMap strips the wrapper from its lambda return type, and such an argument does not reach the new kernel anyway (sources are built over TypeListNumberWithUUID, and the dispatcher arm requires NumericArraySlice<IntN> exactly).
h Backward compatible? Yes. No setting and no default change, so no SettingsChangesHistory.cpp entry is needed. No serialization or format change. Results are bit-identical to the current implementation, which is the acceptance gate this was verified against.
i Invariants and contracts preserved? Yes. Null maps and haystacks shorter than max(32, 4 * lanes) are diverted to hasAllIntegralLoopRemainder, the pre-existing scalar loop, before any vector load. Note the null-map half of that guard is dead in production for reasons that predate this PR (the caller passes no null map at all, see the review comment); the guard is written to be correct if that is ever fixed, and it matches what the AVX2 arm does today. A bounds oracle range-checked 1,223,598 vector loads with zero outside the slice, and reports 392 when an off-by-one is injected. No allocation, no locking, no lifetime change: the kernel is a pure function over two slices.

@clickhouse-gh

clickhouse-gh Bot commented Aug 25, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [bb72fcd]

Summary: ❌

job_name test_name status info comment
AST fuzzer (amd_debug) FAIL
Logical error: 'parts_ranges[0].event == PartsRangesIterator::EventType::RangeStart' (STID: 2508-4956) FAIL cidb
Integration tests (amd_asan_ubsan, db disk, old analyzer, 5/6) ERROR
Timeout FAIL cidb

AI Review

Summary

This PR adds an __aarch64__ + __ARM_NEON fast path for sliceHasImplAnyAll, so hasAll on same-type integer array slices can use NEON on AArch64 instead of always falling back to the generic scalar scan. I did not find a correctness, compatibility, or PR-metadata issue in the current diff, and the previously raised inline concerns are addressed in the code currently under review.

Missing context / blind spots
  • ⚠️ I could not execute the new NEON path in this workspace or rerun the PR's AArch64 performance job locally. That gap would be closed by an ARM job that runs gtest_has_all or an equivalent focused correctness check against the new path.
Final Verdict

✅ No new findings.

LLVM Coverage Report

Metric Baseline Current Δ
Lines 87.20% 87.20% +0.00%
Functions 91.90% 91.90% +0.00%
Branches 79.40% 79.40% +0.00%

Changed lines: Changed C/C++ lines covered: 2/3 (66.67%) · Uncovered code

Full report · Diff report

@groeneai

Copy link
Copy Markdown
Collaborator Author

cc @rschu1ze @antaljanosbenjamin, could you review this? The four vectorised set-intersection kernels in sliceHasImplAnyAll.h and the dispatcher that selects them all sit inside #if defined(__AVX2__) with no #elif, so every hasAll on an integer array falls through to the per-needle linear scan on AArch64; this adds the missing NEON arm, and x86 is unchanged by construction.

The 8-bit columns of the main matrix remapped values through x % 100. With the
longest haystack at 200 elements that made every value repeat after 100 slots,
so the "absent" needle was present after all and every hit landed in the first
100 elements. The 8-bit arms therefore could not observe a miss or a deep hit,
which is exactly what the file header claims the length matrix covers.

The remapping was never needed: toInt8 and toUInt8 truncate modulo 2^8 rather
than throwing, and the longest length here is 200, which is below 256, so a
plain cast stays injective at 8 bits too.

Measured on cross-compiled aarch64 (qemu-aarch64), replaying this matrix against
the shipped kernel. With the kernel deliberately returning "found" for 1-byte
widths only, the 8-bit arms went from 4 reddened cases to 12, and with a
fencepost that drops the last element of the scalar tail, from 6 to 24. The
deepest observed hit index for the 8-bit widths went from 99 to 199, and the
number of genuinely-absent oracle cases per 8-bit width from 14 to 18.
@clickhouse-gh

clickhouse-gh Bot commented Aug 25, 2026 •

Copy link
Copy Markdown
Contributor

Build profile diff (arm_release)

Comparing bb72fcd44 with master 86a433ccd (stripped binary size, per-symbol sizes and ThinLTO time; compile times per translation unit against the most recent warmup build that recompiled it).

✅ No significant changes.

Binary sizes
Binary Master PR Δ
programs/clickhouse-stripped 710.09 MiB 707.07 MiB -3.02 MiB (-0.43%)

Only the stripped binary is compared: the official master build keeps debug symbols while PR builds strip them, so the other binaries differ by construction.

Object file sizes

4 object files changed (+55.00 KiB total), 0 added.

Object file Master PR Δ
src/Functions/GatherUtils/CMakeFiles/clickhouse_functions_gatherutils.dir/has_all.cpp.o 3.02 MiB 3.08 MiB +54.98 KiB (+1.78%)

737 more object files are built by the master warmup baseline only (it builds every object-file target, a pull request build only clickhouse-bundle) and not compared.

Compile time of recompiled translation units

30 translation units recompiled, 124 s compile time in total, 30 of them have a recent master baseline.

Median compile-time ratio to the baselines is ×0.94 (machine-speed difference or a change affecting every TU); per-TU deltas below are relative to that ratio.
The matched translation units cost -9.8 s (-7%) in total before that adjustment.

Job report

@clickhouse-gh

clickhouse-gh Bot commented Aug 25, 2026 •

Copy link
Copy Markdown
Contributor

📊 Cloud Performance Report

✅ AI verdict: no_change — no significant changes across 39 queries analysed

This PR adds an ARM NEON SIMD specialization for the array hasAll function on integer arrays. None of the flagged ClickBench queries use hasAll — they are all GROUP BY aggregations (Q16-Q18, Q32-Q34) that don't execute the changed code path, so the uniform +8% to +14% deltas cannot plausibly be caused by this change and look like run-to-run variance across the co-located source runs (only 6 source runs vs 21 baseline). The Q16 and Q17 regressions were downgraded to not-sure on that basis; the remaining queries already sit within master's variance band. No genuine regression is attributable to this diff.

clickbench

⚠️ 6 inconclusive

Flagged queries (6 of 43)
Query Verdict Baseline median (ms) PR median (ms) Change q-value Hint
⚠️ 16 not_sure 596 682 +14.3% <0.0001 aggregation: This PR only adds an ARM NEON specialization of the array hasAll function; Q16's GROUP BY UserID never calls hasAll, so the +14.3% is off-path variance, not a PR effect.
⚠️ 17 not_sure 242 273 +12.8% <0.0001 aggregation: Q17 is a GROUP BY aggregation that doesn't use the array hasAll path this PR touches, so the +12.8% cannot plausibly come from this change and reads as run-to-run variance.
⚠️ 18 not_sure 1040 1150 +10.6% <0.0001 aggregation: GROUP BY aggregation unrelated to the hasAll code path changed here; the +10.6% sits inside master's variance band and is not attributable to this PR.
⚠️ 32 not_sure 1310 1413 +7.9% 0.0002 aggregation: The two tests disagree here and this GROUP BY query doesn't exercise the changed array hasAll path, so the +7.9% is best read as noise.
⚠️ 33 not_sure 1176 1300 +10.5% <0.0001 aggregation: Another GROUP BY aggregation outside the hasAll path; the +10.5% falls within master's variance band and is not tied to this change.
⚠️ 34 not_sure 1169 1306 +11.7% <0.0001 aggregation: GROUP BY URL aggregation, unrelated to the array hasAll change; the +11.7% stays within master's envelope and is not a PR effect.

Change = percent below ×2; the ratio of medians (×N faster/slower) beyond, where percent understates the scale. q-value = BH-FDR adjusted p; smaller is stronger evidence. MIRAI flags a query when q < fdr_q (default 0.10) — the value the verdict is based on.

tpch_adapted_1_official

🟢 No significant changes

Debug info
  • StressHouse run: 2b0a351d-fd87-4417-b85c-205dc35c1e82
  • MIRAI run: 51b6ce5e-50cc-4eba-b3af-b08391b06308
  • PR check IDs:
    • clickbench_350198_1787679417
    • clickbench_350205_1787679422
    • clickbench_350216_1787679423
    • tpch_adapted_1_official_350223_1787679422
    • tpch_adapted_1_official_350240_1787679416
    • tpch_adapted_1_official_350269_1787679417

@groeneai

Copy link
Copy Markdown
Collaborator Author

CI finish ledger - 29aacd2

Every failure below has an owner: a fixing PR (ours or external), or a full-effort fix task
whose fixing-PR link will be posted here when it opens. Only CH Inc sync is exempt.

Check / test Reason Owner / fixing PR
Stateless tests (amd_llvm_coverage, ParallelReplicas, s3 storage, parallel) - job-level error, no failing test job timeout: the shard hit the 9000 s cap 184 s after all 13172 tests had finished, so praktika SIGTERMed it (exit -15). Not PR-caused: this un-batched coverage shard reached the cap on 17 other commits in the last 14 days, one of them on master. #116209 (ours, open) - splits this exact shard into 2 batches
Stateless tests (amd_llvm_coverage, ParallelReplicas, s3 storage, parallel) / 04411_memory_profiler_sample_probability_sql_settings flaky under coverage instrumentation: SYSTEM FLUSH LOGS trace_log exceeded its 180 s limit while flushing TraceLogElement. Not PR-caused - this PR touches sliceHasImplAnyAll.h and one hasAll test only. #116242 (ours, merged 07:45:14Z) - marks the test no-llvm-coverage. Merged 460 commits after this head, so it was not present in this run.
Mergeable Check, PR aggregators reflecting the shard above same owners as above
Sync - CH Inc sync (private, not actionable by me)

178 check-runs completed: 159 success, 16 skipped, 3 failure, 0 queued or in progress.
Last completion 07:37:07Z. No CIDB FAIL/ERROR test rows on this commit.

Session id: cron:our-pr-ci-monitor:20260825-080000

@@ -0,0 +1,191 @@
-- Every row prints 1. `hasAll(set, subset)` is compared against a brute-force

@rschu1ze rschu1ze Aug 25, 2026 •

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.

@groeneai Remove this test. All functionality is already covered by existing tests.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Removed, and the comment too (bb72fcd).

You are right on coverage: src/Functions/tests/gtest_has_all.cpp calls sliceHasImplAnyAll, the dispatcher, so it routes to whichever arm the build selects, and its sizes 100/4096 (125 for 8-bit) are above this arm's entry threshold max(32, 4 * lanes) for all four widths, in both the all-present and one-absent directions, plus a null-map case. I also checked the other direction: every pre-existing hasAll call site in the stateless suite is either below that threshold or not a numeric slice, so none reached the arm before this PR either (04141_h3_polygon_to_cells_with_containment looked like the exception, but its array measures 7 elements).

One fact for the record, no action implied: Unit tests is AMD-only, all 7 paramsets RunnerLabels.AMD_LARGE (ci/defs/job_configs.py:1072-1085), so the gtest exercises the AVX2 arm and never the NEON one. That is pre-existing and applies equally to the four AVX2 kernels. Performance Comparison (arm_release) is what covers the new arm on ARM now.


#elif defined(__aarch64__) && defined(__ARM_NEON)

/// AArch64/NEON counterpart of the x86 specialisations above.

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.

@groeneai Get rid of this slop comment.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Gone, along with the rest of the narration in that block (bb72fcd). What survives is one sentence on why the x86 lane-rotation shape is not reused, and the null-map/short-haystack note moved down to the guard it explains. No executable line changed: the header is 650 non-comment lines before and after, byte-identical.

@rschu1ze rschu1ze self-assigned this Aug 25, 2026
@rschu1ze

Copy link
Copy Markdown
Member
image

Both changes were asked for in review.

The stateless test is dropped: src/Functions/tests/gtest_has_all.cpp already
covers the functional contract of this kernel. It calls sliceHasImplAnyAll, the
dispatcher, so it routes to whichever arm the build selects, and its array sizes
(100 and 4096, plus 125 for the 8-bit case) are above the new arm's entry
threshold max(32, 4 * lanes) for all four widths, in both the all-present and
one-absent directions, with a null-map case alongside. Every hasAll call site in
the pre-existing stateless suite is below that threshold or is not a numeric
slice, so none of them reached the arm before this change either.

The comment block above the arm is reduced to the one thing not visible in the
code: why the x86 lane-rotation shape is deliberately not reused. The
null-map/short-haystack justification moves to the guard it explains. The
remaining narration went; no executable line changes (650 non-comment lines in
the header, byte-identical before and after).
@rschu1ze rschu1ze removed their assignment Aug 25, 2026
@groeneai

Copy link
Copy Markdown
Collaborator Author

CI finish ledger - bb72fcd

Every failure below has an owner: a fixing PR (ours or external), or a full-effort fix task
whose fixing-PR link will be posted here when it opens. Only CH Inc sync is exempt.

Check / test Reason Owner / fixing PR
AST fuzzer (amd_debug) / parts_ranges[0].event == PartsRangesIterator::EventType::RangeStart (STID 2508-4956) server abort in splitPartsRangesImpl, reached via setupDistributedReadBuckets from tryMakeDistributedRead; first sighting in 30 days (1 CIDB row, against a 5566-row STID control) a fix task is created (investigating at full effort - fixing-PR link to follow on this PR)
Integration tests (amd_asan_ubsan, db disk, old analyzer, 5/6) / Timeout shard duration overrun, not a test failure: 1379 passed, 65 skipped, 20 warnings in 7237.15s against --session-timeout=7200, i.e. 37 s over budget with 0 failing tests #115963 (ours, open)

This diff cannot reach either failure: it is one file, src/Functions/GatherUtils/sliceHasImplAnyAll.h,
and all 116 added lines sit behind #elif defined(__aarch64__) && defined(__ARM_NEON), so none of
them is compiled into the amd_debug or amd_asan_ubsan binaries that failed. The fuzzer query
contains no hasAll/hasAny call.

#114177 is deliberately not linked for the fuzzer row. It is the nearest sibling (same file, merge
commit 2566e0ed4cc0db58d4813654af029ed046782d06), but git merge-base --is-ancestor shows it is
already present in the build that aborted, and its PartsSplitter.cpp hunks touch neither the
assertion nor parts_ranges[0], so it is a distinct defect.

Session id: cron:our-pr-ci-monitor:20260825-200000

@groeneai

Copy link
Copy Markdown
Collaborator Author

Completing the finish ledger above.

AST fuzzer (amd_debug) / parts_ranges[0].event == PartsRangesIterator::EventType::RangeStart (STID 2508-4956): fixing PR #116473 (ours, open).

Root cause is ALTER TABLE ... MODIFY ORDER BY silently dropping the DESC direction of a retained sorting key column while the existing parts stay physically sorted the old way. The metadata then describes an order the data does not have, and the primary-key range bucketizer trips the assertion above. #116473 refuses such an ALTER. A table that is already in that state stays affected, so the change removes the way to create it rather than repairing it.

@Algunenano Algunenano self-assigned this Oct 2, 2026
@Algunenano

Copy link
Copy Markdown
Member

This is very likely superseeded by #123420. @groeneai Compare and close this PR if it's not noticeably faster

@Algunenano Algunenano left a comment

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.

Better to avoid intrinsics

@Algunenano

Copy link
Copy Markdown
Member

I'll do the comparison myself and apply any improvements from this PR into #123420 instead

@Algunenano Algunenano closed this Oct 2, 2026
@groeneai

groeneai commented Oct 2, 2026

Copy link
Copy Markdown
Collaborator Author

Thanks. From the code, the shapes where this PR could still be ahead of #123420 are narrow: it only vectorizes hasAll on non-Nullable arrays whose first argument has at least 32 elements (64 for 8-bit types), and the two differences there are a mask test every 32 bytes instead of every 128 for 16/32/64-bit types (less work when a value is found among the first elements), and Int16 arrays of 32 to 63 elements, which #123420 handles with the scalar loop. I have no ARM hardware to time these, so they are only worth checking if those shapes matter.

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-performance Pull request with some performance improvements

Projects

None yet

Development

Successfully merging this pull request may close these issues.

hasAll on Array(IntN) is up to 13x slower on aarch64 — the vectorised set-intersection kernel is __AVX2__-only

3 participants