Skip to content

fix(ivfflat): integrate exact PRE storage Top-K and gate local DOP - #28515

Merged
XuPeng-SH merged 3 commits into
matrixorigin:mainfrom
aunjgr:fix/exact-pre-storage-local-dop
Sep 9, 2026
Merged

XuPeng-SH merged 3 commits into
matrixorigin:mainfrom
aunjgr:fix/exact-pre-storage-local-dop

Conversation

@aunjgr

@aunjgr aunjgr commented Sep 9, 2026

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:

Related to #27854. Replaces the remaining exact-PRE integration and local-DOP scope of #28002 on main after #28488; #28002 is left unchanged and open.

What this PR does / why we need it:

Require standalone scalar PRE domains on both runtime-filter producer and consumer using MustApply. Validate the terminal payload before opening entry readers, fail closed on unavailable or malformed required input, and keep required scans on the coordinator independently of placement hints.

Use a shared exact integer membership filter for storage Top-K, and the existing fused filter-before-Top-K path for residual or noninteger required predicates. Carry the small-domain all-centroids decision explicitly and constrain that scan with a version prefix. Preserve existing nprobe, candidate budgets, visibility, distance semantics, final rechecks, and exact fallback paths.

Add default-off vectorLocalDOP=1 scheduling for synchronous, uncorrelated, single-round integer PRE searches. Estimate physical work from hidden entries statistics, preserve it through plan copying, serialization and EXPLAIN, and cap parallelism by scan work, objects, CPU and max_dop. Recheck the current gate when compiling execution so cached plans cannot retain disabled parallelism.

Prepare one generation-owned domain, metadata version, centroid route and snapshot before publishing disjoint local readers. Give each reader independent scan state and cancellation, retain logical CN/cache identity, aggregate round diagnostics, and release shared resources after the last reader closes. Keep Hooks.NewReader and correlated APPLY interfaces unchanged.

Design and rollout

The approved design was recorded before implementation. This reuses main's must_apply=12, appends advisory scan_work=18, and integrates the storage paths already present after #28488.

Exact membership is not globally exact ANN search. Local DOP stays off unless optimizer_hints='vectorLocalDOP=1' is selected. Controlled Wiki-10M A/B/C evidence remains a prerequisite for proposing default-on; this PR makes no workload-speedup claim.

Validation

  • Normal owning-package tests: planner, EXPLAIN, compiler, IVF-FLAT plugins/readers and SQL scan adapter.
  • Owning-package race tests for IVF-FLAT, SQL scan adapter and compiler; 100 focused repetitions of concurrent shared-generation readers, including one shared historical snapshot clone.
  • Two-CN SQL regression using 125 rows, two explicitly flushed entries objects and injected cost statistics: identical results at DOP 1/2, required empty-domain handling and coordinator-local placement.
  • Extended 30-statement BVT and existing 68-statement end-to-end BVT each passed twice on the same instance; database teardown verified between runs.
  • Required-domain malformed/type/null/cardinality/PASS/cancellation rejection, memory-admission denial and partial-construction cleanup; exact integer, string, residual, full-centroid and descending-fallback storage paths.
  • make config static-check: package graph, repository lint, license checks and golangci-lint.

Require standalone scalar PRE domains on both runtime-filter producer and
consumer using MustApply. Validate the terminal payload before opening entry
readers, fail closed on unavailable or malformed required input, and keep
required scans on the coordinator independently of placement hints.

Use a shared exact integer membership filter for storage Top-K, and the existing
fused filter-before-Top-K path for residual or noninteger required predicates.
Carry the small-domain all-centroids decision explicitly and constrain that scan
with a version prefix. Preserve existing nprobe, candidate budgets, visibility,
distance semantics, final rechecks, and exact fallback paths.

Add default-off vectorLocalDOP=1 scheduling for synchronous, uncorrelated,
single-round integer PRE searches. Estimate physical work from hidden entries
statistics, preserve it through plan copying, serialization and EXPLAIN, and cap
parallelism by scan work, objects, CPU and max_dop. Recheck the current gate when
compiling execution so cached plans cannot retain disabled parallelism.

Prepare one generation-owned domain, metadata version, centroid route and
snapshot before publishing disjoint local readers. Give each reader independent
scan state and cancellation, retain logical CN/cache identity, aggregate round
diagnostics, and release shared resources after the last reader closes. Keep
Hooks.NewReader and correlated APPLY interfaces unchanged.
@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.

Deep review of exact head 12660a7 against cd04bb4. No confirmed blocking correctness, lifecycle, liveness, or compatibility finding.

Design: reviewed the separately committed, version-linked design at 23d4a97 and the #28002 decision history. The coordinator-local, shared-generation contract is sound; the new scheduling policy is explicitly opt-in and rechecked at execution compilation. Accepting this scoped design does not certify Wiki-10M performance recovery or authorize default-on/cross-CN rollout.

Coverage: all 30 changed files, including generated protobuf code and decoded descriptor delta. Required producer/consumer domains fail closed before entries open; empty domains preserve reader cardinality. Exact integer membership reaches storage before Top-K, while noninteger/residual predicates retain filter-before-Top-K and unsupported ordering retains the exact fallback. The explicit all-centroid route remains version constrained; final SQL rechecks and ANN candidate/nprobe semantics remain distinct from globally exact nearest-neighbor search.

Ownership/liveness: one generation seals domain, metadata version, centroid route and snapshot before publishing disjoint local readers. Reader contexts and scan state are independent; construction/reference cleanup and last-reader release balance shared filter ownership without cancelling siblings or the parent transaction. Storage filter shares are released on early errors and normal close. DOP remains bounded by work/object/CPU/query caps; missing statistics and unsupported execution modes stay conservative. Hooks.NewReader/APPLY and persistent index encoding are unchanged; the protobuf descriptor adds only advisory scan_work=18 and its four-field message.

Evidence reused: successful exact-head CI run 34325427836, including race UT, coverage, SCA and multi-CN BVT. Its UT log explicitly records TestIssue27854RequiredVectorDomainStaysCoordinatorLocal passing in 3.46 seconds; the test checks real persisted objects, DOP 1/2 results and empty-domain handling. Reviewed the targeted generation/admission/malformed-input, storage-path, hint/cost, prepared-execution and noninteger SQL oracles, together with the author's documented normal/race and same-instance BVT results. No new local native suite or representative performance benchmark is claimed.

@mergify mergify Bot added the queued label Sep 9, 2026
@mergify

mergify Bot commented Sep 9, 2026 •

Copy link
Copy Markdown
Contributor

Merge Queue Status

  • ✅ Entered queue — 2026-09-09 09:38 UTC · Rule: main · triggered by rule Automatic queue on approval for main
  • 🟠 Checks running · in-place
  • 🚫 Left the queue — 2026-09-09 09:39 UTC · at 29fc56903668a7843f9126c7b841d83e4705ee05

This pull request spent 58 seconds in the queue, with no time running CI.

Waiting for
  • any of: [🛡 GitHub branch protection]
    • check-neutral = Matrixone CI / UT Test on Ubuntu/x86
    • check-skipped = Matrixone CI / UT Test on Ubuntu/x86
    • check-success = Matrixone CI / UT Test on Ubuntu/x86
  • any of: [🛡 GitHub branch protection]
    • check-neutral = Matrixone CI / SCA Test on Linux/arm64
    • check-skipped = Matrixone CI / SCA Test on Linux/arm64
    • check-success = Matrixone CI / SCA Test on Linux/arm64
  • any of: [🛡 GitHub branch protection]
    • 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)
    • check-success = Matrixone Compose CI / multi cn e2e bvt test docker compose(PROXY)
  • any of: [🛡 GitHub branch protection]
    • check-neutral = Matrixone Utils CI / Coverage
    • check-skipped = Matrixone Utils CI / Coverage
    • check-success = Matrixone Utils CI / Coverage
  • any of: [🛡 GitHub branch protection]
    • check-neutral = Matrixone UT Coverage / UT Coverage on Ubuntu/x86
    • check-skipped = Matrixone UT Coverage / UT Coverage on Ubuntu/x86
    • check-success = Matrixone UT Coverage / UT Coverage on Ubuntu/x86
  • any of: [🛡 GitHub branch protection]
    • check-neutral = Matrixone Standlone CI / multi CN e2e BVT Test on Linux/x64(COMPOSE, PESSIMISTIC)
    • check-skipped = Matrixone Standlone CI / multi CN e2e BVT Test on Linux/x64(COMPOSE, PESSIMISTIC)
    • check-success = Matrixone Standlone CI / multi CN e2e BVT Test on Linux/x64(COMPOSE, PESSIMISTIC)
All conditions
  • any of [🛡 GitHub branch protection]:
    • check-neutral = Matrixone CI / UT Test on Ubuntu/x86
    • check-skipped = Matrixone CI / UT Test on Ubuntu/x86
    • check-success = Matrixone CI / UT Test on Ubuntu/x86
  • any of [🛡 GitHub branch protection]:
    • check-neutral = Matrixone CI / SCA Test on Linux/arm64
    • check-skipped = Matrixone CI / SCA Test on Linux/arm64
    • check-success = Matrixone CI / SCA Test on Linux/arm64
  • any of [🛡 GitHub branch protection]:
    • 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)
    • check-success = Matrixone Compose CI / multi cn e2e bvt test docker compose(PROXY)
  • any of [🛡 GitHub branch protection]:
    • check-neutral = Matrixone Utils CI / Coverage
    • check-skipped = Matrixone Utils CI / Coverage
    • check-success = Matrixone Utils CI / Coverage
  • any of [🛡 GitHub branch protection]:
    • check-neutral = Matrixone UT Coverage / UT Coverage on Ubuntu/x86
    • check-skipped = Matrixone UT Coverage / UT Coverage on Ubuntu/x86
    • check-success = Matrixone UT Coverage / UT Coverage on Ubuntu/x86
  • any of [🛡 GitHub branch protection]:
    • check-neutral = Matrixone Standlone CI / multi CN e2e BVT Test on Linux/x64(COMPOSE, PESSIMISTIC)
    • check-skipped = Matrixone Standlone CI / multi CN e2e BVT Test on Linux/x64(COMPOSE, PESSIMISTIC)
    • check-success = Matrixone Standlone CI / multi CN e2e BVT Test on Linux/x64(COMPOSE, PESSIMISTIC)
  • #review-threads-unresolved = 0 [🛡 GitHub branch protection]
  • github-review-approved [🛡 GitHub branch protection]

Reason

Pull request #28515 has been dequeued

Pull request from fork cannot be queued. This pull request comes from a fork, and Mergify needs the author's permission to update its branch.

The author needs to enable "Allow edits from maintainers" on this pull request.

Hint

You should look at the reason for the failure and decide if the pull request needs to be fixed or if you want to requeue it.
If you do update this pull request, it will automatically be requeued once the queue conditions match again.
If you think this was a flaky issue instead, you can requeue the pull request, without updating it, by posting a @mergifyio queue comment.

Tick the box to put this pull request back in the merge queue (same as @mergifyio queue).

  • Requeue this pull request

@XuPeng-SH
XuPeng-SH merged commit 6a961bd into matrixorigin:main Sep 9, 2026
20 of 21 checks passed
@mergify mergify Bot added dequeued and removed queued labels Sep 9, 2026
VioletQwQ-0 pushed a commit to VioletQwQ-0/matrixone that referenced this pull request Sep 17, 2026
…atrixorigin#28515)

## What type of PR is this?

- [ ] API-change
- [x] BUG
- [x] Improvement
- [ ] Documentation
- [ ] Feature
- [ ] Test and CI
- [ ] Code Refactoring

## Which issue(s) this PR fixes:

Related to matrixorigin#27854. Replaces the remaining exact-PRE integration and
local-DOP scope of matrixorigin#28002 on main after matrixorigin#28488; matrixorigin#28002 is left unchanged
and open.

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

Require standalone scalar PRE domains on both runtime-filter producer
and consumer using `MustApply`. Validate the terminal payload before
opening entry readers, fail closed on unavailable or malformed required
input, and keep required scans on the coordinator independently of
placement hints.

Use a shared exact integer membership filter for storage Top-K, and the
existing fused filter-before-Top-K path for residual or noninteger
required predicates. Carry the small-domain all-centroids decision
explicitly and constrain that scan with a version prefix. Preserve
existing nprobe, candidate budgets, visibility, distance semantics,
final rechecks, and exact fallback paths.

Add default-off `vectorLocalDOP=1` scheduling for synchronous,
uncorrelated, single-round integer PRE searches. Estimate physical work
from hidden entries statistics, preserve it through plan copying,
serialization and EXPLAIN, and cap parallelism by scan work, objects,
CPU and `max_dop`. Recheck the current gate when compiling execution so
cached plans cannot retain disabled parallelism.

Prepare one generation-owned domain, metadata version, centroid route
and snapshot before publishing disjoint local readers. Give each reader
independent scan state and cancellation, retain logical CN/cache
identity, aggregate round diagnostics, and release shared resources
after the last reader closes. Keep `Hooks.NewReader` and correlated
APPLY interfaces unchanged.

## Design and rollout

The [approved
design](https://github.com/aunjgr/matrixone/blob/23d4a971b4/docs/design/exact_pre_storage_local_dop.md)
was recorded before implementation. This reuses main's `must_apply=12`,
appends advisory `scan_work=18`, and integrates the storage paths
already present after matrixorigin#28488.

Exact membership is not globally exact ANN search. Local DOP stays off
unless `optimizer_hints='vectorLocalDOP=1'` is selected. Controlled
Wiki-10M A/B/C evidence remains a prerequisite for proposing default-on;
this PR makes no workload-speedup claim.

## Validation

- Normal owning-package tests: planner, EXPLAIN, compiler, IVF-FLAT
plugins/readers and SQL scan adapter.
- Owning-package race tests for IVF-FLAT, SQL scan adapter and compiler;
100 focused repetitions of concurrent shared-generation readers,
including one shared historical snapshot clone.
- Two-CN SQL regression using 125 rows, two explicitly flushed entries
objects and injected cost statistics: identical results at DOP 1/2,
required empty-domain handling and coordinator-local placement.
- Extended 30-statement BVT and existing 68-statement end-to-end BVT
each passed twice on the same instance; database teardown verified
between runs.
- Required-domain malformed/type/null/cardinality/PASS/cancellation
rejection, memory-admission denial and partial-construction cleanup;
exact integer, string, residual, full-centroid and descending-fallback
storage paths.
- `make config static-check`: package graph, repository lint, license
checks and golangci-lint.

---------

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
…atrixorigin#28515)

## What type of PR is this?

- [ ] API-change
- [x] BUG
- [x] Improvement
- [ ] Documentation
- [ ] Feature
- [ ] Test and CI
- [ ] Code Refactoring

## Which issue(s) this PR fixes:

Related to matrixorigin#27854. Replaces the remaining exact-PRE integration and
local-DOP scope of matrixorigin#28002 on main after matrixorigin#28488; matrixorigin#28002 is left unchanged
and open.

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

Require standalone scalar PRE domains on both runtime-filter producer
and consumer using `MustApply`. Validate the terminal payload before
opening entry readers, fail closed on unavailable or malformed required
input, and keep required scans on the coordinator independently of
placement hints.

Use a shared exact integer membership filter for storage Top-K, and the
existing fused filter-before-Top-K path for residual or noninteger
required predicates. Carry the small-domain all-centroids decision
explicitly and constrain that scan with a version prefix. Preserve
existing nprobe, candidate budgets, visibility, distance semantics,
final rechecks, and exact fallback paths.

Add default-off `vectorLocalDOP=1` scheduling for synchronous,
uncorrelated, single-round integer PRE searches. Estimate physical work
from hidden entries statistics, preserve it through plan copying,
serialization and EXPLAIN, and cap parallelism by scan work, objects,
CPU and `max_dop`. Recheck the current gate when compiling execution so
cached plans cannot retain disabled parallelism.

Prepare one generation-owned domain, metadata version, centroid route
and snapshot before publishing disjoint local readers. Give each reader
independent scan state and cancellation, retain logical CN/cache
identity, aggregate round diagnostics, and release shared resources
after the last reader closes. Keep `Hooks.NewReader` and correlated
APPLY interfaces unchanged.

## Design and rollout

The [approved
design](https://github.com/aunjgr/matrixone/blob/23d4a971b4/docs/design/exact_pre_storage_local_dop.md)
was recorded before implementation. This reuses main's `must_apply=12`,
appends advisory `scan_work=18`, and integrates the storage paths
already present after matrixorigin#28488.

Exact membership is not globally exact ANN search. Local DOP stays off
unless `optimizer_hints='vectorLocalDOP=1'` is selected. Controlled
Wiki-10M A/B/C evidence remains a prerequisite for proposing default-on;
this PR makes no workload-speedup claim.

## Validation

- Normal owning-package tests: planner, EXPLAIN, compiler, IVF-FLAT
plugins/readers and SQL scan adapter.
- Owning-package race tests for IVF-FLAT, SQL scan adapter and compiler;
100 focused repetitions of concurrent shared-generation readers,
including one shared historical snapshot clone.
- Two-CN SQL regression using 125 rows, two explicitly flushed entries
objects and injected cost statistics: identical results at DOP 1/2,
required empty-domain handling and coordinator-local placement.
- Extended 30-statement BVT and existing 68-statement end-to-end BVT
each passed twice on the same instance; database teardown verified
between runs.
- Required-domain malformed/type/null/cardinality/PASS/cancellation
rejection, memory-admission denial and partial-construction cleanup;
exact integer, string, residual, full-centroid and descending-fallback
storage paths.
- `make config static-check`: package graph, repository lint, license
checks and golangci-lint.

---------

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
…atrixorigin#28515)

## What type of PR is this?

- [ ] API-change
- [x] BUG
- [x] Improvement
- [ ] Documentation
- [ ] Feature
- [ ] Test and CI
- [ ] Code Refactoring

## Which issue(s) this PR fixes:

Related to matrixorigin#27854. Replaces the remaining exact-PRE integration and
local-DOP scope of matrixorigin#28002 on main after matrixorigin#28488; matrixorigin#28002 is left unchanged
and open.

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

Require standalone scalar PRE domains on both runtime-filter producer
and consumer using `MustApply`. Validate the terminal payload before
opening entry readers, fail closed on unavailable or malformed required
input, and keep required scans on the coordinator independently of
placement hints.

Use a shared exact integer membership filter for storage Top-K, and the
existing fused filter-before-Top-K path for residual or noninteger
required predicates. Carry the small-domain all-centroids decision
explicitly and constrain that scan with a version prefix. Preserve
existing nprobe, candidate budgets, visibility, distance semantics,
final rechecks, and exact fallback paths.

Add default-off `vectorLocalDOP=1` scheduling for synchronous,
uncorrelated, single-round integer PRE searches. Estimate physical work
from hidden entries statistics, preserve it through plan copying,
serialization and EXPLAIN, and cap parallelism by scan work, objects,
CPU and `max_dop`. Recheck the current gate when compiling execution so
cached plans cannot retain disabled parallelism.

Prepare one generation-owned domain, metadata version, centroid route
and snapshot before publishing disjoint local readers. Give each reader
independent scan state and cancellation, retain logical CN/cache
identity, aggregate round diagnostics, and release shared resources
after the last reader closes. Keep `Hooks.NewReader` and correlated
APPLY interfaces unchanged.

## Design and rollout

The [approved
design](https://github.com/aunjgr/matrixone/blob/23d4a971b4/docs/design/exact_pre_storage_local_dop.md)
was recorded before implementation. This reuses main's `must_apply=12`,
appends advisory `scan_work=18`, and integrates the storage paths
already present after matrixorigin#28488.

Exact membership is not globally exact ANN search. Local DOP stays off
unless `optimizer_hints='vectorLocalDOP=1'` is selected. Controlled
Wiki-10M A/B/C evidence remains a prerequisite for proposing default-on;
this PR makes no workload-speedup claim.

## Validation

- Normal owning-package tests: planner, EXPLAIN, compiler, IVF-FLAT
plugins/readers and SQL scan adapter.
- Owning-package race tests for IVF-FLAT, SQL scan adapter and compiler;
100 focused repetitions of concurrent shared-generation readers,
including one shared historical snapshot clone.
- Two-CN SQL regression using 125 rows, two explicitly flushed entries
objects and injected cost statistics: identical results at DOP 1/2,
required empty-domain handling and coordinator-local placement.
- Extended 30-statement BVT and existing 68-statement end-to-end BVT
each passed twice on the same instance; database teardown verified
between runs.
- Required-domain malformed/type/null/cardinality/PASS/cancellation
rejection, memory-admission denial and partial-construction cleanup;
exact integer, string, residual, full-centroid and descending-fallback
storage paths.
- `make config static-check`: package graph, repository lint, license
checks and golangci-lint.

---------

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>

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 kind/enhancement size/XL Denotes a PR that changes [1000, 1999] lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants