config: add cgroup memory limit config

This commit is contained in:
Mitchell Hashimoto
2024-06-05 10:27:53 -07:00
parent 3b41b89c23
commit 99d567274b
2 changed files with 14 additions and 4 deletions

View File

@ -57,10 +57,11 @@ pub fn init(app: *App) ![]const u8 {
// of "max" because it's a soft limit that can be exceeded and
// can be monitored by things like systemd-oomd to kill if needed,
// versus an instant hard kill.
// try internal_os.cgroup.configureMemoryLimit(transient, .{
// // 1GB
// .high = 1 * 1024 * 1024 * 1024,
// });
if (app.config.@"linux-cgroup-memory-limit") |limit| {
try internal_os.cgroup.configureMemoryLimit(transient, .{
.high = limit,
});
}
return transient;
}

View File

@ -1012,6 +1012,15 @@ keybind: Keybinds = .{},
///
@"linux-cgroup": LinuxCgroup = .@"single-instance",
/// Memory limit for any individual terminal process (tab, split, window,
/// etc.) in bytes. If this is unset then no memory limit will be set.
///
/// Note that this sets the "memory.high" configuration for the memory
/// controller, which is a soft limit. You should configure something like
/// systemd-oom to handle killing processes that have too much memory
/// pressure.
@"linux-cgroup-memory-limit": ?u64 = null,
/// If this is false, then any cgroup initialization (for linux-cgroup)
/// will be allowed to fail and the failure is ignored. This is useful if
/// you view cgroup isolation as a "nice to have" and not a critical resource