Skip to content

[Performance]: defer FULLTEXT2 phrase position decoding until document alignment #27155

Closed

Description

@VioletQwQ-0

Background

FULLTEXT2 positional phrase search currently decodes a posting block's position payload while cursors are still advancing and aligning document ordinals. For sparse phrase intersections, many decoded position blocks are never inspected because the terms do not align on a common document.

Profiles from the 2,303,643-document gojieba workload show phraseCursor.skipTo, position decoding, and varint decoding as the dominant Natural Language Mode costs.

Proposed scope

  • Split phrase-cursor document-block state from position-block state.
  • Let doc() and skipTo() decode only document ordinals.
  • Decode positions only after all phrase cursors align on a common document and positions() is requested.
  • Decode each position block at most once per cursor/block.
  • Preserve the existing phrase membership, BM25/TF-IDF score, result ordering contract, buffer ownership, and serialized index format.

Non-goals

  • No SQL, DDL, FST, posting, CDC, or runtime-filter format changes.
  • No changes to Boolean, BM25 OR, prefix, or position-free routing.
  • No new cache or background state.

Acceptance criteria

  • Differential phrase tests match the existing fallback for build-side and serialized loaded segments, including sparse intersections and block boundaries.
  • Document-only cursor advancement does not decode positions.
  • FULLTEXT2 package tests, focused race tests, build, vet, and the relevant FULLTEXT2 BVT control pass on the PR head.
  • A same-data A/B shows lower CPU/request or higher Natural Language Mode QPS without a Boolean control regression.

QA decision

  • QA required: yes
  • Reason: the optimization is internal and semantics-preserving, but the performance claim depends on a deployed real-data workload.
  • Production entrypoint: positional FULLTEXT2 MATCH ... AGAINST (... IN NATURAL LANGUAGE MODE).
  • Automated terminal coverage: differential PK membership and float32 score-bit tests.
  • Remaining validation: representative latest-main A/B on the 2,303,643-document workload.

Activity

  1. added
    severity/s0
    on Aug 14, 2026
  2. VioletQwQ-0 commented on Aug 17, 2026

    @VioletQwQ-0
    CollaboratorAuthor

    Transfer to testing after #27165 merged.

    • PR head: b66120c91839aa2ec53f2a71cc0d025eb06894f2
    • Merge commit: ec591dc9d4ec6b3beb81b804dac11aceb9b66441
    • Current main: b5900c275d0cad01f499357f6d3830cd71fa17e4
    • Automated evidence: CHECK PR VALID, shared build, UT coverage, and Summary completed successfully; complementary BVT planning also passed. The PR's correctness preflight covered 82 differential queries with identical PK membership and float32 score bits, and the paired 2.3M-document benchmark completed all 10 cells with zero errors/timeouts, but was marked PERF_INCONCLUSIVE_HOST_BUSY because the host was shared.

    QA required: yes. Remaining testing scope is the production positional FULLTEXT2 entry point (MATCH ... AGAINST (... IN NATURAL LANGUAGE MODE)) on current main: verify deferred phrase-position decoding for sparse and dense phrase intersections, single-slot/prefix fallback, WAND parity, result/score equivalence, and representative latency/throughput against the baseline. Expected PASS: identical result PK membership and float32 score bits, no errors/timeouts, and the intended sparse-intersection improvement without regression in the boolean MUST control. Expected FAIL: any correctness/score mismatch, timeout/error, or material regression in the covered control.

    Issue author is VioletQwQ-0 (not heni02), so the designated tester is Ariznawlll.

  3. VioletQwQ-0 commented on Aug 19, 2026

    @VioletQwQ-0
    CollaboratorAuthor

    合并后关闭 Issue 的验证证据

    实现已通过 #27165 合入主线。

    • PR Head:b66120c91839aa2ec53f2a71cc0d025eb06894f2
    • Merge Commit:ec591dc9d4ec6b3beb81b804dac11aceb9b66441
    • 生产入口:positional FULLTEXT2 MATCH ... AGAINST (... IN NATURAL LANGUAGE MODE)

    根因与实现证据

    修改前,phraseCursor.doc()、phraseCursor.skipTo() 与 positions() 使用同一个 block decoder。因此,每个被游标访问的 posting block 在所有 phrase cursor 对齐到共同文档之前,就会解码 position payload;对于稀疏 phrase intersection,其中大量 position 数据最终不会被使用。

    合并后的实现将文档块和位置块状态拆开:文档推进阶段只解码 document ordinal;只有所有游标对齐后请求 positions() 时才解码 position,并保证每个 cursor/block 最多解码一次。

    本次改动不修改 SQL、DDL、索引/FST/posting 格式、CDC、runtime-filter 格式、phrase membership 或评分语义。

    正确性证据

    • phrase cursor 差分测试覆盖 build-side、serialized loaded segment、稀疏 intersection、block 边界和生产 table-function 路径,全部通过。
    • lazy-decode 测试证明 doc()、skipTo() 不会解码 position block,直到 positions() 被调用。
    • WAND parity、FULLTEXT2 race、package test、关联 table-function test、build、vet 和 git diff --check 均通过。
    • latest-main 代表集预检:82/82 条查询的 PK membership 和每个 PK 的 float32 score bits 完全一致。
    • 历史完整固定 query pack:588/588 个查询对的 PK membership 和每个 PK 的 float32 score bits 完全一致。

    2,303,643 文档性能证据

    配对 A/B 使用同一份只读 positional gojieba FULLTEXT2 索引和固定 query pack:

    • 语料 SHA-256:b903ac6cdc6af77f01f27cc71c8cc4f29cfbe27c4b122c61861243abf3d67bdd
    • natural_normal(200 条):f6ce089380452686462329a91b48da58e19d9399ec57ddc9c12fd8f224852934
    • natural_mixed(188 条):a73f75109c0d460d020f2c587aec997fc7edd47150b46633535511cf28f91e94
    • boolean_must(200 条):a5794b5e4c78513ae97098354d90da704d04ddbb1fd5d697599f1f3d876915bd

    latest-main 配对测试每个 cell 预热 15 秒、测量 60 秒,并采用 A/C 交错顺序:

    Workload Candidate/Main QPS Candidate/Main P99 重复波动
    natural_normal 2.939x 0.155x 2.66%
    natural_mixed 2.689x 0.159x 3.65%
    boolean_must 控制组 0.969x 1.054x 单次控制

    latest-main 的 10 个性能 cell 全部完成,0 error、0 timeout。

    更早的同语料 30-cell 测试提供了更完整的 C1/C10 证据:

    • natural_normal:C1 为 2.41x,C10 为 3.01x
    • natural_mixed:C1 为 2.11x,C10 为 2.72x
    • boolean_must C10 控制组:0.979x

    CI 与证据边界

    合并 PR 的 exact head 已完成所需 CI,包括 Ubuntu UT/coverage、SCA、Proxy/Multi-CN BVT、TKE Check-in BVT、TPCC、Sysbench、SSB 和 TPCH,结果均为成功。

    mo-55 是共享测试主机,因此性能结果统一标记为 PERF_INCONCLUSIVE_HOST_BUSY:配对测试可以证明性能改善方向,但不发布绝对 QPS/P99。

    以上构成开发侧的实现、语义一致性、回归测试和真实数据性能证据。当前 Issue 仍处于 phase/testing;指定测试人员在 current main 上验证 Natural Language Mode 生产入口,确认结果及 score 一致、0 error、0 timeout,且 Boolean 控制组无明显回退后,即可关闭本 Issue。

  4. Ariznawlll commented on Sep 18, 2026

    @Ariznawlll
    Collaborator

    测试版本

    • 分支:main
    • commit:6690f1af97977ad5671235e9204296cd2d504ad5
    • 部署方式:129 性能回归 Slot A,FULLTEXT2 独占回归服务;gojieba parser,C10
    • 测试日期:2026-09-18

    原问题验证

    以 2,303,643 行固定语料运行生产 Natural Language Mode workload。gojieba 依次执行 natural_short(200 条)、natural_normal(200 条)和 natural_mixed(188 条)query pack;每 cell 预热 60 秒、测量 10 分钟,合计 588 条固定查询。三组均为 0 error、客户端退出码 0:

    • short:QPS 2506.9171,P99 23.55 ms;
    • normal:QPS 2803.4743,P99 13.99 ms;
    • mixed:QPS 3213.7190,P99 11.45 ms。

    本 issue 的修复前/后 A/B 已在此前验收完成;本轮不重复 A/B,只以当前 main 的正式性能回归验证持续稳定性和控制路径。

    验证范围与结果

    1. gojieba Natural Language short/normal/mixed 三类 query pack 共 588 条,在真实 230 万文档、C10 下均完整执行且无 error。
    2. ngram 同一 Natural Language workload 也完整执行;两个 parser 的 workload 计划均确认走 fulltext2_search。
    3. gojieba boolean_must 200 条控制组完整执行,0 error,QPS 2551.4245、P99 9.95 ms;未观察到 Boolean 控制路径回归。

    既有语义覆盖

    1. 关联修复 PR #27165 的既有 phrase-cursor 差分覆盖包含 build-side/serialized loaded segment、稀疏 intersection、block 边界、单 slot/prefix fallback 与 WAND parity;以 PK membership 和每个 PK 的 float32 score bits 为 oracle。
    2. 本轮性能 job 不重复构造上述内部 phrase 边界;其职责是固定真实语料上的 Natural Language 性能/稳定性门禁。

    白盒验证

    • PR #27165 已合入;相关覆盖位于 pkg/fulltext2/phrase_cursor_test.go 和 phrase_perf_bench_test.go。
    • 既有测试验证 doc()/skipTo() 在调用 positions() 前不解码 position block,并覆盖 phrase 结果与 score 差分。

    回归测试

    测试证据

    • 该 run 的产物 fulltext-parser-regression/summary.tsv 记录 gojieba Natural Language 三组 workload 的 query pack hash、成功次数、0 error、QPS 与 P99;Boolean 控制组同一产物中为 0 error。
    • 关联修复提交:ec591dc9d4ec6b3beb81b804dac11aceb9b66441。

    测试结论

    测试通过。

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

Metadata

Metadata

Assignees

Labels

phase/testingseverity/s0

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions