Repository navigation
refactor(server): respect cgroup heap limits - #3320
Conversation
- bound default heap sizing by remaining cgroup memory - resolve controller mounts and visible ancestor limits - add memory sizing regression checks to server CI
imbajin
left a comment
There was a problem hiding this comment.
Independent review of this head: 7.0/10; hold for the two P2 fixes below, then re-review. The supplied shell fixture suite and bash syntax check passed independently. Two additional bounded cloud fixtures reproduced the decision paths described inline. No real container restart, memory-pressure test, full Java build, or RC acceptance was run in this review. The author's container validation remains separate evidence. CI was still running when reviewed.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #3320 +/- ##
============================================
+ Coverage 52.42% 52.51% +0.09%
- Complexity 2273 2374 +101
============================================
Files 762 762
Lines 67400 67431 +31
Branches 9138 9151 +13
============================================
+ Hits 35333 35410 +77
+ Misses 28525 28488 -37
+ Partials 3542 3533 -9 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
- retain limits across covering cgroup mount views - account for reclaimable cache with conservative guards - run required Memory tests after License Checker - remove retired workflows and verify the result gate
- restore the trusted and limited retry workflow - select required jobs from the current failed attempt - rerun selected producers and their dependent jobs - preserve source guards and paused PR retries
- stop the monitor before shutting down its fixture - verify the foreground PID belongs to its wrapper - retain signal assertions and report failed ownership
Purpose of the PR
Server launchers size the default heap from host memory, so a memory-limited container can receive a heap larger than its limit. The default calculation now uses the smaller of host availability and remaining memory under visible cgroup hard limits.
Main Changes
Resolve covering cgroup v1/v2 mounts and their visible ancestor limits. Account for reclaimable inactive file cache, using conservative values when statistics are missing or inconsistent. Preserve existing heap bounds and explicit JVM option precedence.
Run License Checker before the Server product plans and required Memory tests in one workflow. Keep both required check names and isolate the Memory plan artifact. Preserve limited automatic retries for required jobs on failed push runs, using the native job rerun API; successful unrelated product jobs are retained.
Verifying these changes
Does this PR potentially affect the following parts?
Documentation Status
Doc - TODODoc - Done: Docker Server heap sizing.Doc - No NeedHeap sizing at a glance
The diagram illustrates the default calculation in this change. Explicit heap options retain precedence.

The heap is only part of process memory; native allocations, stacks, and caches still need headroom.
This illustration describes the design, not runtime acceptance or merge readiness.