Skip to content

tests: skip --max in levels.sh on low-memory Linux systems - #4784

Open
JohannesGezachew wants to merge 1 commit into
meta:devfrom
JohannesGezachew:cli-tests-levels-low-memory
Open

JohannesGezachew wants to merge 1 commit into
meta:devfrom
JohannesGezachew:cli-tests-levels-low-memory

Conversation

@JohannesGezachew

Copy link
Copy Markdown

Fixes #4748.

compression/levels.sh always runs zstd --max, which needs about 8.5 GB of memory. On machines, VMs and CI containers with less than that, the test is OOM-killed and fails:

FAIL: compression/levels.sh.check_exit
Exit code mismatch! Expected 0 but got 137

This skips the --max step on Linux when less than 9 GiB is available, the same way it is already skipped on 32-bit builds (file-max.zst is a copy of file-19.zst, so the rest of the test still runs).

Available memory is the MemTotal from /proc/meminfo, lowered to the cgroup memory limit when there is one (/sys/fs/cgroup/memory.max for cgroup v2, memory/memory.limit_in_bytes for v1). The cgroup part matters because inside a container /proc/meminfo shows the host's memory: in a container limited to 4 GiB on an 18 GiB VM it still reports MemTotal: 18388764 kB, so checking /proc/meminfo alone would not help there.

The detection runs inside the existing set +v block, so it is not echoed. Only the new elif branch shows up in levels.sh.stderr.exact, and it is the same on every platform. On other platforms, mem_kib stays empty and --max runs as before. That keeps it running on the macOS CI runners, where memory compression lets it pass with less RAM.

Testing

zstd --max on the test's 64 KiB input peaks at 8,397,836 KiB RSS on Linux (/usr/bin/time -v). With docker run --memory=X --memory-swap=X it is killed at 8 GiB and succeeds at 9 GiB, hence the 9 GiB threshold.

levels.sh on Linux (Debian bookworm, /bin/sh is dash), aarch64:

memory limit detected mem_kib --max before after
none (18 GiB VM) 18388764 runs (8201 MiB peak) PASS PASS
10 GiB 10485760 runs (8201 MiB peak) PASS PASS
8 GiB 8388608 skipped FAIL (137) PASS
4 GiB 4194304 skipped FAIL (137) PASS

On macOS (arm64), mem_kib is empty, --max still runs, and all 44 cli-tests pass. I also checked the script with sh -n under dash, bash --posix and macOS /bin/sh.

I could not test the cgroup v1 path, because Docker Desktop only uses cgroup v2. On v1, an unlimited group reports a very large number, which is never lower than MemTotal, so it is ignored.

`zstd --max` needs about 8.5 GB of memory, so compression/levels.sh
gets OOM-killed (exit 137) on machines, VMs and containers with less
memory than that.

On Linux, read the physical memory from /proc/meminfo and lower it to
the cgroup v2/v1 memory limit when there is one, since /proc/meminfo
reports the host's memory inside a container. Skip the --max step when
less than 9 GiB is available, the same way it is already skipped on
32-bit builds. Other platforms are unaffected.

Fixes meta#4748
@meta-cla meta-cla Bot added the CLA Signed label Sep 11, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

cli-tests: levels.sh --max test fails on systems with < 10GB RAM

1 participant