Skip to content

feat: Add throttle_limits to count memory.high as a memory limit - #25

Merged
Pijukatel merged 2 commits into
apify:masterfrom
Mantisus:high-max-memory
Nov 11, 2026
Merged

Pijukatel merged 2 commits into
apify:masterfrom
Mantisus:high-max-memory

Conversation

@Mantisus

@Mantisus Mantisus commented Nov 9, 2026 •

Copy link
Copy Markdown
Collaborator

Description

On cgroup v2 a level can limit memory with memory.max and with memory.high. Only memory.max was read, so a limit set with memory.high alone gave no budget.

  • get_memory_budget(), snapshot() and describe() take a keyword throttle_limits. With throttle_limits=True, each level's limit is the tighter of memory.max and memory.high.
  • The default is False. memory.high is then not read at all, and the behaviour stays as before.
  • With throttle_limits=True, a memory.high that cannot be read is handled as an unreadable memory.max is.
  • cgroup v1 and Windows job objects have no such limit, so the argument changes nothing there.

Issues

Testing

  • Unit tests for both modes:
    • memory.high below and above memory.max, and unset;
    • an unreadable or negative value in either file;
    • cgroup v1 ignoring memory.soft_limit_in_bytes.
  • e2e with throttle_limits=True: a systemd scope with MemoryHigh, and a memory.high set inside a Docker container.

@Mantisus Mantisus self-assigned this Nov 9, 2026
@Mantisus
Mantisus requested a review from Pijukatel November 9, 2026 23:03
@Pijukatel

Copy link
Copy Markdown
Contributor

I am not sure about this. Can we make it configurable? This seems like an application decision whether they want to respect the soft limit memory.high.

@Mantisus

Copy link
Copy Markdown
Collaborator Author

Great idea. I'll update it.

@Mantisus
Mantisus marked this pull request as draft November 10, 2026 12:18
@Mantisus Mantisus changed the title fix!: Count memory.high as a memory limit under cgroup v2 feat: Add throttle_limits to count memory.high as a memory limit Nov 10, 2026
@Mantisus
Mantisus marked this pull request as ready for review November 10, 2026 14:01

@Pijukatel Pijukatel left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks. Nice upgrade.

@Pijukatel
Pijukatel merged commit e53e4cc into apify:master Nov 11, 2026
37 checks passed
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.

Treat memory.high as a memory limit on cgroup v2

2 participants