Repository navigation
Description
Summary and confidence
Confirmed, reachable performance inefficiency: the IVF exact-membership Top-K block reader pins validated cached filter columns, but binds them through MustVectorToCached, which clones the complete decoded column representation on every block visit. The filter callback only borrows these vectors synchronously, and ObjectIO already has a scoped binding API for this ownership contract.
This is not a claim that a new October 2 PR introduced all of the nightly IVF slowdown. The affected code is identical in the two measured SHAs. Physical index layout and background Merge progress differ substantially. The copy path is an independently identified CPU/allocation contributor, not a proven explanation for every PRE/POST result.
Product versions and original evidence
- Previous Main Weekly: Run 36881937434, MO
32f54981401fd3888702f2dab8702d2e62c6997a, namespacemo-main-family-36881937434-1. - Current Main Weekly: IVF Job 111009680329 / Run 37032919785, MO
9078a8bd87af49ea06f52e09d64e7740122aea61, namespacemo-main-family-37032919785-1. - Current immutable image:
ccr.ccs.tencentyun.com/matrixone-dev/matrixone@sha256:1ae602f7db3ac123870e1ed4f76e4010068d298a73dd27735e36dc369ab3ec9e. - Same workload tool manifest/digest (
ff310427ad6b), dataset, query/GT/mapping identities, topology and resource profile in both runs. - 1 TP + 2 AP; each CN 14 CPU / 55Gi memory / 16Gi FileService memory cache; TN 14 CPU / 32Gi memory / 5Gi cache. CN GOMEMLIMIT=25000MiB, GOGC=200.
- Wiki: 10M float32 vectors, 768 dimensions; K=10, probe_limit=5, ivf_preload_entries=0; 100 workers; 10,000 queries per round, two rounds for each of six modes.
- All 120,000 current queries completed, zero query/connection errors; sampled result audit passed. No CN/TN OOM or restart was observed. This is a performance report, not a wrong-result report or a certification of the complete GT.
Observed throughput
Second-round QPS, consistent with the existing checker convention:
| Mode | Previous | Current | Change | Previous / current recall |
|---|---|---|---|---|
| only/pre | 881.88 | 358.33 | -59.37% | 0.7575 / 0.7550 |
| only/post | 886.33 | 406.68 | -54.12% | 0.7575 / 0.7550 |
| filter/pre | 131.87 | 77.43 | -41.28% | 0.6132 / 0.6119 |
| filter/post | 491.15 | 337.50 | -31.28% | 0.2840 / 0.2901 |
| threshold/pre | 127.37 | 84.22 | -33.88% | 0.6215 / 0.6168 |
| threshold/post | 571.56 | 332.01 | -41.91% | 0.2900 / 0.2952 |
The full six-mode timed query window increased from approximately 8m54s to 13m17s. The specific copy path below applies to exact-membership PRE; this table must not be interpreted as assigning POST/only losses to the same call site.
Runtime proof of the copy path
Matched two-minute CPU profiles of the AP CNs, both wholly within filter/pre:
- Previous: 2026-10-01 20:03:00–20:05:00 UTC.
- Current: 2026-10-02 20:14:00–20:16:00 UTC.
- Pyroscope selectors:
{service_name="<namespace>/main",pod=~".*-ap-cn-.*"}; CPU profileprocess_cpu:cpu:nanoseconds:cpu:nanoseconds.
| Inclusive sampled CPU share | Previous | Current |
|---|---|---|
ReadBlockBySearchAndTopN |
12.79% | 34.24% |
CbitmapFilter.TestVector |
5.39% | 16.21% |
validatedVectorSnapshot |
1.43% | 8.13% |
compress.Decompress |
1.61% | 0.12% |
Inclusive entries overlap and must not be added. These percentages identify measured work, not promised speedup or aggregate wall-clock shares. The current snapshot-copy node's ancestry is:
IvfflatSearchIndex.scanEntriesInDomain
relationScanner.ScanRelation
reader.Read / reader.read
BlockDataRead
blockDataReadWithExactMembershipTopK
ReadBlockBySearchAndTopN
MustVectorToCached
vectorCacheDataBytes
validatedVectorSnapshot
bytes.Clone
The CGo membership hotspot is below ReadBlockBySearchAndTopN -> selectRows -> ConstructBlockPKFilter -> CbitmapFilter.TestVector -> mo_cbitmap_test_fixed, rather than the filter's initial construction. This makes reducing unnecessary per-block work relevant even when caches hit.
Code-level cause
At the actually tested SHA:
ReadBlockBySearchAndTopNrequestsShareScopedDecodedColumn, retainsfilterReaduntil the callback and scoring complete, and documents the callback as synchronous borrowing.- The filter-column loop calls
MustVectorToCachedrather than scoped binding. MustVectorToCached/vectorCacheDataBytesobtain a snapshot for marked cache data.validatedVectorSnapshotunconditionally usesbytes.Clone(d.data.Bytes()).bindCachedVectorForScopealready binds the validated backing inside an ObjectIO scope without exposing it to the caller. Existing row-copy and Top-N operations use this facility.
git blame attributes this filter binding call site to 315502ef79f, #28623. That establishes the origin of the call site, not a first-bad performance commit. The same call site remains in current main at the time of investigation. The general snapshot/immutability protection is intentional and should not be removed globally.
Why this nightly comparison is not a clean introducing-PR A/B
- No production diff in
pkg/vectorindex/ivfflat,pkg/objectio,pkg/fileserviceor TN merge scheduler between the measured SHAs. The ObjectIO diff is a marshal unit test; ReadUtil changes concern numeric-domain filtering, not the filtered IVF plan shape shown by the diagnostics. - Both recorded filter diagnostics use Vector Index Scan DOP=2, the same filter value, K/probe settings and query-vector identity; there is no evidence of a switch back to the earlier one-CN fallback.
- Current entries table
273252was still atpointDepth 198/195/192during PRE; the previous entries table273275was already nearpointDepth 15. These are overlapping object ranges, not counts of incorrect logical rows. - Current TN logs at 20:13:57 UTC show limit=24Gi, RSS≈20.15Gi, pinned≈4.39Gi, available=0B. Subsequent merges only admit small batches. This can prolong a high block-visit state. The previous run also had occasional budget shortages; it is incorrect to claim it never did.
- Current prepare finished at 19:48:35 UTC and queries started around 20:09:34 (~21 minutes later); previous prepare finished around 19:04 and queries started around 20:00 (~56 minutes later).
- Current no-PK bulk prepare starts at 20:13:38 and overlaps filtered PRE; previous filtered PRE overlapped point-select instead. However current only/pre and only/post were already slower before no-PK bulk prepare started. That overlap cannot explain all six losses.
- Neither run's IVF query window overlaps ANLI or Full Concurrent; those jobs start later. Kubernetes nodes also differ between runs.
Physical-layout/background-Merge amplification is therefore a strong contributing explanation, but no controlled same-object A/B has yet quantified its contribution versus query-side copy cost.
Expected behavior and bounded next validation
Read-only membership evaluation should avoid cloning an already validated, pinned filter column when its lifetime can safely remain inside the existing read scope. Preserve all existing correctness contracts: no writable cache alias escapes, the callback cannot mutate shared cache data, fallback wrappers remain checked, releases occur exactly once, and cancellation/error paths remain safe.
Suggested validation, not yet performed as a production fix:
- Use the existing exact-membership reader fixtures to measure allocation/copy bytes with validated cached filter columns; include no-match, sparse-match, dense-match and callback-error cases.
- Verify cache backing cannot be modified or retained through the callback; do not blindly replace every snapshot API with raw
Bytes(). - Compare the existing binding and a safe scoped binding on the same physical Wiki entries objects, image/config except for this local change, and exact query sequence.
- Preserve result/recall audits and measure PRE CPU/allocation, block visits and QPS; do not infer gains in POST from PRE.
- Separately compare converged and unconverged layouts without disabling memory admission or bypassing the exact-membership correctness rule.
Duplicate boundary
- [Bug]: IVF Wiki 10M has sustained object-column read/decompression amplification under bounded cache #28627 tracks the older ObjectIO/FileService read/decompression cliff and includes TN Merge-pressure discussion. Here current filtered-PRE LZ4 CPU is only 0.12%; the newly isolated cause is in-memory sealed snapshot copying at the exact-membership call site.
- [Bug]: FileService: concurrent disk-cache hits duplicate reads/decodes and can evict warm entries before key deduplication #28898 concerns repeated concurrent DiskCache decode, not this copy on an already validated column.
- [Bug]: Main IVF filtered PRE is 4-7x slower than 4.2 at comparable recall (Wiki 10M) #29531 concerns the older filtered-PRE distributed-execution gap; both current diagnostics use DOP=2.
- [Bug]: 10M IVFFlat workload intermittently closes RPC/backend connections #27757 concerns connection closure; current Wiki has zero connection errors.
Searched open/closed issues for validatedVectorSnapshot, ReadBlockBySearchAndTopN, cache clone/snapshot, cbitmap and IVF performance; no specific existing report for this scoped filter-copy path was found. This issue deliberately isolates that contributor rather than duplicating the entire historical IVF slowdown report.
Activity
Avoid cloning pinned IVF exact-membership filter columns (#29583)