---
type: runbook
system: CachyOS laptop
area: workstation
status: active
tags:
  - arch-linux
  - aur
  - paru
  - makepkg
  - oom
  - zram
created: 2026-05-19
updated: 2026-05-19
---

# Arch AUR Build OOM Mitigation

## Context

On Will's CachyOS/Arch laptop, `paru -Syu` can exhaust RAM and zram swap while compiling AUR packages.

Observed on 2026-05-19:

- Physical memory: about 30 GiB.
- zram swap: about 10 GiB.
- CPU parallelism: 24 threads (`nproc`).
- `/etc/makepkg.conf` had `MAKEFLAGS="-j$(nproc)"`.
- zram swap was heavily occupied even after pressure subsided: about 8.5 GiB / 10 GiB used.
- Kernel logs showed real OOM kills during the update attempt:
  - Chrome was killed first.
  - A `clang++` compile process was killed shortly after.

Root cause: AUR builds inherited 24-way parallelism. Some C++/Rust builds can use well over 1 GiB per compile job, so `-j24` can overwhelm 30 GiB RAM plus zram.

## Current mitigation

A user-level makepkg override was created at:

```text
/home/will/.makepkg.conf
```

Current contents:

```bash
# Atlas conservative AUR build defaults for this laptop.
# Reason: /etc/makepkg.conf uses MAKEFLAGS="-j$(nproc)"; on this 24-thread CPU,
# parallel C/C++/Rust AUR builds can exhaust 30 GiB RAM + 10 GiB zram swap.
# Keep this user-level override instead of editing /etc/makepkg.conf.

# Limit make/cmake/autotools-style builds.
MAKEFLAGS="-j6"

# Limit compressors; zstd -T0 can spawn many threads during packaging.
COMPRESSZST=(zstd -c -T2 -9 -)
COMPRESSXZ=(xz -c -z -T2 -)

# Keep large builds off /tmp tmpfs. /var/tmp is on disk here with much more room.
BUILDDIR=/var/tmp/makepkg

# Best-effort caps for build systems used by many AUR packages.
export CARGO_BUILD_JOBS=4
export NINJAFLAGS="-j6"
export CMAKE_BUILD_PARALLEL_LEVEL=6
export npm_config_jobs=4
```

Build directory created:

```text
/var/tmp/makepkg
```

## Normal update command

Use the normal command first:

```bash
paru -Syu
```

The user-level makepkg limits should be picked up automatically.

## If a specific package still OOMs

Retry that package with stricter one-off limits:

```bash
MAKEFLAGS="-j2" \
CARGO_BUILD_JOBS=2 \
NINJAFLAGS="-j2" \
CMAKE_BUILD_PARALLEL_LEVEL=2 \
paru -S <package>
```

For extremely memory-heavy packages, use `-j1`.

## If swap remains heavily occupied before retrying

Check current memory/swap:

```bash
free -h
swapon --show
zramctl
```

If RAM has plenty of headroom but zram swap remains full, a manual zram swap flush can help:

```bash
sudo swapoff /dev/zram0 && sudo swapon /dev/zram0
```

Caution: `swapoff` may temporarily move swapped pages back into RAM. Do this only when RAM has comfortable free/available capacity and the desktop is stable.

## Diagnostic commands

Check effective build settings:

```bash
grep -nE '^(MAKEFLAGS|COMPRESSZST|COMPRESSXZ|BUILDDIR|export (CARGO_BUILD_JOBS|NINJAFLAGS|CMAKE_BUILD_PARALLEL_LEVEL|npm_config_jobs))' ~/.makepkg.conf
```

Check OOM evidence:

```bash
journalctl -k --since '24 hours ago' --no-pager | grep -Ei 'out of memory|oom|killed process|clang|zram|swap' | tail -80
```

Check current memory pressure:

```bash
free -h
ps -eo pid,comm,%mem,%cpu,rss --sort=-rss | head -20
```

Check paru cache size:

```bash
du -sh ~/.cache/paru
```

## Notes

- Prefer this user-level override over editing `/etc/makepkg.conf`; it is easier to audit and less likely to be overwritten by package updates.
- This does not reduce the zram cap; Will's current zram setup is intentionally around 10-12 GiB with less aggressive swappiness than CachyOS defaults.
- If updates become too slow, try raising `MAKEFLAGS`/`NINJAFLAGS` from `-j6` to `-j8`, but keep Rust/Cargo closer to `4` unless memory pressure is clearly low.

## Related

- [[Runbooks Home]]
