Measure memory_threshold against the test process's own RSS - #122
Merged
Merged
Conversation
The memory recycle check compared whole-system memory use, 1 - Sys.free_memory()/Sys.total_memory(), against the threshold. On macOS free memory stays near zero even on an idle machine (0.07-0.19 GB of 7 GB on GitHub arm64 runners), so any threshold recycled the test process after every item, and a process was also blamed for memory other processes used. The threshold is now the fraction of total system memory that one test process's current resident memory may reach. `_current_rss()` reads it from /proc/self/statm on Linux, task_info(MACH_TASK_BASIC_INFO) on macOS and K32GetProcessMemoryInfo on Windows, using plain ccall so it works on every Julia version the test server supports (1.0 on). When the RSS cannot be determined the check never fires. A threshold of 0.0 still recycles after every item. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This was referenced Sep 24, 2026
Merged
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.
Summary
memory_threshold, an experimental option that is off by default, now compares the test process's own current resident memory with total system memory. It used to look at system-wide memory use. A test process recycles itself oncerss / Sys.total_memory() > threshold.Why
The old check was
1 - Sys.free_memory()/Sys.total_memory() > threshold. On macOS,Sys.free_memory()stays close to zero even on an idle machine: on GitHub's macOS arm64 runners we measured 0.07–0.19 GB free out of 7 GB. So any threshold fired after every item, and every item paid for a process restart. A system-wide figure also recycles one process because of memory that other processes are using.Recycling is the only mechanism that gives back memory a test process still holds live. Compiled code and caches grow over a process's lifetime, and no GC can free them. Measuring per process makes the option usable on every platform.
Changes
testprocess/TestItemServer/src/process_memory.jlwith_current_rss(): current resident memory, not the peak thatSys.maxrss()reports./proc/self/statm.task_info(MACH_TASK_BASIC_INFO). The struct layout was checked against the xnu headers.K32GetProcessMemoryInfowithstdcall.SIZE_Tis declared asCsize_t, so the struct is also correct in 32-bit Julia.ccalland Julia 1.0-era Base, because the test server runs on Julia 1.0 and later. It returnsnothing(never recycle) when it can't measure._memory_over_thresholduses it. A threshold of0.0still recycles after every item, as the existing tests expect.TestRunState, the test server and theexecute_testrundocstring._current_rssreturns a plausible value, and a threshold of1.0never recycles.Testing
test/test_worker_lifecycle.jl: 61/61 pass on Julia 1.12.7 (Windows). The "Julia 1.0/1.6 platform" items also pass, so the test server still loads there._current_rss()checked directly on Windows with Julia 1.0.5, 1.6.7, 1.12.7 and 1.13.0:WorkingSet64to within 0.6 MB.GC.gc(), whileSys.maxrss()stays at the peak._current_rsstest item covers them.Related
Follow-up to the arm64 GC investigation, alongside #121 (GC between items opt-in).
🤖 Generated with Claude Code