Skip to content

Automatically set GOMEMLIMIT based on memory cgroup quotas

Arran Walker requested to merge 27984-gitlab-runner-helper-mem-killed into main

What does this MR do?

Uses github.com/KimMachineGun/automemlimit/memlimit to automatically set GOMEMLIMIT.

This is similar to the automatic CPU limit change that was recently merged: !4142 (merged).

Why was this MR needed?

GOMEMLIMIT is not usually set, meaning there's no soft memory limit. Where cgroup quotas are present and the Go application has no knowledge of the limit, the application can easily be OOM killed because it doesn't GC often enough. This was occurring frequently with our helper binary during cache extraction.

With this change, in container environments that have memory limits set, Go is now aware of the value, and will set the soft limit to 90% of the cgroup memory limit.

What's the best way to test this MR?

What are the relevant issue numbers?

Closes #27984 (closed)

Merge request reports