Repository navigation
fix: keep cache pressure target under high RSS - #24543
2 commits merged into
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 addresses CN OOM risk under high RSS pressure by making cache eviction/admission enforcement more effective during RSS scavenging, so memory/meta caches don’t quickly refill back to near-cap after an eviction.
Changes:
- Enable RSS scavenging + cache-family eviction for the default
Workspacemem throttler (disttae engine). - Introduce “sticky” pressure admission targets (with TTL) for FileService memory cache and objectio meta cache, and skip cache writes that would exceed the active pressure target.
- Add unit tests covering pressure-admission behavior and expiry for both caches.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| pkg/vm/engine/disttae/engine.go | Adds RSS cache-eviction hook to Workspace throttler and applies sticky cache pressure targets. |
| pkg/cnservice/server.go | Extends RSS cache evictor to also set sticky cache pressure admission targets. |
| pkg/fileservice/mem_cache.go | Adds memory-cache pressure target state and skips cache admission above active target. |
| pkg/fileservice/mem_cache_test.go | Adds tests for memory-cache pressure admission skip + expiry. |
| pkg/objectio/cache.go | Adds meta-cache pressure target state and skips meta cache admission above active target. |
| pkg/objectio/meta_test.go | Adds tests for meta-cache pressure admission skip + expiry. |
609d18a to
ef8e307
Compare
XuPeng-SH
left a comment
There was a problem hiding this comment.
Reviewed from correctness, concurrency, cancellation, and regression angles.
The RSS pressure handling now closes the loop end-to-end: eviction and sticky admission targets are wired consistently for both CNFlushS3 and Workspace, the FIFO admission path accounts atomically under queueLock, and the added tests cover the key pressure-admission and timeout behaviors.
LGTM.
## What type of PR is this? - [ ] API-change - [x] BUG - [ ] Improvement - [ ] Documentation - [ ] Feature - [ ] Test and CI - [ ] Code Refactoring ## Which issue(s) this PR fixes: issue #24592 ## What this PR does / why we need it: This PR reverts the risky semantic changes from the previous RSS-pressure fixes, then restores only the minimal cache-pressure protection needed for high RSS: 1. Revert the prior cache/PK-path changes from #24535, #24542, and #24543 as a clean baseline. 2. Keep the low-risk fileservice event logger cap and strip request event logging from cache-capacity eviction before cache-data allocation. 3. Under RSS pressure, asynchronously evict fileservice memory cache and objectio metadata cache to a bounded target. 4. Run CN memory-cache and metadata-cache pressure eviction concurrently so one slow cache family cannot consume the shared pressure timeout and skip the other. 5. Keep a short pressure admission target so memory/meta cache writes do not immediately refill the just-evicted caches. 6. Do not change PK check concurrency behavior beyond reverting the risky metadata/BF/tombstone scope expansion. 7. Do not change tombstone, metadata, or bloom-filter read policy. 8. Keep foreground cache allocation from consuming global async eviction debt. 9. Add pressure logs and metrics for RSS trigger, cache eviction duration, and admission skips. The intended behavior is: - Normal RSS: no cache throttling or PK-path behavior change. - High RSS: background cache/meta eviction plus temporary cache-admission suppression. - Foreground reads/writes: no global PK semaphore expansion, no tombstone policy change, no metadata/BF policy change. ## Test ```text git diff --check git diff --check base/4.0-dev...HEAD GOCACHE=/private/tmp/mo-gocache go test ./pkg/fileservice/fifocache -run 'TestEvict|TestPostEvict|TestMemoryCache|TestCachePressure|TestEvictToTarget' -count=1 GOCACHE=/private/tmp/mo-gocache go test ./pkg/fileservice -run 'TestEventLogger|TestWithoutEventLogger|TestMemoryCache|TestDiskCacheReadEnsuresMemoryCacheCapacity' -count=1 GOCACHE=/private/tmp/mo-gocache go test ./pkg/objectio -run 'TestMetaCachePressure' -count=1 GOCACHE=/private/tmp/mo-gocache go test ./pkg/common/rscthrottler -run 'TestMemThrottlerRSS|TestAcquirePolicyForCNFlushS3|TestAcquirePolicyForDataBranch' -count=1 GOCACHE=/private/tmp/mo-gocache go test ./pkg/cnservice -run 'TestMakeRSSCacheEvictor|Test_InitServer|Test_tenant' -count=1 GOCACHE=/private/tmp/mo-gocache go test ./pkg/vm/engine/disttae -run 'TestTombstonePKExistsInRange|TestLinearSearchOffsetByValFactory' -count=1 GOCACHE=/private/tmp/mo-gocache go test ./pkg/vm/engine/disttae -run 'TestPKCheckSemaphore|TestTombstonePKExistsInRange' -count=1 ```
This PR ports the final minimal RSS cache pressure protection from #24612 to `main`. Background: - #24535 tried to reduce CN RSS pressure under TPCC/sysbench, but it mixed cache pressure handling with broader PK, tombstone, metadata, and BF read-path behavior changes. - #24542 added fileservice event logger capacity protection. - #24543 kept cache pressure admission targets active under high RSS. - #24612 reverted the risky mixed behavior on `4.0-dev` and restored only the smaller validated RSS cache pressure protection. `main` does not contain the risky #24535/#24542/#24543 commits, so this PR does not cherry-pick those revert commits. It ports the final net behavior directly: - cap fileservice event logger events; - avoid carrying request event logs into cache capacity eviction; - asynchronously trigger memory cache and metadata cache eviction under RSS pressure; - keep a short pressure admission TTL to prevent immediate cache refill; - keep foreground `EvictWithWait` from absorbing async eviction debt; - add cache pressure trigger / eviction / admission-skip / eviction-duration metrics; - run CN memory/meta cache family eviction concurrently with independent timeouts; - add focused coverage for cache admission, target eviction, event logger caps, RSS soft/hard target escalation, and CN concurrent eviction. One `main` port adjustment: - `tryScavengeRSS` captures the evictor and `freeOSMemory` hook before launching the async goroutine, preserving behavior while avoiding a race-detector issue in tests that replace the package-level hook. Validation: ```text GOCACHE=/private/tmp/mo-gocache-main go test ./pkg/fileservice/fifocache -run 'TestEvict|TestPostEvict|TestMemoryCache|TestCachePressure|TestEvictToTarget' -count=1 GOCACHE=/private/tmp/mo-gocache-main go test ./pkg/fileservice -run 'TestEventLogger|TestWithoutEventLogger|TestMemoryCache|TestDiskCacheReadEnsuresMemoryCacheCapacity' -count=1 GOCACHE=/private/tmp/mo-gocache-main go test ./pkg/objectio -run 'TestMetaCachePressure' -count=1 GOCACHE=/private/tmp/mo-gocache-main go test ./pkg/common/rscthrottler -run 'TestMemThrottlerRSS|TestAcquirePolicyForCNFlushS3|TestAcquirePolicyForDataBranch' -count=1 GOCACHE=/private/tmp/mo-gocache-main go test ./pkg/cnservice -run 'TestMakeRSSCacheEvictor|Test_InitServer|Test_tenant' -count=1 GOCACHE=/private/tmp/mo-gocache-main go test ./pkg/util/metric/v2 -run TestNonExistent -count=0 GOCACHE=/private/tmp/mo-gocache-main go test -race ./pkg/common/rscthrottler -run 'TestMemThrottlerRSSCacheEviction' -count=10 GOCACHE=/private/tmp/mo-gocache-main go test -race ./pkg/cnservice -run 'TestMakeRSSCacheEvictor' -count=10 git diff --check base/main...HEAD ``` Approved by: @gouhongshen, @XuPeng-SH, @aptend
…#24615) This PR ports the final minimal RSS cache pressure protection from matrixorigin#24612 to `main`. Background: - matrixorigin#24535 tried to reduce CN RSS pressure under TPCC/sysbench, but it mixed cache pressure handling with broader PK, tombstone, metadata, and BF read-path behavior changes. - matrixorigin#24542 added fileservice event logger capacity protection. - matrixorigin#24543 kept cache pressure admission targets active under high RSS. - matrixorigin#24612 reverted the risky mixed behavior on `4.0-dev` and restored only the smaller validated RSS cache pressure protection. `main` does not contain the risky matrixorigin#24535/matrixorigin#24542/matrixorigin#24543 commits, so this PR does not cherry-pick those revert commits. It ports the final net behavior directly: - cap fileservice event logger events; - avoid carrying request event logs into cache capacity eviction; - asynchronously trigger memory cache and metadata cache eviction under RSS pressure; - keep a short pressure admission TTL to prevent immediate cache refill; - keep foreground `EvictWithWait` from absorbing async eviction debt; - add cache pressure trigger / eviction / admission-skip / eviction-duration metrics; - run CN memory/meta cache family eviction concurrently with independent timeouts; - add focused coverage for cache admission, target eviction, event logger caps, RSS soft/hard target escalation, and CN concurrent eviction. One `main` port adjustment: - `tryScavengeRSS` captures the evictor and `freeOSMemory` hook before launching the async goroutine, preserving behavior while avoiding a race-detector issue in tests that replace the package-level hook. Validation: ```text GOCACHE=/private/tmp/mo-gocache-main go test ./pkg/fileservice/fifocache -run 'TestEvict|TestPostEvict|TestMemoryCache|TestCachePressure|TestEvictToTarget' -count=1 GOCACHE=/private/tmp/mo-gocache-main go test ./pkg/fileservice -run 'TestEventLogger|TestWithoutEventLogger|TestMemoryCache|TestDiskCacheReadEnsuresMemoryCacheCapacity' -count=1 GOCACHE=/private/tmp/mo-gocache-main go test ./pkg/objectio -run 'TestMetaCachePressure' -count=1 GOCACHE=/private/tmp/mo-gocache-main go test ./pkg/common/rscthrottler -run 'TestMemThrottlerRSS|TestAcquirePolicyForCNFlushS3|TestAcquirePolicyForDataBranch' -count=1 GOCACHE=/private/tmp/mo-gocache-main go test ./pkg/cnservice -run 'TestMakeRSSCacheEvictor|Test_InitServer|Test_tenant' -count=1 GOCACHE=/private/tmp/mo-gocache-main go test ./pkg/util/metric/v2 -run TestNonExistent -count=0 GOCACHE=/private/tmp/mo-gocache-main go test -race ./pkg/common/rscthrottler -run 'TestMemThrottlerRSSCacheEviction' -count=10 GOCACHE=/private/tmp/mo-gocache-main go test -race ./pkg/cnservice -run 'TestMakeRSSCacheEvictor' -count=10 git diff --check base/main...HEAD ``` Approved by: @gouhongshen, @XuPeng-SH, @aptend
…#24615) This PR ports the final minimal RSS cache pressure protection from matrixorigin#24612 to `main`. Background: - matrixorigin#24535 tried to reduce CN RSS pressure under TPCC/sysbench, but it mixed cache pressure handling with broader PK, tombstone, metadata, and BF read-path behavior changes. - matrixorigin#24542 added fileservice event logger capacity protection. - matrixorigin#24543 kept cache pressure admission targets active under high RSS. - matrixorigin#24612 reverted the risky mixed behavior on `4.0-dev` and restored only the smaller validated RSS cache pressure protection. `main` does not contain the risky matrixorigin#24535/matrixorigin#24542/matrixorigin#24543 commits, so this PR does not cherry-pick those revert commits. It ports the final net behavior directly: - cap fileservice event logger events; - avoid carrying request event logs into cache capacity eviction; - asynchronously trigger memory cache and metadata cache eviction under RSS pressure; - keep a short pressure admission TTL to prevent immediate cache refill; - keep foreground `EvictWithWait` from absorbing async eviction debt; - add cache pressure trigger / eviction / admission-skip / eviction-duration metrics; - run CN memory/meta cache family eviction concurrently with independent timeouts; - add focused coverage for cache admission, target eviction, event logger caps, RSS soft/hard target escalation, and CN concurrent eviction. One `main` port adjustment: - `tryScavengeRSS` captures the evictor and `freeOSMemory` hook before launching the async goroutine, preserving behavior while avoiding a race-detector issue in tests that replace the package-level hook. Validation: ```text GOCACHE=/private/tmp/mo-gocache-main go test ./pkg/fileservice/fifocache -run 'TestEvict|TestPostEvict|TestMemoryCache|TestCachePressure|TestEvictToTarget' -count=1 GOCACHE=/private/tmp/mo-gocache-main go test ./pkg/fileservice -run 'TestEventLogger|TestWithoutEventLogger|TestMemoryCache|TestDiskCacheReadEnsuresMemoryCacheCapacity' -count=1 GOCACHE=/private/tmp/mo-gocache-main go test ./pkg/objectio -run 'TestMetaCachePressure' -count=1 GOCACHE=/private/tmp/mo-gocache-main go test ./pkg/common/rscthrottler -run 'TestMemThrottlerRSS|TestAcquirePolicyForCNFlushS3|TestAcquirePolicyForDataBranch' -count=1 GOCACHE=/private/tmp/mo-gocache-main go test ./pkg/cnservice -run 'TestMakeRSSCacheEvictor|Test_InitServer|Test_tenant' -count=1 GOCACHE=/private/tmp/mo-gocache-main go test ./pkg/util/metric/v2 -run TestNonExistent -count=0 GOCACHE=/private/tmp/mo-gocache-main go test -race ./pkg/common/rscthrottler -run 'TestMemThrottlerRSSCacheEviction' -count=10 GOCACHE=/private/tmp/mo-gocache-main go test -race ./pkg/cnservice -run 'TestMakeRSSCacheEvictor' -count=10 git diff --check base/main...HEAD ``` Approved by: @gouhongshen, @XuPeng-SH, @aptend
…#24615) This PR ports the final minimal RSS cache pressure protection from matrixorigin#24612 to `main`. Background: - matrixorigin#24535 tried to reduce CN RSS pressure under TPCC/sysbench, but it mixed cache pressure handling with broader PK, tombstone, metadata, and BF read-path behavior changes. - matrixorigin#24542 added fileservice event logger capacity protection. - matrixorigin#24543 kept cache pressure admission targets active under high RSS. - matrixorigin#24612 reverted the risky mixed behavior on `4.0-dev` and restored only the smaller validated RSS cache pressure protection. `main` does not contain the risky matrixorigin#24535/matrixorigin#24542/matrixorigin#24543 commits, so this PR does not cherry-pick those revert commits. It ports the final net behavior directly: - cap fileservice event logger events; - avoid carrying request event logs into cache capacity eviction; - asynchronously trigger memory cache and metadata cache eviction under RSS pressure; - keep a short pressure admission TTL to prevent immediate cache refill; - keep foreground `EvictWithWait` from absorbing async eviction debt; - add cache pressure trigger / eviction / admission-skip / eviction-duration metrics; - run CN memory/meta cache family eviction concurrently with independent timeouts; - add focused coverage for cache admission, target eviction, event logger caps, RSS soft/hard target escalation, and CN concurrent eviction. One `main` port adjustment: - `tryScavengeRSS` captures the evictor and `freeOSMemory` hook before launching the async goroutine, preserving behavior while avoiding a race-detector issue in tests that replace the package-level hook. Validation: ```text GOCACHE=/private/tmp/mo-gocache-main go test ./pkg/fileservice/fifocache -run 'TestEvict|TestPostEvict|TestMemoryCache|TestCachePressure|TestEvictToTarget' -count=1 GOCACHE=/private/tmp/mo-gocache-main go test ./pkg/fileservice -run 'TestEventLogger|TestWithoutEventLogger|TestMemoryCache|TestDiskCacheReadEnsuresMemoryCacheCapacity' -count=1 GOCACHE=/private/tmp/mo-gocache-main go test ./pkg/objectio -run 'TestMetaCachePressure' -count=1 GOCACHE=/private/tmp/mo-gocache-main go test ./pkg/common/rscthrottler -run 'TestMemThrottlerRSS|TestAcquirePolicyForCNFlushS3|TestAcquirePolicyForDataBranch' -count=1 GOCACHE=/private/tmp/mo-gocache-main go test ./pkg/cnservice -run 'TestMakeRSSCacheEvictor|Test_InitServer|Test_tenant' -count=1 GOCACHE=/private/tmp/mo-gocache-main go test ./pkg/util/metric/v2 -run TestNonExistent -count=0 GOCACHE=/private/tmp/mo-gocache-main go test -race ./pkg/common/rscthrottler -run 'TestMemThrottlerRSSCacheEviction' -count=10 GOCACHE=/private/tmp/mo-gocache-main go test -race ./pkg/cnservice -run 'TestMakeRSSCacheEvictor' -count=10 git diff --check base/main...HEAD ``` Approved by: @gouhongshen, @XuPeng-SH, @aptend
Summary
Fixes #24534.
This follows the post-#24542 OOM evidence from the 4.0-dev nightly run:
nightly-regression-dis-tp-cn-6t6mxwas OOMKilled during sysbench update-index 1000.fileservice.eventLogger.emitas the dominant heap owner.Workspaceobserved the pressure, but only the CNFlushS3 throttler had RSS cache eviction configured.Changes
Workspacethrottler, so hard RSS observed by workspace allocation paths can evict memory/meta caches to the hard target.Tests
GOCACHE=/private/tmp/matrixone-rss-cache-gocache go test ./pkg/fileservice -run 'TestMemoryCachePressureAdmission|TestMemoryCacheEvictToCapacityPercent'Local broader package tests are blocked by existing environment dependencies:
go test ./pkg/objectio ...andgo test ./pkg/cnservice ...fail during build because this machine is missingusearch.handxxhash.h.pkg/fileservicetests also hit sandbox networking restrictions inhttptestlistener setup.