add rss pressure cache controller - #24665
Conversation
Qodo reviews are paused for this user.Troubleshooting steps vary by plan Learn more → On a Teams plan? Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center? |
There was a problem hiding this comment.
Pull request overview
This PR adds an explicit RSS pressure controller for memory cache admission and eviction, replacing TTL-only lifecycle behavior with state-based pressure handling.
Changes:
- Adds RSS pressure states (
none,soft,hard) with hysteresis thresholds and target percentages. - Splits pressure target set/clear from cache eviction and adds generation checks for async eviction.
- Exports memory cache pressure target clearing and wires the new pressure target callbacks in CN and workspace throttlers.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
pkg/common/rscthrottler/resource_throttler.go |
Implements RSS pressure state machine, target lifecycle callbacks, and async evict generation guard. |
pkg/common/rscthrottler/resource_throttler_test.go |
Adds lifecycle coverage for state transitions and updates concurrent escalation test inputs. |
pkg/fileservice/mem_cache.go |
Exports pressure target clearing and reuses it for invalid target inputs. |
pkg/fileservice/mem_cache_test.go |
Adds coverage for clearing memory cache pressure targets. |
pkg/cnservice/server.go |
Wires CN RSS cache pressure target setter/clearer separately from eviction. |
pkg/vm/engine/disttae/engine.go |
Wires workspace RSS cache pressure target setter/clearer separately from eviction. |
|
Addressed the review findings:
Re-ran focused tests: GOCACHE=/private/tmp/mo-gocache-step3 go test -mod=mod ./pkg/common/rscthrottler -run 'TestMemThrottlerRSS' -count=1
GOCACHE=/private/tmp/mo-gocache-step3 go test -mod=mod ./pkg/fileservice -run 'TestMemoryCachePressure|TestClearMemoryCachePressureTarget|TestMemoryCacheEvictToCapacityPercent' -count=1
GOCACHE=/private/tmp/mo-gocache-step3 go test -mod=mod ./pkg/cnservice -run 'TestMakeRSSCacheEvictorEvictsMemoryCacheOnly' -count=1
GOCACHE=/private/tmp/mo-gocache-step3 go test -mod=mod ./pkg/vm/engine/disttae -run 'TestNonExistent' -count=1 |
gouhongshen
left a comment
There was a problem hiding this comment.
Code-review skill result (full review mode): no must-fix / merge-blocking issues found.\n\nDestructive-test conclusion: PARTIAL. The PR adds focused lifecycle and owner-isolation tests, but does not include destructive stress tests for concurrent owner target churn or deadline/ownership races under continuous pressure transitions (e.g., interleaving SetByOwner and ClearByOwner under concurrent scavenge calls).\n\nNon-blocking findings:\n1) Consider adding a concurrency-focused destructive test around owner-target interleaving to validate effective target recomputation under high-frequency transitions.\n2) Consider adding a test for expired-owner cleanup during repeated pressure churn to confirm effective deadline handling remains correct under continuous updates.\n\nThese findings are non-blocking and do not prevent merge.
Merge Queue Status
This pull request spent 1 minute 9 seconds in the queue, including 13 seconds running CI. Required conditions to merge
|
### 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 Co-authored-by: XuPeng-SH <xupeng3112@163.com>
What type of PR is this?
Which issue(s) this PR fixes:
Fixes #24664
What this PR does / why we need it:
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:
none,soft, andhard;none -> soft: RSS >= 85%;soft -> hard: RSS >= 92%;hard -> soft: RSS <= 88%;soft/hard -> none: RSS <= 80%;debug.FreeOSMemoryactions throttled by cooldown;The change keeps Step 1/2 behavior intact: RSS pressure still only controls data/memory cache and does not force objectio meta cache eviction.