feat: add --max-memory to bound each scenario's memory use - #649
Open
ykhrustalev wants to merge 1 commit into
Open
ykhrustalev wants to merge 1 commit into
ykhrustalev wants to merge 1 commit into
Conversation
A mutant can turn a bounded loop into an unbounded allocator, and a test process growing at hundreds of MB/s exhausts the machine well before a 5x-baseline test timeout arrives. On a CI runner the VM is then torn down with no log, and the shard's mutants are never recorded. --max-memory SIZE, and the max_memory config key, put a ceiling on each scenario's cargo process tree instead. It is enforced with setrlimit (RLIMIT_AS), which limits address space rather than resident memory and so has to be set generously; which mechanism is in use is logged at startup. macOS accepts RLIMIT_AS and ignores it, so there the option warns and does nothing, as documented. Where it cannot be applied at all, giving the option is an error raised before any mutant runs, rather than a long run that silently had no limit. Zero is rejected too: unlike -t 0 it would mean 'stop everything', not 'no limit'.
This was referenced Sep 16, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
A mutant can turn a bounded loop into an unbounded allocator. A test process growing at hundreds of MB/s exhausts the machine long before a 5×-baseline test timeout fires — on CI the VM is torn down with no log, and the shard's mutants are never recorded.
Solution
--max-memory SIZEand themax_memoryconfig key to bound each scenario's cargo process tree.setrlimit(RLIMIT_AS)on the cargo process, inherited by everything it spawns, and logs the mechanism at startup.RLIMIT_AS, so the option warns and is a no-op there.-t 0,--max-memory=0would mean "stop everything", not "no limit".Testing
Split out of #647 as requested.
RLIMIT_ASlimits address space rather than resident memory and has to be set generously; next in the stack: #651 adds a cgroup v2memory.maxbackend that limits what actually matters and prefers it where available, and #653 reports its OOM kills.