Skip to content

fix: tightest memory limit of the cgroup and its parents; no log for GOMEMLIMIT=off - #399

Merged
butschster merged 1 commit into
masterfrom
fix/memlimit-parents
Nov 7, 2026
Merged

butschster merged 1 commit into
masterfrom
fix/memlimit-parents

Conversation

@butschster

Copy link
Copy Markdown
Member

Follow-up to #398 (review notes), refs #331.

Changes

  • Every cgroup level from the process's own one up to the root counts; the smallest limit wins. A service or scope with no limit of its own inside a limited slice (or a container process in a nested /init.scope) now gets the slice's limit.
  • cgroup v1: the limit of the process's own memory cgroup (N:memory:/path in /proc/self/cgroup) and its parents is read, not only the root's. v2 still comes first.
  • GOMEMLIMIT=off no longer logs go memory limit mib=8796093022207; nothing is logged.

Tests

go test -run "Memory|SelfCgroup" ./internal/app/: new table cases v2 limited parent, v2 smallest wins, v1 own cgroup; TestSelfCgroup covers hybrid and v1-only; TestApplyMemoryLimit_EnvWins checks off.
Live: systemd-run --user --scope -p MemoryMax=512M ./buggregator → mib=460 source=cgroup; GOMEMLIMIT=off → no log line.

Made with harnsy

…GOMEMLIMIT=off

Review notes on #398: a process whose own cgroup has no limit under a
limited slice now gets the slice's limit (every level up to the root
counts, the smallest wins); the v1 limit is read from the process's own
memory cgroup too; GOMEMLIMIT=off no longer logs a bogus 8 EiB limit.

Refs #331
@butschster butschster added performance Performance-related type: bug Something is broken or behaves incorrectly labels Nov 7, 2026
@butschster
butschster merged commit 6676fcf into master Nov 7, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

performance Performance-related type: bug Something is broken or behaves incorrectly

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant