Skip to content

fix!: Report from readable levels instead of None on an unreadable file - #26

Merged
Pijukatel merged 4 commits into
apify:masterfrom
Mantisus:soft-limit
Nov 19, 2026
Merged

Pijukatel merged 4 commits into
apify:masterfrom
Mantisus:soft-limit

Conversation

@Mantisus

@Mantisus Mantisus commented Nov 11, 2026 •

Copy link
Copy Markdown
Collaborator

Description

When one cgroup file could not be read, the whole reading was dropped and the answer was None. A consumer reads None as "no limit" and sizes from the whole machine, which is looser than any limit that could be read.

  • A limit file that cannot be read is left out. The limit comes from the files that can be read. This covers memory.max, memory.high, the CPU quota and the CPU set.
  • A CPU set is never taken from an ancestor. Under cgroup v1 an unreadable cpuset.effective_cpus gives way to cpuset.cpus of the same level.
  • A memory usage that cannot be read no longer drops the budget. That level is charged at least the largest charge read below it. used is then a lower bound, and available an upper bound.
  • *_LIMIT_UNREADABLE and MEMORY_USAGE_UNREADABLE name the file and the reason, such as memory.max (EACCES). On Windows they name the job query and its error code.
  • MEMORY_USAGE_UNREADABLE now comes beside a reported budget. A level whose limit covers the machine, such as the cgroup v1 sentinel, is named only where it sets available.
  • On Windows an affinity that cannot be read is left out, and the CPU rate stays.
  • On Windows a CPU rate that cannot be sized, because the core count of the machine is unknown, is left out with MACHINE_CPU_COUNT_UNKNOWN. The affinity is still reported.
  • On Windows a job that will not answer the extended-limits or rate-control query still reports no CPU limit.

Issues

Testing

  • Unit tests:
    • an unreadable, unparsable or negative limit file, and one that is gone when opened, for each limit file;
    • the cgroup v1 fallback from cpuset.effective_cpus to cpuset.cpus;
    • the usage bound: several silent levels in a row, levels without a limit between them, a tie, and a level whose limit covers the machine;
    • an absent file read while out of file descriptors still reads as absent;
    • on Windows, an affinity that cannot be read beside a rate, and a rate that cannot be sized beside an affinity.
  • A test fixture checks that every injected read failure actually fires.
  • Each commit passes ruff, ty and the unit tests on its own, on Linux and on a Windows host.

@Mantisus Mantisus self-assigned this Nov 11, 2026
@Mantisus
Mantisus requested a review from Pijukatel November 11, 2026 22:38

@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.

Two findings inline: on Windows a failed affinity query still drops a rate that was read fine, and ceiling shouldn't be a backend parameter.


Generated by Claude Code

Comment thread src/proclimits/_windows.py Resolved
Comment thread src/proclimits/_cgroup.py Resolved
@Mantisus

Copy link
Copy Markdown
Collaborator Author

@Pijukatel, thanks, updated.

@Mantisus
Mantisus requested a review from Pijukatel November 18, 2026 18:26
@Pijukatel
Pijukatel merged commit cc7bea8 into apify:master Nov 19, 2026
35 of 36 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.

Keep reporting limits when a cgroup file cannot be read

2 participants