Repository navigation
Count a heap snapshot as 1.5x the heap in the room check - #1818
Merged
Merged
Conversation
The guard let a snapshot through when rss + heapUsed fit in 85 % of the cgroup limit. On 2026-11-21 a snapshot of a 2.4 GB heap with 2.7 GB RSS grew the process to 5.9 GB (1.32x the heap) and the kernel killed it in its 6 GB cgroup. The check now counts 1.5x the used heap, and the log lines quote that estimate.
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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
The heap snapshot guard (
HEAP_SNAPSHOT_PERCENT) allowed a snapshot wheneverrss + heapUsedfit in 85 % of the cgroup limit, on the assumption that a snapshot needs about one extra heap of memory. That was too little. On 2026-11-21, with a 2.4 GB heap and 2.7 GB RSS in a 6 GB container, the guard allowed the snapshot (5.1 GB fits under 5.2 GB). The process then grew to 5.9 GB, 1.32x the heap, and the kernel killed it. The setting is off by default and is off again where it was turned on. This PR makes the guard refuse a case like this one.Changes
process-vitals.ts: newSNAPSHOT_COST_FACTOR = 1.5andsnapshotCost(). The room check now counts 1.5x the used heap.process-vitals.service.ts: the "snapshot" and "snapshot-skipped" log lines quote that estimate.process-vitals.spec.ts: a regression test with the 2026-11-21 numbers, which now givesnapshot-skipped..env.example: the comment onHEAP_SNAPSHOT_PERCENTexplains the 1.5x.Self-hosted and Cloud behave the same. The default is unchanged (0, no snapshot).
Type
Testing
In
packages/backend:npx jest --maxWorkers=2 src/common/process-vitals: 29/29 passnpx eslinton the three files: cleannpx tsc --noEmit -p tsconfig.json: no errors in the changed files. This worktree had no generated Prisma client, so unrelated files report Prisma errors; CI generates it.Checklist