Visitar URL original
native preview: CPU baseline check for images above the platform baseline (x86-64-v3, armv8.1-a) by tae898 · Pull Request #489 · humemai/arcadedb-embedded-python · GitHub
Skip to content

native preview: CPU baseline check for images above the platform baseline (x86-64-v3, armv8.1-a) - #489

Closed
tae898 wants to merge 1 commit into
native-previewfrom
native/cpu-baseline-check
Closed

tae898 wants to merge 1 commit into
native-previewfrom
native/cpu-baseline-check

Conversation

@tae898

@tae898 tae898 commented Oct 23, 2026

Copy link
Copy Markdown

Note on the base: the native preview wheel (arcadedb-embedded-native) is not on main yet. It lives on the native-* branches, and native-inline is the newest tip, so this PR is based on native-inline, not main.

What

arcadedb_embedded/_native/cpu.py is a pure-Python CPU baseline check that runs before libarcadedb is loaded. A CPU below the image's baseline gets an ArcadeDBError that names the missing features, the baseline, the JVM fallback (arcadedb-embedded) and ARCADEDB_NATIVE_SKIP_CPU_CHECK=1, instead of Illegal instruction.

Why, and what the baseline really is

An image that needs more than the CPU has dies with Illegal instruction and no message. That is what a user sees after pip install on a Proxmox VM with the default CPU type, on a Celeron/Pentium N/J (J4125, N5105), or on a Raspberry Pi 4 / AWS Graviton1 (no LSE atomics).

The shipped wheels do not have this problem: native-spike/scripts/preview-build.sh defaults to MARCH=compatibility (line 16, passed as -march=$MARCH on line 27) and .github/workflows/native-preview.yml sets MARCH: compatibility for all four platforms. That is baseline x86-64 and generic armv8-a, and it runs on every CPU in the examples above. GraalVM CE's own default (x86-64-v3 / armv8.1-a) only applies to a reference image built with MARCH=x86-64-v3 or a local build with the default. So the check is a guard for those images, and it is a no-op for the published wheels: it must not refuse a Celeron or a Pi 4 on a compatibility wheel, because that wheel runs there.

lib.py::_check_cpu already existed for this case but only knew avx2, bmi2 and fma, only Linux x86-64, and had no tests. This PR replaces it with the full list and covers the other platforms.

How it detects

Platform Source
Linux x86-64 flags line of /proc/cpuinfo: avx, avx2, bmi1, bmi2, fma, f16c, lzcnt (or abm), movbe (the v3 list of ArcadeData#10624)
Linux arm64 Features line: atomics (LSE), only for an armv8.1-a image
Windows x86-64 IsProcessorFeaturePresent(40) (AVX2) via ctypes
macOS not checked: Apple Silicon is always fine and there is no Intel macOS wheel

If the information cannot be read (no /proc, empty flags, any exception) it logs at debug and continues. ARCADEDB_NATIVE_SKIP_CPU_CHECK=1 skips the check. Nothing is checked for -march=compatibility.

Docs

native-wheel/README.md has a new "CPU requirements" section (baseline, machines below v3, fallback), and build-architecture.md and the build_wheel.py comment point at cpu.py. The repo keeps no changelog.

Tests

bindings/python/tests/test_native_cpu_check.py, 12 tests on fake cpuinfo and feature sets: v3 present (also LZCNT as lzcnt), AVX2 missing (J4125-like), Proxmox default CPU, Pi 4 without atomics, arm64 with atomics, compatibility never checks, unreadable CPU does not block, skip env var, Windows AVX2, macOS and unknown machines. PYTHONPATH=src uv run --no-project --with pytest --with jpype1 --with numpy pytest tests/test_native_cpu_check.py --noconftest: 12 passed. The CI legs build and parity-test the wheel on the four platforms.

🤖 Generated with Claude Code

…line (x86-64-v3, armv8.1-a)

The shipped wheels are built with -march=compatibility and run on every CPU of their platform. A reference image built for GraalVM's default baseline
died with "Illegal instruction" on an older CPU. _native/cpu.py checks all eight x86-64-v3 features (was avx2, bmi2, fma), LSE atomics for armv8.1-a on
arm64 Linux and AVX2 on Windows, never blocks when the CPU cannot be read, and ARCADEDB_NATIVE_SKIP_CPU_CHECK=1 skips it. Unit tests on fake cpuinfo;
README section "CPU requirements".

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@tae898
tae898 marked this pull request as draft October 23, 2026 15:54
Base automatically changed from native-inline to native-preview October 24, 2026 05:44
@tae898

tae898 commented Oct 24, 2026

Copy link
Copy Markdown
Author

Not needed: the native wheel ships -march=compatibility, and the laptop A/B (native-compat, reportable, A/A clean) puts its cost against x86-64-v3 at no more than about 5% on write and load paths, with queries and vector search unchanged (numbers on ArcadeData#10581). A CPU check only matters for an image above the platform baseline, which we do not ship.

@tae898 tae898 closed this Oct 24, 2026
@tae898
tae898 deleted the native/cpu-baseline-check branch November 8, 2026 11:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant