Repository navigation
fix(cn): react to cgroup memory pressure - #26471
Closed
gouhongshen wants to merge 1 commit into
Closed
gouhongshen wants to merge 1 commit into
gouhongshen wants to merge 1 commit into
Conversation
1 task done
gouhongshen
force-pushed
the
codex/use-cgroup-memory-pressure
branch
from
July 31, 2026 02:38
f3f9d17 to
007cf0b
Compare
XuPeng-SH
pushed a commit
that referenced
this pull request
Jul 31, 2026
## What type of PR is this? - [x] Improvement ## Which issue(s) this PR fixes: Related to #26465 ## What this PR does / why we need it: After #26470 removed the per-object allocation, large table scans still test every visible tombstone object for every data block. The QA workload in #26465 has system tables with roughly 700 visible tombstone objects and scans roughly 132 data blocks per statement, resulting in about 92,000 object-level Rowid zone-map checks per scan. This PR builds a per-data-source interval index from each tombstone object's Rowid zone-map block range: - ranges are sorted by minimum block ID and carry a cumulative maximum; - each data block queries only intervals that can contain its block ID; - candidate objects are restored to the original visible-object order before the existing tombstone reader is called, preserving read and error order; - objects without an initialized Rowid zone map remain unconditional candidates because they cannot be safely excluded; - scans below 32 blocks keep the existing allocation-free linear iterator to avoid paying the index construction cost for small reads; - the index and candidate scratch space are released when the data source is closed. The existing object/block zone-map checks remain in place. This changes only candidate selection, not tombstone visibility or deletion semantics. Validation: - `go test ./pkg/vm/engine/disttae -count=1` - `go test -race ./pkg/vm/engine/disttae -run '^TestTombstoneObjectIndex' -count=1` - exhaustive equivalence test over 701 objects and 1,100 block IDs - QA-shape benchmark (700 tombstone objects, 132 data blocks, 5 iterations): - linear scan: about 501 us/op - index build: about 72 us/op, 57,344 B/op, 1 alloc/op - indexed block queries: about 11.8 us/op, 0 B/op - build plus queries is about 6x faster than the linear scan This is intentionally separate from the cgroup pressure handling in #26471. It reduces the work generated by the workload but does not claim to solve all sources of CN memory pressure by itself. --------- Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
VioletQwQ-0
pushed a commit
to VioletQwQ-0/matrixone
that referenced
this pull request
Sep 17, 2026
## What type of PR is this? - [x] Improvement ## Which issue(s) this PR fixes: Related to matrixorigin#26465 ## What this PR does / why we need it: After matrixorigin#26470 removed the per-object allocation, large table scans still test every visible tombstone object for every data block. The QA workload in matrixorigin#26465 has system tables with roughly 700 visible tombstone objects and scans roughly 132 data blocks per statement, resulting in about 92,000 object-level Rowid zone-map checks per scan. This PR builds a per-data-source interval index from each tombstone object's Rowid zone-map block range: - ranges are sorted by minimum block ID and carry a cumulative maximum; - each data block queries only intervals that can contain its block ID; - candidate objects are restored to the original visible-object order before the existing tombstone reader is called, preserving read and error order; - objects without an initialized Rowid zone map remain unconditional candidates because they cannot be safely excluded; - scans below 32 blocks keep the existing allocation-free linear iterator to avoid paying the index construction cost for small reads; - the index and candidate scratch space are released when the data source is closed. The existing object/block zone-map checks remain in place. This changes only candidate selection, not tombstone visibility or deletion semantics. Validation: - `go test ./pkg/vm/engine/disttae -count=1` - `go test -race ./pkg/vm/engine/disttae -run '^TestTombstoneObjectIndex' -count=1` - exhaustive equivalence test over 701 objects and 1,100 block IDs - QA-shape benchmark (700 tombstone objects, 132 data blocks, 5 iterations): - linear scan: about 501 us/op - index build: about 72 us/op, 57,344 B/op, 1 alloc/op - indexed block queries: about 11.8 us/op, 0 B/op - build plus queries is about 6x faster than the linear scan This is intentionally separate from the cgroup pressure handling in matrixorigin#26471. It reduces the work generated by the workload but does not claim to solve all sources of CN memory pressure by itself. --------- Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
VioletQwQ-0
pushed a commit
to VioletQwQ-0/matrixone
that referenced
this pull request
Sep 17, 2026
## What type of PR is this? - [x] Improvement ## Which issue(s) this PR fixes: Related to matrixorigin#26465 ## What this PR does / why we need it: After matrixorigin#26470 removed the per-object allocation, large table scans still test every visible tombstone object for every data block. The QA workload in matrixorigin#26465 has system tables with roughly 700 visible tombstone objects and scans roughly 132 data blocks per statement, resulting in about 92,000 object-level Rowid zone-map checks per scan. This PR builds a per-data-source interval index from each tombstone object's Rowid zone-map block range: - ranges are sorted by minimum block ID and carry a cumulative maximum; - each data block queries only intervals that can contain its block ID; - candidate objects are restored to the original visible-object order before the existing tombstone reader is called, preserving read and error order; - objects without an initialized Rowid zone map remain unconditional candidates because they cannot be safely excluded; - scans below 32 blocks keep the existing allocation-free linear iterator to avoid paying the index construction cost for small reads; - the index and candidate scratch space are released when the data source is closed. The existing object/block zone-map checks remain in place. This changes only candidate selection, not tombstone visibility or deletion semantics. Validation: - `go test ./pkg/vm/engine/disttae -count=1` - `go test -race ./pkg/vm/engine/disttae -run '^TestTombstoneObjectIndex' -count=1` - exhaustive equivalence test over 701 objects and 1,100 block IDs - QA-shape benchmark (700 tombstone objects, 132 data blocks, 5 iterations): - linear scan: about 501 us/op - index build: about 72 us/op, 57,344 B/op, 1 alloc/op - indexed block queries: about 11.8 us/op, 0 B/op - build plus queries is about 6x faster than the linear scan This is intentionally separate from the cgroup pressure handling in matrixorigin#26471. It reduces the work generated by the workload but does not claim to solve all sources of CN memory pressure by itself. --------- Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
VioletQwQ-0
pushed a commit
to VioletQwQ-0/matrixone
that referenced
this pull request
Sep 17, 2026
## What type of PR is this? - [x] Improvement ## Which issue(s) this PR fixes: Related to matrixorigin#26465 ## What this PR does / why we need it: After matrixorigin#26470 removed the per-object allocation, large table scans still test every visible tombstone object for every data block. The QA workload in matrixorigin#26465 has system tables with roughly 700 visible tombstone objects and scans roughly 132 data blocks per statement, resulting in about 92,000 object-level Rowid zone-map checks per scan. This PR builds a per-data-source interval index from each tombstone object's Rowid zone-map block range: - ranges are sorted by minimum block ID and carry a cumulative maximum; - each data block queries only intervals that can contain its block ID; - candidate objects are restored to the original visible-object order before the existing tombstone reader is called, preserving read and error order; - objects without an initialized Rowid zone map remain unconditional candidates because they cannot be safely excluded; - scans below 32 blocks keep the existing allocation-free linear iterator to avoid paying the index construction cost for small reads; - the index and candidate scratch space are released when the data source is closed. The existing object/block zone-map checks remain in place. This changes only candidate selection, not tombstone visibility or deletion semantics. Validation: - `go test ./pkg/vm/engine/disttae -count=1` - `go test -race ./pkg/vm/engine/disttae -run '^TestTombstoneObjectIndex' -count=1` - exhaustive equivalence test over 701 objects and 1,100 block IDs - QA-shape benchmark (700 tombstone objects, 132 data blocks, 5 iterations): - linear scan: about 501 us/op - index build: about 72 us/op, 57,344 B/op, 1 alloc/op - indexed block queries: about 11.8 us/op, 0 B/op - build plus queries is about 6x faster than the linear scan This is intentionally separate from the cgroup pressure handling in matrixorigin#26471. It reduces the work generated by the workload but does not claim to solve all sources of CN memory pressure by itself. --------- Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
This branch had an error being deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What type of PR is this?
Which issue(s) this PR fixes:
Related to #26465
What this PR does / why we need it:
CN memory pressure handling currently samples process RSS only when the
resource throttler is used. This misses two parts of the actual OOM boundary:
can therefore leave pressure state stale for tens of seconds.
The QA workload from #26465 exposed both gaps. A 36 GiB CN reached about
35.1 GiB cgroup working set while process RSS was still about 32.1 GiB. The
hard-pressure state was entered only seconds before the container was
OOM-killed. One affected CN currently has 4.4 GiB of cgroup slab alone, mainly
associated with 11,107,273 disk-cache files, which RSS cannot observe.
This PR:
tightest limiting cgroup ancestor (cgroup v1 and v2);
max(process RSS, cgroup usage)for cache pressure, available-memorycalculation, and the CN S3 physical-memory backstop;
workloads cannot leave the pressure state stale;
transition logs;
automemlimitdependency.Validation:
go test ./pkg/common/system ./pkg/common/rscthrottler ./pkg/cnservice -count=1go test -race ./pkg/common/system ./pkg/common/rscthrottler ./pkg/cnservice -count=1go vet ./pkg/common/system ./pkg/common/rscthrottler ./pkg/cnservicepkg/common/systemfor Linux and ran it in an existingAlpine container with
--memory 256m; the detector returned the exact268,435,456-byte limit and a non-zero usage below that limit.
The full MatrixOne container A/B is not included yet because the local builder
image cannot currently be fetched from Docker Hub (
auth.docker.ioTLSfailure). The component tests and real Linux cgroup test above pass; this PR is
kept as draft until full CI and workload validation complete.