Skip to content

perf(vector): reduce IVF prefilter scan memory copies - #26989

Merged
mergify[bot] merged 10 commits into
matrixorigin:mainfrom
jiangxinmeng1:agent/fix-ivf-prefilter-oom
Aug 12, 2026
Merged

mergify[bot] merged 10 commits into
matrixorigin:mainfrom
jiangxinmeng1:agent/fix-ivf-prefilter-oom

Conversation

@jiangxinmeng1

Copy link
Copy Markdown
Contributor

What type of PR is this?

  • API-change
  • BUG
  • Improvement
  • Documentation
  • Feature
  • Test and CI
  • Code Refactoring

Which issue(s) this PR fixes:

issue #26720

What this PR does / why we need it:

Summary

  • avoid copying the complete parent varlen area when materializing a borrowed Vector window
  • compute persisted IVF TopN directly from pinned cache-backed vectors instead of duplicating full
    embedding blocks
  • materialize only selected non-embedding rows after TopN evaluation
  • add LoopJoin byte-admission diagnostics for remote performance analysis
  • preserve cache ownership, null handling, metadata propagation, and appendable-block MVCC behavior

Performance impact

Pyroscope showed the IVF recall workload was CPU-bound in:

  • runtime.memmove
  • runtime.memclrNoHeapPointers
  • MustVectorToCachedWithMpool -> Vector.Dup
  • LoopJoin -> UnionBatch

The changes remove two major copy-amplification paths:

  1. borrowed varlen windows now copy only their live payload span
  2. persisted vector TopN no longer duplicates the complete embedding block before calculating
    distances

Validation

  • focused varlen UnionBatch fast-path tests
  • cache-backed TopN ownership and result tests
  • focused ObjectIO and BlockIO tests
  • rebased onto the latest upstream/main

https://github.com/matrixorigin/mo-nightly-regression/actions/runs/31476056288/job/93738970576

@qodo-code-review

Copy link
Copy Markdown

Qodo reviews are paused for this user.

Troubleshooting steps vary by plan Learn more →

On a Teams plan?
Reviews resume once this user has a paid seat and their Git account is linked in Qodo.
Link Git account →

Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center?
These require an Enterprise plan - Contact us
Contact us →

@XuPeng-SH XuPeng-SH left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-reviewed exact head 7562bb0. The prior blockers are closed: aliased varlen UnionBatch sources are cloned before mpool growth, with forced-growth self/window regressions; persisted TopN now keeps the cache lease pinned, materializes only selected non-embedding rows, preserves tombstone/prefilter/rowid-distance alignment, and retains the appendable MVCC fallback; temporary LoopJoin diagnostics were removed. I also checked empty/all-null results, cache hit/miss ownership, error cleanup, and area metadata invariants. Focused CGo tests for vector, objectio, objectio/ioutil, and blockio pass. No remaining blocker.

@aunjgr aunjgr left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed exact head 7562bb0 against merge base c04df06.

The prior alias-lifetime blocker is resolved: UnionBatch now clones an overlapping varlen source before destination growth, preserving both header and area backing, and the forced-growth regressions cover self-append, borrowed Window aliases, nulls, and grouping metadata. I also checked the persisted BlockIO TopN path: cache-backed vectors remain scoped to the pinned IOVector, selected rows and distances are the only escaping data, and cache hit/miss, prefilter, tombstone, all-deleted, empty-bound, row-alignment, and appendable-fallback cases are covered. No remaining blocker found.

@mergify mergify Bot added the queued label Aug 12, 2026
@mergify

mergify Bot commented Aug 12, 2026 •

Copy link
Copy Markdown
Contributor

Merge Queue Status

  • ✅ Entered queue — 2026-08-12 08:20 UTC · Rule: main · triggered by rule Automatic queue on approval for main
  • ✅ Checks passed · in-place
  • ✅ Merged — 2026-08-12 09:23 UTC · at f0392156dce9c24ebb592d0a6645793eef5792ba · squash

This pull request spent 1 hour 2 minutes 44 seconds in the queue, including 44 minutes 53 seconds running CI.

Required conditions to merge
  • #review-threads-unresolved = 0 [🛡 GitHub branch protection]
  • github-review-approved [🛡 GitHub branch protection]
  • any of [🛡 GitHub branch protection]:
    • check-success = Matrixone Standlone CI / e2e BVT Test on Linux/x64(LAUNCH, PESSIMISTIC)
    • check-neutral = Matrixone Standlone CI / e2e BVT Test on Linux/x64(LAUNCH, PESSIMISTIC)
    • check-skipped = Matrixone Standlone CI / e2e BVT Test on Linux/x64(LAUNCH, PESSIMISTIC)
  • any of [🛡 GitHub branch protection]:
    • check-success = Matrixone CI / UT Test on Ubuntu/x86
    • check-neutral = Matrixone CI / UT Test on Ubuntu/x86
    • check-skipped = Matrixone CI / UT Test on Ubuntu/x86
  • any of [🛡 GitHub branch protection]:
    • check-success = Matrixone CI / SCA Test on Linux/arm64
    • check-neutral = Matrixone CI / SCA Test on Linux/arm64
    • check-skipped = Matrixone CI / SCA Test on Linux/arm64
  • any of [🛡 GitHub branch protection]:
    • check-success = Matrixone Compose CI / multi cn e2e bvt test docker compose(PROXY)
    • check-neutral = Matrixone Compose CI / multi cn e2e bvt test docker compose(PROXY)
    • check-skipped = Matrixone Compose CI / multi cn e2e bvt test docker compose(PROXY)
  • any of [🛡 GitHub branch protection]:
    • check-success = Matrixone Utils CI / Coverage
    • check-neutral = Matrixone Utils CI / Coverage
    • check-skipped = Matrixone Utils CI / Coverage
  • any of [🛡 GitHub branch protection]:
    • check-success = Matrixone UT Coverage / UT Coverage on Ubuntu/x86
    • check-neutral = Matrixone UT Coverage / UT Coverage on Ubuntu/x86
    • check-skipped = Matrixone UT Coverage / UT Coverage on Ubuntu/x86

@mergify
mergify Bot merged commit dcfaae0 into matrixorigin:main Aug 12, 2026
25 of 26 checks passed
@mergify mergify Bot removed the queued label Aug 12, 2026
XuPeng-SH added a commit that referenced this pull request Aug 28, 2026
## 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 #26720

## What this PR does / why we need it:

Backport the fixes missing from `4.2-dev` for
[#26720](#26720) and
  [#25114](#25114).

  Included PRs:

  - #26711: Fix pipeline remote batch backpressure
  - #26739: Retry COS multipart initialization on EOF
  - #26759: Fix IVF prefilter OOM
  - #26989: Reduce IVF prefilter scan memory copies
  - #27156: Keep connections alive after long-running requests

The changes address vector-index memory usage, file-service retry
behavior, remote pipeline backpressure, and
  frontend connection lifecycle on `4.2-dev`.

---------

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Co-authored-by: XuPeng-SH <[email protected]>
VioletQwQ-0 pushed a commit to VioletQwQ-0/matrixone that referenced this pull request Sep 17, 2026
VioletQwQ-0 pushed a commit to VioletQwQ-0/matrixone that referenced this pull request Sep 17, 2026
VioletQwQ-0 pushed a commit to VioletQwQ-0/matrixone that referenced this pull request Sep 17, 2026

This branch was previously deployed

1 inactive deployment
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kind/bug Something isn't working size/XL Denotes a PR that changes [1000, 1999] lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants