Skip to content

Avoid cloning pinned IVF exact-membership filter columns - #29583

Merged
XuPeng-SH merged 8 commits into
matrixorigin:mainfrom
LeftHandCold:fix/29578-ivf-filter-cache-copy
Oct 3, 2026
Merged

XuPeng-SH merged 8 commits into
matrixorigin:mainfrom
LeftHandCold:fix/29578-ivf-filter-cache-copy

Conversation

@LeftHandCold

Copy link
Copy Markdown
Collaborator

What type of PR is this?

  • BUG
  • Improvement

Which issue(s) this PR fixes:

Fixes #29578

What this PR does / why we need it:

The exact-membership Top-K path already pins its filter-column IOVector, but then calls MustVectorToCached, whose validated snapshot clones the entire column. Profiles in #29578 identify this avoidable copy in IVF PRE filtering. This change removes that copy for a closed, read-only operation without weakening the existing arbitrary-callback boundary.

Change and safety boundary

  • Add an ObjectIO-owned membership descriptor admitting only the existing Cbitmap, Sorted64 and CRoaring concrete read-only implementations, optionally intersected with the existing PK search descriptor.
  • Bind filter columns to their pinned cache backing only inside ObjectIO. The external tombstone callback receives owned row offsets, never a cache vector alias.
  • Keep the old snapshot path for unsupported filters and arbitrary callbacks. Membership lifetime remains owned by the reader; borrowed vectors are freed before the IOVector is released.
  • Preserve NULL handling, sorted/unsorted searches, tombstone application, Top-K materialization, row-ID semantics, and existing malformed-secondary-filter fallback. No new worker, retry, global cache, format or configuration.

Validation

Using native artifacts rebuilt from this worktree:

  • Full pkg/objectio, pkg/vm/engine/readutil, and pkg/vm/engine/tae/blockio tests: PASS, normal and race.
  • Shared-cache concurrency test repeated 100 times under race: PASS.
  • Persisted-object consumer tests cover all three membership implementations, sorted/unsorted input, dense/sparse/empty/NULL cases, PK intersection, missing base-PK predicate, tombstone failure, cancellation, and exactly-once release.
  • Counterexample: an arbitrary legacy callback mutates its snapshot, but cannot corrupt the sealed cache or subsequent output.
  • go vet, incremental golangci-lint, gofmt and diff whitespace checks: PASS.

An 8192-row compound-key binding + membership microbenchmark (three repetitions):

Path ns/op B/op allocs/op
Snapshot 78,014–79,936 411,520 4
Scoped 48,498–48,966 10,112 3

This reduces allocation bytes by about 97.5% and this microbenchmark's time by about 39%. It is not a claim of equivalent end-to-end IVF QPS recovery: object layout, merge state, membership probing and vector reads also contribute to the incident. A full nightly/TKE run was not executed for this PR.

@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 →

@LeftHandCold

Copy link
Copy Markdown
Collaborator Author

CI failure root cause and minimal correction:

  • Build, UT and SCA on 4d3cf82ee929522166f8c38012cb092437fb9863 failed at the whole-repository test graph check: docfilter (memory_test.go) -> rscthrottler -> objectio -> docfilter.
  • Both BVT modes failed while building their image for the same reason. Coverage aggregation then lacked a required producer; these are not several independent SQL regressions.
  • The new ObjectIO dependency exposed an existing internal-test integration edge. My earlier focused package validation missed that full test graph. The fix moves only the throttler integration test into docfilter_test, with a test-only bridge. It preserves all 100-worker / 80% admission-budget / full-release assertions and joins workers before fatal assertions. No production cache-safety or ownership contract is relaxed.

Validation: the full test package graph reproduces the cycle before the fix and passes afterwards (1,333 nodes). The five affected packages pass normal tests; docfilter and rscthrottler pass complete race tests; the production-policy race test passes 100 repetitions. An independent source review found no additional correctness or lifecycle blocker in the original scoped-cache implementation.

The complete make static-check-analysis (repository graph, prohibited API check, pinned molint, full golangci-lint; no reduced package/diff scope) passed with exit 0 and zero lint issues at ee097f4bcf, on Go 1.26.4 Linux amd64. The CI arm64 run remains a separate check.

I also synchronized current main b210a0a5fc878e1e7d04c371297687de003ba292 and retained #29581's one-line prepared-authorization test fix. This avoids inheriting main's separate undefined-helper compile error when this PR enters the merge queue. Original production optimization files remain unchanged.

Final-head validation at 71acd9ac0071b514a4fdce96857fad5e77e5e5b6: complete test graph PASS (1,331 nodes after main's package removal), all five owning packages PASS, docfilter/rscthrottler complete race tests PASS, and complete frontend test-package compilation plus all three prepared-authorization tests PASS. New CI: https://github.com/matrixorigin/matrixone/actions/runs/37111946095 (started/queued; not yet reported as green).

@matrix-meow matrix-meow added size/XL Denotes a PR that changes [1000, 1999] lines and removed size/L Denotes a PR that changes [500,999] lines labels Oct 3, 2026
@LeftHandCold
LeftHandCold requested a review from XuPeng-SH October 3, 2026 11:56
@LeftHandCold

Copy link
Copy Markdown
Collaborator Author

@XuPeng-SH 已复核最新修正 26004750d9f1870ea84882c77898af33b32ca5a7 与本次 changes:fixed-width filter 列保留真实旧 callback / reusableSels,scoped membership-only 不再无条件分配全量 offsets;原 persisted fixture 已补 PK 与 membership 分别命中但交集不同/为空、真正 membership-only no-hit/single-hit/NULL。新 consumer benchmark 经过 ConstructBlockPKFilter -> BlockDataRead,对照真实 legacy callback,覆盖了本次遗漏的 eligibility 边界。未发现需要追加修改的同类问题。具体测试与基准记录见已回复的 discussion_r4172860764,讨论已 resolved,复审请求保持在你名下,请继续 review 最新 head。新 CI 37121182308 仍在运行,未将旧 head 的绿灯当作本次完整 CI 已通过。

@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.

审查 commit:26004750d9f1870ea84882c77898af33b32ca5a7(base:b210a0a5fc878e1e7d04c371297687de003ba292)。结论:APPROVE。完整检查全部 13 个文件的增量、现有职责归属与调用链,未使用 subagent,未发现未闭合的 blocker。

上一轮 P2 性能退化已确认修复:BlockIO 按实际 filter 列类型选择 scoped 路径,全 fixed-width 保留真实旧 callback 和 reader-owned reusableSels;membership-only 的 scoped search 只为实际命中分配 offsets,无命中不分配,没有新增可变 buffer/cache owner。本机真实 ConstructBlockPKFilter -> BlockDataRead 基准(Darwin arm64 / Apple M4、8,192 行持久化缓存块、GOMAXPROCS=2、200ms × 3)确认 fixed-width 的 no-hit / single-hit / dense 两路径分别同为 9,056 / 10,128 / 10,776 B/op,allocs 也完全一致,原先额外 65,536 B/block 已消除。compound-varchar 三组每次均减少 499,712 B,耗时中位数分别降低 30.1% / 28.2% / 12.8%。这些是缓存块级 consumer 结果,不外推为端到端 IVF QPS。

设计与 unhappy path:闭合的只读 membership descriptor 复用现有 ObjectIO scoped binding 和 IOVector pin;借用 Vector 在 pin 释放前收尾,membership filter 仍由 reader Close/reset 管理。Top-K、输出物化、tombstone、rowid 与统计共用既有执行职责。未知 filter、任意 callback 的 varlen snapshot 边界及不适用优化的旧路径有实际消费者,应保留;未引入重复状态机、校验、长期存储或后台执行机制。检查了具体 Go/C filter 的只读行为、部分读取失败清理、取消、finalize 错误和并发缓存读取。Q1 所有权、Q2 等待、Q3 增长约束均闭合。

上一轮测试正交性意见已落实:现有四行 persisted fixture 的 PK={0,1}、membership={1,3}、交集={1},并包含双方分别命中但交集为空的控制,以及真正 membership-only 的 no-hit / single-hit / NULL;覆盖三种 concrete filter。未知实现、typed-nil、secondary length mismatch fail-open、callback snapshot 隔离、pin release 和 tombstone/stats 控制仍保留。真实 consumer benchmark 对照实际旧 callback,并明确 cache-hit、重置 Top-K heap、复用输出,修正了原 benchmark 仅比较 binding 而遗漏缓冲复用代价的问题。

增量分别审视:实现 +230/-46(净增 184),测试 +850/-50(净增 800),文档 0。测试增量较大,其中 239 行提供此前缺失的真实 consumer 性能对照;结果与生命周期验证复用小型 persisted fixture。docfilter integration test 外移用于消除真实 test import cycle,保留原 admission/release 断言并在 fatal assertion 前释放、等待全部 worker;prepared-authorization fixture 使用当前职责所属 helper。未发现无消费者字段、替代后遗留执行逻辑或需要阻止批准的低价值抽象。

验证:当前 head 本地三个 owning/consumer 包的七个具名 focused tests 全部通过,真实 consumer benchmark 全部通过;复核所有实质性 review comments 已闭合。当前 exact-head CI 37121182308 已完成并通过,包含 build、SCA、Ubuntu UT、coverage、适用的 proxy / multi-CN pessimistic BVT 和 CI Required;已核对 run headSha 与 UT checkout。跳过的模式不计为通过证据。未运行新的 nightly/TKE 或完整 IVF QPS workload。

CI:https://github.com/matrixorigin/matrixone/actions/runs/37121182308

@mergify mergify Bot added the queued label Oct 3, 2026
@mergify

mergify Bot commented Oct 3, 2026 •

Copy link
Copy Markdown
Contributor

Merge Queue Status

  • ✅ Entered queue — 2026-10-03 13:20 UTC · Rule: main · triggered by rule Automatic queue on approval for main
  • 🟠 Checks running · in-place
  • 🚫 Left the queue — 2026-10-03 13:56 UTC · at 9b4e6be76c32ced662d3fc78cdc3c111d7290866

This pull request spent 35 minutes 21 seconds in the queue, with no time running CI.

Reason

Pull request #29583 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.

Waiting for any of
  • check-neutral = CI Required
  • check-skipped = CI Required
  • check-success = CI Required
All conditions

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

  • Requeue this pull request

This branch was previously deployed

1 inactive deployment
ci — 9b4e6be7 Deployed Oct 3, 2026 by XuPeng-SH
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.

[Bug]: IVF exact-membership reads repeatedly clone pinned cached filter columns

3 participants