Skip to content

Native: start the isolate with -XX:MaximumHeapSizePercent=50 by default - #74

Merged
tae898 merged 1 commit into
native-two-distfrom
native-heap-50
Oct 25, 2026
Merged

tae898 merged 1 commit into
native-two-distfrom
native-heap-50

Conversation

@tae898

@tae898 tae898 commented Oct 25, 2026

Copy link
Copy Markdown
Collaborator

What

The native build now starts its GraalVM isolate with -XX:MaximumHeapSizePercent=50 by default, instead of GraalVM's 80%. If the user sets the heap in ARCADEDB_NATIVE_ISOLATE_ARGS (-Xmx..., -XX:MaximumHeapSizePercent=... or -XX:MaxRAM=...), nothing is added and theirs wins. Python only: no Java change and no image rebuild.

Why

With the 80% default the engine's off-heap memory comes on top of an almost full heap, and in a memory-limited container the kernel kills the process. In the container probes the process was OOM-killed 6 of 6 times in the two memory-limited cases with 80%, and ran clean 6 of 6 times with 50%. Both percentages follow the cgroup memory limit, not the host RAM, so a 4 GB container gets a 2 GB heap.

Evidence

The choice was made under a rule fixed before the runs. A timed laptop A/B (ab.py --noise, ABBA order, 41 figures, at least 11 clean pairs per figure, two replicates) showed no time figure worse than 5% against the old default. The large-data figures were at 0.995 to 1.010 of the old time, and peak RSS was not higher. So the lower limit costs no speed and removes the kills.

The image accepts -XX:MaximumHeapSizePercent=<n>, -Xmx<n> and -XX:MaxRAM=<n>. It does not accept -XX:MaxRAMPercentage: isolate creation fails with rc=22. The docs say so.

Changes

  • src/arcadedb/_native/lib.py: new _heap_isolate_args(user_args); _load always builds the isolate parameters now (the log-directory arguments are always there), so the dead if iso_args: is gone.
  • tests/test_native_heap.py (native only, registered in conftest.py): the default argument; each of -Xmx, -XX:MaximumHeapSizePercent and -XX:MaxRAM suppresses it; other arguments keep it; and on the real image lib.diag()["max_heap"] is 0.5000 of the host memory by default (16294346752 of 32589176832 bytes here) and a user percent, -Xmx or -XX:MaxRAM replaces the default.
  • docs/modules/ROOT/pages/installation.adoc: a short "Heap size" section under the native build notes (the default, how to override it, that it follows the container limit, that -XX:MaxRAMPercentage is not accepted), with a link to the main ArcadeDB docs for the native image.

Tests run

On a locally built image (ARCADEDB_BACKEND=native): test_native_heap.py, test_native_log_dir.py, test_native_startup.py, test_native_startup_runtime.py, test_log_dir.py and test_core.py: 66 passed, 3 skipped (the three skips are the existing JVM-only cases in test_log_dir.py). Bandit 1.9.4 (--severity-level low --confidence-level low): no issues. isort --profile black and black: clean on the touched files. scripts/check_no_embedded_name.py: ok.

This PR targets native-two-dist, the base of #66.

🤖 Generated with Claude Code

GraalVM's default heap limit is 80% of the memory the isolate sees (the container limit when there is one). With the engine's off-heap memory on top, the kernel killed the process in memory-limited containers. The glue now passes -XX:MaximumHeapSizePercent=50 as an isolate argument unless ARCADEDB_NATIVE_ISOLATE_ARGS already has -Xmx, -XX:MaximumHeapSizePercent or -XX:MaxRAM (theirs wins). The isolate arguments are now always non-empty (the log directory is always set), so the dead "if iso_args:" branch is gone.

Tests: the default and the override rules, and on the real image the default max_heap is about half of the memory and a user percent, -Xmx or -XX:MaxRAM replaces it. Docs: a heap-size section in the installation page.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@tae898
tae898 merged commit 38e8aae into native-two-dist Oct 25, 2026
27 checks passed
@tae898
tae898 deleted the native-heap-50 branch October 25, 2026 16:06
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