Skip to content

test(embed): measure execution memory headroom against a per-process limit - #33142

Merged
fengttt merged 2 commits into
matrixorigin:mainfrom
fengttt:ut-embed-memory-headroom
Nov 24, 2026
Merged

fengttt merged 2 commits into
matrixorigin:mainfrom
fengttt:ut-embed-memory-headroom

Conversation

@fengttt

@fengttt fengttt commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

What type of PR is this?

  • Test and CI

Which issue(s) this PR fixes:

issue #33077

Also seen on #33115 (run 45332505615): TestSnapshotDatabasePublicationReplayBoundaries/incomplete_view_scope failed on use mo_catalog with

execution resource admission rejected: requested=48 used=0 cap=0;
physical memory headroom: sampled_available=1014726656 safety_reserve=1073741824 growth_headroom=0

What this PR does / why we need it:

Coverage UT runs 8 packages at once (-p 8) on a 15 GiB runner. A CN in an embedded test cluster admits execution memory against the host's available memory minus a 1 GiB margin. When other test binaries hold the host near that margin, every new allocation is refused, even 48 bytes, and whichever embedded test runs a query at that moment fails. The failure has nothing to do with the test or the PR under test.

This PR lets a process give execution admission a private memory limit:

  • process.SetExecutionPrivateMemoryLimit(limit): when non-zero, physical headroom is limit − this process's resident memory (system.ProcessResidentMemory). The process is treated as if it ran alone in a container of that size. The safety margin is sized from the limit instead of the whole host, so a large dev machine does not reserve more than the limit allows.
  • Embedded test clusters (embed.WithTesting) set 8 GiB before starting. Admission still refuses when the test process itself grows too large, but other processes on the runner no longer decide the outcome.
  • Servers never set it: a zero limit keeps the existing host/cgroup measurement, so production behaviour is unchanged.

Limit sizing: peak RSS measured locally with -cover -short binaries, as in CI:

package peak RSS
pkg/embed 4.0 GiB
pkg/tests/sqlintegration 2.9 GiB
pkg/tests/issues 2.0 GiB

With 8 GiB and the 1 GiB margin, refusal starts at about 7 GiB. All three packages pass with no refusals.

Tests: headroom arithmetic; headroom read from this process's own memory; the safety margin under a private limit; and a 48-byte request refused or admitted depending on this process's own memory use under the limit. pkg/vm/process and pkg/common/system pass; golangci-lint reports 0 issues.

Not changed: lock-retry pacing (lockop) and vector-index build sizing also read host free memory, but neither refuses small queries.

🤖 Generated with Claude Code

…limit

Coverage UT runs eight test packages at once on a 15 GiB runner. A CN in
an embedded test cluster admitted execution memory against the host's
available memory minus a 1 GiB margin, so when other packages held the
host near that margin even a 48-byte request was rejected
("execution resource admission rejected ... growth_headroom=0") and
unrelated tests such as TestSnapshotDatabasePublicationReplayBoundaries
failed at random.

A process can now give execution admission a private memory limit
(process.SetExecutionPrivateMemoryLimit). With one set, physical headroom
is the limit minus this process's own resident memory, and the safety
margin is sized from the limit rather than the host. Embedded test
clusters set 8 GiB; the heaviest packages peak at 2-4 GiB under -cover.
Servers never set a limit and keep the host/cgroup measurement.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@qodo-code-review

Copy link
Copy Markdown

Qodo reviews are paused for this user.

Troubleshooting steps vary by plan Learn more →

On a Teams plan?
Reviews resume once this user has a paid seat and their Git account is linked in Qodo.
Link Git account →

Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center?
These require an Enterprise plan - Contact us
Contact us →

@mergify mergify Bot added the kind/test-ci label Nov 24, 2026
@mergify

mergify Bot commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

This pull request is merged.

This branch was successfully deployed

No deployments
ci — 692ddeb0 Deployed Nov 24, 2026 by fengttt
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kind/test-ci size/M Denotes a PR that changes [100,499] lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants