Repository navigation
[4.2-dev] fix(build): pin usearch to a portable arm64 baseline to stop SIGILL on non-SVE CPUs (#30413) - #30609
Conversation
…does not SIGILL on non-SVE CPUs (matrixorigin#30413) usearch's CMakeLists compiles with -march=native, tuning the artifact to the build host's CPU. The thirdparties Makefile already rewrites that to a haswell baseline on x86, but the probe used (-march=haswell) only succeeds on x86, so on arm64 the rewrite was skipped and -march=native survived. An arm64 release/image built on an SVE-capable host (modern Graviton / Ampere / Neoverse CI runners) then auto-vectorizes usearch's distance loops into SVE and bakes those instructions into libusearch_c with no runtime dispatch. The binary SIGILLs (illegal instruction, in usearch_add during HNSW build) on any arm64 CPU without SVE -- e.g. Apple Silicon under Docker, which is NEON-only. IVFFlat is unaffected because it uses no -march=native native kernel. Add the matching arm64 arm: when -march=haswell is unavailable but -march=armv8-a compiles, rewrite -march=native to -march=armv8-a. armv8-a is the AArch64 floor (every arm64 CPU implements it) and keeps mandatory NEON vectorization while dropping the optional SVE. SVE on genuinely-SVE hardware belongs behind SimSIMD runtime dispatch (MO_CL_SIMSIMD=1), not a static -march. Co-Authored-By: Claude Opus 4.8 <[email protected]>
Qodo reviews are paused for this user.Troubleshooting steps vary by plan Learn more → On a Teams plan? Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center? |
|
mo-bot review · Commit: Review completed. Read the assessment. |
|
mo-bot review · Commit: already-reviewed |
XuPeng-SH
left a comment
There was a problem hiding this comment.
mo-bot review · mo-bot-xupeng · review
Commit: 16056d037faac03ea11ec65f467eb8b3a3bb2d4f
Assessment: approve
Reviewed the complete change, vendored CMake configuration, build callers, native consumers and supplied evidence. The fix uses the existing build owner to select a portable ARM64 baseline while preserving x86 behavior. No actionable findings remain.
Model: gpt-6-astra / xhigh
Session: 01a15209-2c6d-71e2-b8f3-aa17387fa283 · slot 2 · generation 0
Validation:
-
Compiler probes passed for GCC/Clang x86 and Clang Linux/Darwin ARM64 targets. The base-revision control retained march=native on ARM64.
-
Representative ARM64 distance-loop compilation retained NEON without SVE under armv8-a; the armv8-a+sve control emitted SVE.
-
Repository-owned usearch build passed on Linux x86_64. Verified current input/output hashes and haswell flags for both shared and static libraries.
-
Isolation preflight and all 32 reported vendored C API test cases passed against the freshly built library.
-
Frozen patch correspondence, clean source and diff checks passed. Five successful receipts and matching logs are reconciled in /home/xupeng/.local/state/mo-bot/jobs/e9932d2200fe80da6a11e940/attempt-1/validation-manifest.json.
Limitations:
-
Local ARM64 validation used cross-target compiler probes and representative assembly; no ARM64 usearch binary, non-SVE device or MatrixOne SQL-service test was run.
-
Frozen CI metadata reports successful amd64/arm64 native builds, but raw CI and author validation logs were unavailable. local_validation was empty, and the linked issue body was not supplied.
## What type of PR is this? - [x] API-change - [x] BUG - [ ] Improvement - [ ] Documentation - [ ] Feature - [x] Test and CI - [ ] Code Refactoring ## Which issue(s) this PR fixes: Related to #30231. ## What this PR does / why we need it: Fix two independently reproduced UT flake mechanisms seen in #30609 and #30612 on `4.2-dev`: - Scope catalog admission hooks to the intended service, connection and active transaction. An unrelated transaction on the same CN could capture the barrier and leave the writer admission count at zero. Apply the same ownership rule to the neighboring DDL-first and stale-ALTER fixtures. Add real competing SQL before and during the paused writer; retain all ALTER/standalone, retry, rollback, result and neighboring-index assertions. - Semantic-backport main's optional caller-context CN label API from #30337, preserving the legacy three-second operational API and existing HAKeeper execution path. Use a bounded phase context and authoritative refresh in the IVF integration test. Remove redundant label updates and resultless refresh polling. - Serialize strict-boundary invalidation with cleanup. Cancel and join the callback before restoring labels with a fresh context; attempt every target after partial failure and report cleanup errors. Check exact CN identities and both labels. Validation (Go 1.26.4, Darwin/arm64, matching native libraries): - Full `clusterservice` and operational `ctl` packages: normal and race. - All affected Issue29715/27966 tests: normal and race. - Ten race repetitions of ALTER/standalone late admission; three race repetitions of the real IVF test. - Deadline/error/identity and partial-update/refresh/cleanup unit cases; configured incremental gofmt, vet, molint and golangci-lint. - `gpt-6.1-sol` / `xhigh` design and overall review. No production query-path, wire, schema or global-timeout change. This fixes the demonstrated fixture mechanisms; it does not establish the physical cause of the historical HAKeeper slowdown or eliminate every possible CI flake. Linux CI remains pending. ### CI follow-up The first Linux run exposed two additional test synchronization defects: - Lock caller-deadline tests shared the holder's setup budget, then asserted a lower bound on only the remaining wait. Separate setup from the fresh caller deadline, observe real contention, and require `context.DeadlineExceeded` rather than elapsed-time floors. Cover zero and explicit lock timeouts and successful release; cancel, release and join workers before restoring private hooks. - The tenant stage/fulltext2 test polled MATCH before CDC readiness. Wait for the durable tail before the first content query, using the same boundary as its mutation checks. Bound tail/checksum SQL with one 30-second context per transition, report SQL errors, and stop indexed work before closing the HTTP source. Preserve TXT/PDF/Chinese/DOCX, mutation, compaction/HNSW and authorization assertions. A real-SQL diagnostic probe observed an initial empty MATCH, recovery after durable tail, and successful first MATCH on a fresh readiness-first table. It did not reproduce a persistent stale cache or prove the historical failure's exact cache state; no diagnostic eviction is included in the patch. Additional local validation: complete lockservice/embed packages in normal and race modes; final changed lock cases in normal/race with ten bounded repetitions; three focused readiness-root race repetitions; two expected-failure controls rejecting premature errors and ignored caller contexts; incremental formatting/vet/molint/lint. The `gpt-6.1-sol` / `xhigh` review's cleanup finding was corrected and re-reviewed. The old UT run also exhausted the outer 60-minute wrapper before plan/report completion. These focused corrections do not establish a whole-CI runtime improvement. PROXY's check annotation reports that its hosted runner lost communication; its absent coverage is a consequence of that interruption. New-head remote CI remains pending.
What type of PR is this?
Which issue(s) this PR fixes:
issue #30413 (4.2-dev backport)
What this PR does / why we need it:
HNSW index build crashes
mo-servicewith SIGILL (illegal instruction) insidethe vendored usearch native library (
usearch_add) on arm64 images, wheneverthere are rows to index. IVFFlat is unaffected.
Root cause
usearch's
CMakeLists.txtcompiles with-march=native, which tunes the artifactto the build host's CPU.
thirdparties/Makefilealready rewrites that to aportable
haswellbaseline — but the probe it uses (-march=haswell) only succeedson x86, so on arm64 the rewrite was skipped and
-march=nativesurvived.A release/image built on an SVE-capable arm64 host (modern Graviton / Ampere /
Neoverse CI runners) then auto-vectorizes usearch's distance loops into SVE and
bakes those instructions into
libusearch_cwith no runtime dispatch. That binarySIGILLs on any arm64 CPU without SVE — e.g. Apple Silicon under Docker, which is
NEON-only. The faulting bytes disassemble to SVE (
ptrue p0.s, vl4,ld1w {z0.s}, p0/z, ...). IVFFlat uses no-march=nativenative kernel, so it isunaffected.
(Note: this is not SimSIMD — it is off by default; and not a stale/
make cleanartifact — a fresh build on the same SVE host reproduces the same binary.)
Fix
Add the matching arm64 arm to the existing baseline rewrite: when
-march=haswellis unavailable but
-march=armv8-acompiles, rewrite usearch's-march=nativeto-march=armv8-a.armv8-ais the AArch64 floor — every arm64 CPU implements it —and keeps mandatory NEON vectorization while dropping the optional SVE. SVE on
genuinely-SVE hardware belongs behind SimSIMD runtime dispatch
(
MO_CL_SIMSIMD=1, which already pairs the SVE targets withSIMSIMD_DYNAMIC_DISPATCH=1), never a static-march.Validation
-march=armv8-aon a representative f32 L2 loop emits 0 SVE / 8 NEONinstructions;
-march=armv8-a+sveemits 5 SVE — so the fix drops exactly thecrashing SVE while retaining NEON vectorization.
mo-servicebuild clean;libusearch_ccontains 0 SVE instructions;CREATE INDEX ... USING HNSWon anon-empty table builds and the server stays up.
sedrewrite is verified on both GNU (Linux/CI) and BSD (macOS)sed.🤖 Generated with Claude Code