Brain Structural Validation / Validate Markdown Structure & Links (push) Failing after 8s
2.7 KiB
2.7 KiB
type, date, project, tags
| type | date | project | tags | ||||||
|---|---|---|---|---|---|---|---|---|---|
| debug | 2026-09-27 | nixos |
|
Laptop Memory Exhaustion Postmortem & Mitigation
Incident Summary
On September 27, 2026, the laptop mobile workstation experienced a total UI freeze and lockup during high memory pressure, requiring a hard power-off.
Root Cause
- Zero Swap Space Configured: With 38 GiB of RAM and 0B of swap,
systemd-oomdloggedNo swap; memory pressure usage will be degradedat boot. - Synchronous Page Thrashing: Without swap backing, the Linux kernel cannot swap out cold anonymous pages. Under heavy memory allocations, it was forced to aggressively drop file-backed pages (binaries, shared libraries, font caches).
- Once executable code pages were dropped, every user action, compositor frame, and audio buffer demanded synchronous NVMe disk reads. As I/O stalled, the compositor (
niri), audio server (pipewire), and text editor (zed) locked up simultaneously before the kernel OOM killer could act.
Implemented Mitigations (system/core.nix)
Two complementary layers of memory protection were declared in ~/Config/system/core.nix:
1. Compressed In-RAM Swap (zramSwap)
zramSwap = {
enable = true;
};
- Creates a virtual compressed block device (
/dev/zram0) using up to 50% of RAM (~19 GiB) with fastzstdcompression. - Provides the kernel with headroom to page out inactive anonymous memory rather than discarding file cache.
- Satisfies
systemd-oomdrequirements for tracking memory pressure metrics.
2. Early OOM Killer Daemon (services.earlyoom)
services.earlyoom = {
enable = true;
enableNotifications = true;
extraArgs = [
"--avoid" "^(niri|dms|systemd|sshd)$"
];
};
- Monitors RAM and swap availability once per second.
- Proactively terminates the largest offending rogue process before memory exhaustion causes kernel and compositor lockups.
- Configured with
--avoidto protect core session components:niri(Wayland compositor),dms(DankMaterialShell),systemd, andsshd. - Configured with
enableNotifications = trueto alert the user via desktop notifications whenever a process is terminated.
Validation & Verification
nix flake check: Passed (5 checks: shellcheck, luacheck, ruff-lint, ruff-format, pyright, plus flake outputs).- Dry build validation:
nix build .#nixosConfigurations.laptop.config.system.build.toplevel --no-linkpassed successfully.
Activation Instructions
To activate these changes on the host system:
sudo nixos-rebuild switch --flake .#laptop
Verify zram is active after rebuild:
zramctl
free -h
systemctl status earlyoom