Skip to content

cherry-pick: add rss pressure cache controller - #24678

Merged
XuPeng-SH merged 2 commits into
matrixorigin:4.0-devfrom
LeftHandCold:backport/rss-pressure-controller-step3-4.0-dev
May 28, 2026
Merged

XuPeng-SH merged 2 commits into
matrixorigin:4.0-devfrom
LeftHandCold:backport/rss-pressure-controller-step3-4.0-dev

Conversation

@LeftHandCold

Copy link
Copy Markdown
Collaborator

What type of PR is this?

/kind improvement

What this PR does / why we need it:

Cherry-pick #24665 to 4.0-dev.

This backports the RSS pressure controller state machine and cache pressure target lifecycle improvements:

  • use none / soft / hard RSS pressure states with hysteresis;
  • keep memory cache pressure target as a lease while RSS pressure is active, and clear it immediately after pressure exits;
  • separate action throttling from pressure state transitions;
  • use owner-scoped memory cache pressure targets so CN and Workspace controllers do not clear each other;
  • keep async cache eviction guarded by pressure generation to avoid stale eviction actions from rewriting controller state.

Which issue(s) this PR fixes:

Refs #24664
Backport of #24665

Special notes for your reviewer:

The cherry-pick had one conflict in pkg/common/rscthrottler/resource_throttler.go. The conflict was resolved by keeping the main-branch generation guard for async cache eviction.

Does this PR introduce a user-facing change?

NONE

How to test:

  • GOCACHE=/private/tmp/mo-gocache-pr24665-4dev go test ./pkg/common/rscthrottler ./pkg/fileservice ./pkg/cnservice -run 'TestMemThrottlerRSS|TestMemoryCachePressure|TestClearMemoryCachePressureTarget|TestMakeRSSCacheEvictor' -count=1

This PR adds an RSS pressure controller for memory cache pressure handling.

Before this change, RSS cache pressure used a fixed admission-target TTL as the main lifecycle mechanism. If RSS recovered quickly, the memory cache admission target could still remain active until the TTL expired, slowing data cache recovery.

This PR changes that behavior by:

- adding explicit RSS pressure states: `none`, `soft`, and `hard`;
- using hysteresis for state transitions:
- `none -> soft`: RSS >= 85%;
- `soft -> hard`: RSS >= 92%;
- `hard -> soft`: RSS <= 88%;
- `soft/hard -> none`: RSS <= 80%;
- setting memory cache admission target by state:
- soft: 80%;
- hard: 50%;
- clearing the memory cache admission target immediately when pressure exits;
- keeping evict and `debug.FreeOSMemory` actions throttled by cooldown;
- keeping the target TTL as a lease fallback that is renewed while pressure remains active;
- splitting target set/clear from cache eviction so asynchronous evict actions cannot restore stale pressure targets;
- guarding async evict with a pressure generation check.

The change keeps Step 1/2 behavior intact: RSS pressure still only controls data/memory cache and does not force objectio meta cache eviction.

Approved by: @gouhongshen, @XuPeng-SH

(cherry picked from commit 2b52daa)
Copilot AI review requested due to automatic review settings May 28, 2026 10:39
@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 →

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Backports the RSS pressure controller state machine and improves memory cache pressure target lifecycle so cache admission limits are applied/renewed only while RSS pressure is active and cleared immediately on exit, with owner-scoped targets to prevent different controllers from overwriting each other.

Changes:

  • Introduces an explicit RSS pressure state machine (none/soft/hard) with hysteresis and separates state transitions from throttled actions (evict / debug.FreeOSMemory cooldown).
  • Adds owner-scoped memory cache pressure targets in fileservice, computing an effective target across active owners and supporting per-owner clear.
  • Wires CN and Workspace RSS controllers to set/clear their own cache pressure targets and updates/extends unit tests for the new lifecycle.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated no comments.

Show a summary per file
File Description
pkg/vm/engine/disttae/engine.go Adds workspace-specific owner-scoped cache pressure target setter/clearer and passes them into the RSS throttler options.
pkg/fileservice/mem_cache.go Implements owner-scoped pressure targets with an aggregated effective admission target and adds clear APIs.
pkg/fileservice/mem_cache_test.go Adds tests for clearing pressure targets and verifying owner isolation behavior.
pkg/common/rscthrottler/resource_throttler.go Replaces threshold-only behavior with an RSS pressure state machine + target lifecycle hooks and generation-guarded async eviction.
pkg/common/rscthrottler/resource_throttler_test.go Adds lifecycle/state-machine tests and updates concurrency test inputs for the new hysteresis behavior.
pkg/cnservice/server.go Adds CN-specific owner-scoped cache pressure target setter/clearer and wires them into the RSS throttler options.

@matrix-meow matrix-meow added the size/M Denotes a PR that changes [100,499] lines label May 28, 2026
@XuPeng-SH
XuPeng-SH merged commit 823dba7 into matrixorigin:4.0-dev May 28, 2026
1 of 4 checks passed

This branch was previously deployed

1 inactive deployment
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/M Denotes a PR that changes [100,499] lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants