Repository navigation
fix: reduce CN RSS pressure under TPCC - #24535
Conversation
Add RSS-triggered cache pressure eviction for CN memory and object metadata caches, and expand PK conflict check throttling to metadata, bloom filter, block, and tombstone reads. Co-authored-by: Copilot <[email protected]>
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 reduces CN resident set size (RSS) pressure under high-concurrency TPCC by enabling “evict-to-target” behavior for key memory caches, wiring cache eviction into RSS scavenging at high watermarks, and expanding the PK conflict-check semaphore scope to cover more of the I/O-heavy path.
Changes:
- Add target-based eviction APIs for FileService memory caches and objectio metadata cache (evict down to a capacity percentage, even when already under cap).
- Trigger cache eviction (soft/hard targets) from
rscthrottlerRSS scavenging and follow withfreeOSMemory()to encourage RSS return. - Acquire the PK conflict I/O semaphore earlier in
PKPersistedBetweento bound concurrent metadata/BF/block/tombstone reads; add unit tests for new behaviors.
Reviewed changes
Copilot reviewed 12 out of 12 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| pkg/vm/engine/disttae/txn_table.go | Move PK conflict I/O semaphore acquisition earlier to cover more of the PK check I/O path. |
| pkg/objectio/cache.go | Add metadata cache eviction to a capacity-percentage target. |
| pkg/fileservice/mem_cache.go | Add MemCache helpers to evict to a target and to a capacity-percentage target. |
| pkg/fileservice/mem_cache_test.go | Add test coverage for capacity-percentage eviction across global memory caches. |
| pkg/fileservice/fscache/data_cache.go | Extend DataCache interface with target-based eviction methods. |
| pkg/fileservice/fifocache/fifo.go | Implement EvictToTargetWithWait/ForceEvictWithWait and expose Used/Capacity on FIFO cache. |
| pkg/fileservice/fifocache/data_cache.go | Plumb new eviction APIs through the FIFO DataCache wrapper. |
| pkg/fileservice/disk_cache_test.go | Update test stub to satisfy the extended DataCache interface. |
| pkg/fileservice/cache.go | Add global EvictMemoryCachesToCapacityPercent for pressure-driven eviction. |
| pkg/common/rscthrottler/resource_throttler.go | Add RSS watermark-driven cache eviction hook and option (WithRSSCacheEvictor). |
| pkg/common/rscthrottler/resource_throttler_test.go | Add tests validating RSS-rate-based cache eviction triggering. |
| pkg/cnservice/server.go | Wire CN mem throttler RSS cache-eviction hook to FileService + objectio caches. |
Keep cache pressure eviction throttling separate from OS scavenging so a soft cache target does not block later hard eviction under rising RSS. Co-authored-by: Copilot <[email protected]>
XuPeng-SH
left a comment
There was a problem hiding this comment.
LGTM. The RSS-triggered cache eviction, FIFO pressure-eviction path, and earlier PK conflict throttling all look sound. I did not find a blocking correctness or concurrency issue in the changed paths.
fengttt
left a comment
There was a problem hiding this comment.
Do we know this PR actually helps? Any measurement?
I am really happy that queueLock.Unlock is finally sane (a simple defer without making postEvict dangling out of lock). I am really disapointed we still need this queueLock at all -- why a cache replacement need a queue, or queueLock, is beyond me ...
Co-authored-by: Copilot <[email protected]>
What we do have is the failure evidence and targeted verification for the mechanisms this PR changes: In the original TPCC OOM window, small PK-conflict reads could trigger full-file preload and turn ~40-50KiB entries into ~80-95MiB full-object reads. This PR disables full-file preload only for PK conflict / tombstone PK check reads; normal scan workloads keep the default policy. I agree the cache queue/queueLock design is worth revisiting separately, but I would keep that out of this PR to avoid turning this OOM fix into a larger cache replacement refactor. |
Co-authored-by: Copilot <[email protected]>
Co-authored-by: Copilot <[email protected]>
Merge Queue Status
This pull request spent 26 seconds in the queue, including 3 seconds running CI. Required conditions to merge
|
What type of PR is this?
Which issue(s) this PR fixes:
Fixes #24534
What this PR does / why we need it:
This PR reduces CN RSS pressure under high-concurrency TPCC / sysbench workloads.
EvictMemoryCaches/EvictCacheonly evict to current capacity and do not release RSS when caches are already under cap.debug.FreeOSMemory()pass is also run after cache pressure eviction.PKPersistedBetweenthrottling earlier so the semaphore covers real metadata/BF/block/tombstone reads.Validation: