Skip to content

Conversation

@djeebus
Copy link
Contributor

@djeebus djeebus commented Dec 4, 2025

This configures memory reservations on the envd service, and puts internal processes into cgroups based on their process type. Most importantly, this keeps envd responsive when the system is saturated.

envd.service cgroup:

the envd process. manages and handles communication into the sandbox.

  • memory.min = 50 megabytes. envd seems to use ~10 MB of memory, so this should be plenty
  • memory.low = 100 megabytes. if available memory is less than this, try to free up more memory
  • cpu.weight = 1000. this gives it 10x the priority of an average process, and 20x background procs launched by the user. this isn't a reservation, it's just priority. if envd doesn't need the cpu cycles, they go to other processes.

pty cgroup:

any process that defines a pty configuration. assumed to be interactive, so it gets higher priority.

  • cpu.weight = 200

socat cgroup:

forwarded ports. shouldn't require much cpu, but is used for interaction, so it gets higher priority.

  • cpu.weight = 150

user cgroup:

every other command launched by the user. the lowest priority, as it has the highest chance of interrupting envd.

  • cpu.weight = 50
  • memory.high = 7/8 of the total sandbox

Note

Adds a cgroup v2 manager and assigns envd, PTY, socat, and user processes to dedicated cgroups with CPU/memory settings; integrated into process handling, port forwarding, and orchestrator templates.

  • Cgroups (new):
    • Add cgroups package with cgroup v2 manager (Cgroup2Manager), options, noop manager, and tests.
  • envd runtime:
    • main.go: create and configure cgroup manager (flags: --cgroup-root), set per-type CPU/memory (pty, socat, user), pass to process service and port forwarder; bump Version to 0.4.3.
    • port/forward.go: run socat in ProcessTypeSocat cgroup via SysProcAttr FD.
    • services/process: plumb cgroup manager; handler.New sets SysProcAttr{UseCgroupFD,CgroupFD} and selects proc type (pty vs user).
  • Orchestrator:
    • Update envd.service.tpl with cgroup delegation and resource reservations (Delegate=yes, MemoryMin/Low, CPUWeight).
    • Bump github.com/opencontainers/runtime-spec to v1.3.0; adjust rootfs test accordingly.

Written by Cursor Bugbot for commit 4d795e6. This will update automatically on new commits. Configure here.

Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

@djeebus djeebus mentioned this pull request Dec 5, 2025
@djeebus djeebus force-pushed the oom-killing-no-systemd-run branch from 2fdcc9e to 3b9a6a2 Compare December 9, 2025 00:24
@djeebus djeebus changed the title Create cgroup manually Put envd, ptys, socats, and commands into their own cgruops Dec 10, 2025
@djeebus djeebus changed the title Put envd, ptys, socats, and commands into their own cgruops Put envd, ptys, socats, and commands into their own cgroups Dec 10, 2025
@djeebus djeebus merged commit c7180fe into main Dec 12, 2025
28 checks passed
@djeebus djeebus deleted the oom-killing-no-systemd-run branch December 12, 2025 00:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants