Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions Containerfile.pc
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ RUN --mount=type=tmpfs,dst=/tmp --mount=type=cache,dst=/usr/lib/sysimage/cache/p
pamixer \
matugen \
power-profiles-daemon \
zram-generator \
sudo \
wireplumber \
xdg-utils \
Expand Down Expand Up @@ -210,6 +211,35 @@ RUN install -d /usr/lib/systemd/logind.conf.d && \
'HandleLidSwitchExternalPower=ignore' \
> /usr/lib/systemd/logind.conf.d/10-lid-ignore.conf

# Builds (cargo/webpack/tsc/link steps) can balloon memory on this laptop's
# 8GiB and, with no swap and no OOM intervention, thrash the kernel until it
# hard-hangs. Three layers of defense:
# 1. zram: compressed RAM swap absorbs spikes instead of the kernel having
# nowhere to reclaim to.
# 2. systemd-oomd: watches memory pressure (PSI) and kills the worst
# offending cgroup before the whole system grinds to a halt.
# 3. user-.slice MemoryHigh/MemoryMax: caps everything the user session runs
# (builds, browser, terminal) at 85% of RAM, always reserving headroom
# for system.slice and the kernel.
RUN install -d /usr/lib/systemd/oomd.conf.d /usr/lib/systemd/system/user-.slice.d && \
printf '%s\n' \
'[zram0]' \
'zram-size = min(ram, 8192)' \
'compression-algorithm = zstd' \
'swap-priority = 100' \
> /usr/lib/systemd/zram-generator.conf && \
printf '%s\n' \
'[OOM]' \
'SwapUsedLimit=90%' \
> /usr/lib/systemd/oomd.conf.d/10-swap-limit.conf && \
printf '%s\n' \
'[Slice]' \
'MemoryHigh=85%' \
'MemoryMax=92%' \
'ManagedOOMMemoryPressure=kill' \
'ManagedOOMMemoryPressureLimit=50%' \
> /usr/lib/systemd/system/user-.slice.d/10-resource-limits.conf

# Keep the initramfs aligned with the final kernel, firmware, microcode, and
# NVIDIA modules by running the same generic builder as the Bootcrew-style
# base after the desktop package transaction.
Expand Down Expand Up @@ -239,6 +269,7 @@ RUN systemctl enable \
gdm \
systemd-resolved \
systemd-timesyncd \
systemd-oomd.socket \
fstrim.timer

RUN ln -sf /usr/share/zoneinfo/Asia/Kolkata /etc/localtime && \
Expand Down
Loading