Skip to content

perf(fulltext2): avoid boxing loaded primary keys for runtime-filter probes #27247

Closed

Description

@VioletQwQ-0

Problem

FULLTEXT2 non-INCLUDE WHERE filtering probes a primary-key runtime membership filter for every candidate document. On a loaded segment, the current path decodes the mmap-backed docmap key into a boxed Go value and then encodes it again for docfilter.

This adds avoidable allocation and CPU cost on a hot candidate-filtering path, especially for variable-length primary keys.

Proposed scope

  • Probe immutable loaded-segment docmap PK content bytes directly when their representation matches the runtime-filter source vector.
  • Keep build-side segments on the existing typed fallback.
  • Keep UUID on the typed fallback because the docmap stores its canonical string while docfilter hashes the raw 16-byte representation.
  • Preserve SQL results, score bits, runtime-filter behavior, index format, DDL, CDC, and public interfaces.

Correctness requirements

  • Prove byte-representation compatibility for all supported integer, temporal, decimal, BIT, and varlena PK types.
  • Preserve bounds checks and the UUID/build-side fallback.
  • Keep PK membership and float32 score bits identical to the existing path.

Directional evidence

On the shared mo-55 host, the existing 2,303,643-row paired run completed 36/36 cells with zero errors and zero timeouts:

Workload Candidate / baseline QPS
non-INCLUDE 0.1%, C10 1.310x
non-INCLUDE 1%, C10 1.288x
non-INCLUDE 10%, C10 1.115x
no-WHERE control, C10 0.997x

Microbenchmarks reduced loaded BIGINT probe allocations from 6 B/op to 0 and loaded VARCHAR from 40 B/op / 2 allocs/op to 0.

The host was shared, so these ratios are directional paired evidence; absolute QPS and P99 are not publication-grade.

Activity

  1. self-assigned this
    on Aug 18, 2026
  2. added
    severity/s0
    on Aug 18, 2026
  3. VioletQwQ-0 commented on Aug 30, 2026

    @VioletQwQ-0
    CollaboratorAuthor

    QA handoff after PR #27248 merge

    Issue #27247 remains open and is transferred to testing.

    • PR perf(fulltext2): probe loaded primary keys without boxing #27248 merged from head dda7ec2045501a6bb6c4d5984ccd7e81da1f8c82 at 2026-08-29T19:43:16Z with merge commit a3f1328612563cce6bc6cddaeddc8a3813bc6bb1.
    • The current matrixorigin/matrixone:main head at handoff is 3155f22bdabcecd48802f244d9fb0717b99f9b6d.
    • Required PR CI on the merged head was green, including Ubuntu/x86 UT, Linux/arm64 SCA, coverage, Compose, Standalone, and shared build checks (run 33271574738). The non-required TKE check-in BVT job 99154116448 timed out after 75 minutes and is not treated as a PASS.
    • Automated terminal coverage includes the production Builder -> Finish -> Serialize -> Deserialize loaded-segment path, borrowed PK-content membership probes for supported non-UUID representations, UUID/build-side typed fallbacks, malformed metadata, invalid ordinals, missing offsets, truncation, invalid lengths, and empty varlena content.
    • Remaining QA scenarios: run the non-INCLUDE FULLTEXT2 WHERE membership path on the current main build with loaded segments, verify SQL rows and score bits remain unchanged, confirm no regression in UUID/build-side fallback and malformed-input fail-closed behavior, and measure the loaded-path allocation/performance effect in the deployed environment.
    • Expected result: loaded probes preserve membership semantics while avoiding the boxed decode/re-encode path; all fallback and boundary cases remain correct.
    • Tester selection: the issue author is VioletQwQ-0, not heni02; therefore the required tester is Ariznawlll.
  4. Ariznawlll commented on Sep 18, 2026

    @Ariznawlll
    Collaborator

    在 latest main d9609d742b9000b54279f44e34295630b7238282 完成复测后,此 issue 暂不关闭并转回研发处理测试断言。

    已完成的验证:

    • go test ./pkg/fulltext2 -count=1 通过。
    • 以 -race -count=10 运行当前确定性的 loaded-PK/UUID 覆盖:TestLoadedContainsPkTypes、TestLoadedContainsPkNoAlloc、TestLoadedContainsPkBoxingCounterexample、TestPkContentRejectsInvalidAccess、TestLoadedUUIDMembershipRepresentations、TestLoadedUUIDMembershipMixed、TestLoadedUUIDMembershipRejectsMalformedRows、TestLoadedUUIDMembershipRejectsInvalidAccess、TestLoadedUUIDMembershipLivenessScoreAndStream、TestLoadedUUIDMembershipParallelOwners,均通过。
    • BenchmarkLoadedUUIDMembership 连续 5 次结果中,pointer-backed UUID hit/miss/mixed 均为 0 B/op, 0 allocs/op;inline-copy 对照组仍为 16 B/op, 1 alloc/op,符合本修复要消除 boxing 的目标。

    阻塞项在遗留测试本身,而非已确认的功能回归:将 TestContainsPkTypes/uuid 一并纳入全包 -race 时,会在 ordinal=1 的非成员 UUID 上断言 false,但实际得到 true。UUID 的非整数 PK 路径使用近似 Bloom filter,允许 false positive;pkg/common/docfilter/filter.go 也将该路径标记为 non-exact。当前较新的 pkg/fulltext2/uuid_membership_test.go 已正确区分这一点:表示层测试允许 Bloom 命中,确定性 miss 则使用 exact uuidSetMembershipFilter。

    请将旧的 TestContainsPkTypes/uuid 改为不把任意 Bloom 非成员当作确定 miss,或改用 exact filter/原始字节断言来验证。修改后请重新跑完整 go test -race ./pkg/fulltext2。MOTR #186 中的 SQL 可见性回归可作为补充,但不能替代这个 package race gate。

  5. Ariznawlll commented on Nov 2, 2026

    @Ariznawlll
    Collaborator

    结论

    测试通过。本次补充验证了 FULLTEXT2 非 INCLUDE 条件下主键过滤的结果一致性,并复核了此前阻塞整包 race 的测试断言;相关回归已纳入 MOTR。

    关键证据

    • 功能实现已由 #27248 合入;本次 SQL 和性能微基准运行于 main@ea184ad90624ae3dba8ced628ac019271a6c309c 的单机 1 CN / 1 TN 环境。更新的 main 为 87fe4e0c3ac3f9a98b308f8931fd3f8be345b076,两者之间未变更 FULLTEXT2、docfilter 及相关 CGo 源码。
    • 对 BIGINT、VARCHAR、UUID 主键分别构造 2,000 行并同步索引,关闭与开启运行时过滤器下推后各重复 3 次;每次返回的 500 个 ID 与预期一致,两种模式返回的 ID 及重建的 float32 分数位一致。EXPLAIN 确认开启时全文索引扫描使用 runtime filter。
    • 现有 MOTR 回归 #195 已合入;相关脚本在上述环境独立运行 3 次,3 次通过,覆盖 UUID 回退及过滤开关。完整 go test -race -count=1 ./pkg/fulltext2 在上述版本及更新的 87fe4e0c3ac3f9a98b308f8931fd3f8be345b076 均通过;最新版本耗时 138.579 秒,包含旧 TestContainsPkTypes 和 loaded segment、异常输入、UUID 回退等覆盖。最新版本首次尝试因本机动态库搜索路径缺失未进入测试,补齐路径后通过。
    • loaded UUID 微基准重复 3 次:pointer-backed 的 hit、miss、mixed 均为 0 B/op、0 allocs/op;inline-copy 对照为 16 B/op、1 alloc/op。这是本地微基准,不能替代生产环境性能结论。原 issue 记录的 230 万行、36 组部署环境配对结果作为既有方向性证据,非本次重跑。

    待解决点

    无本 issue 已知待解决项。本次未重新运行原有 230 万行部署环境性能测试,其共享机器上的性能比值仅作为方向性参考。

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

Metadata

Metadata

Labels

area/performancephase/testingseverity/s0test-verification-failed

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions