Skip to content

perf(fulltext2): decode phrase positions after doc alignment - #27165

Merged
XuPeng-SH merged 2 commits into
matrixorigin:mainfrom
VioletQwQ-0:codex/fulltext2-lazy-phrase-positions
Aug 17, 2026
Merged

XuPeng-SH merged 2 commits into
matrixorigin:mainfrom
VioletQwQ-0:codex/fulltext2-lazy-phrase-positions

Conversation

@VioletQwQ-0

@VioletQwQ-0 VioletQwQ-0 commented Aug 14, 2026 •

Copy link
Copy Markdown
Collaborator

What type of PR is this?

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

Which issue(s) this PR fixes

issue #27155

What this PR does / why we need it:

Defer FULLTEXT2 phrase-position decoding until document alignment, so sparse phrase intersections avoid decoding position blocks that are never inspected while preserving query results and existing index behavior.

Summary

Positional FULLTEXT2 phrase cursors previously decoded document ordinals, term frequencies, and positions together while aligning posting lists. Sparse phrase intersections therefore decoded position blocks that were never inspected.

This change separates document-block and position-block state. doc() and skipTo() decode document ordinals only; positions are decoded only after all phrase cursors align on a common document. Existing query-local phrase buffers are reused and the unused phrase-TF scratch is removed. WAND remains on the existing fillBlock path, and single-slot/prefix phrases retain their existing fallback.

There is no SQL, DDL, index-format, FST, CDC, runtime-filter, scoring, or membership change.

Correctness and lifecycle

  • Differential phrase-cursor tests compare document ordinals and phrase TF with the materialized evaluator for build-side and serialized loaded segments.
  • Lazy-decode tests prove that doc() and skipTo() leave the position block undecoded.
  • Sparse-intersection and table-function tests exercise the production search entry point.
  • Results copy ordinal/TF scalars and do not alias pooled buffers; early missing-term paths retain deferred buffer release.
  • WAND parity, focused race, full FULLTEXT2 race, and dependent table-function tests pass.

Validation on current main

Base: matrixorigin/matrixone@8b5dd17ca10699f966b8c22ecbf65f6c6b250217

Head: c6e039fdafd4f3ed67891ac64f5d7a042be73046

Passed:

go test ./pkg/fulltext2/... ./pkg/sql/colexec/table_function/...
go test -race ./pkg/fulltext2/...
go build ./cmd/mo-service
go vet ./pkg/fulltext2/... ./pkg/sql/colexec/table_function/...
git diff --check
semantic preflight: PASS

Latest-main 2.3M-document A/B

The same-host paired run used 2,303,643 documents, the same read-only positional gojieba FULLTEXT2 index, and fixed query packs:

  • natural_normal: 200 queries, SHA-256 f6ce089380452686462329a91b48da58e19d9399ec57ddc9c12fd8f224852934
  • natural_mixed: 188 queries, SHA-256 a73f75109c0d460d020f2c587aec997fc7edd47150b46633535511cf28f91e94
  • boolean_must: 200 queries, SHA-256 a5794b5e4c78513ae97098354d90da704d04ddbb1fd5d697599f1f3d876915bd

The benchmark binaries were built from A-main@8c34dc9 and C-phrase@a8e9eff; the intervening upstream commit and the rebase-only commit do not touch FULLTEXT2, docfilter, or the FULLTEXT planner/plugin paths. The published PR head is the rebased c6e039f.

Correctness preflight passed all 82 selected differential queries with identical PK membership and float32 score bits. All 10 performance cells completed with zero errors and zero timeouts. The host was shared, so absolute QPS/P99 are not published; these are paired direction results only and are marked PERF_INCONCLUSIVE_HOST_BUSY.

Workload Candidate / main QPS Candidate / main P99 Repeat spread
natural_normal 2.939x 0.155x 2.66%
natural_mixed 2.689x 0.159x 3.65%
boolean_must control 0.969x 1.054x single control

The run used 15 seconds of warmup and 60 seconds of measurement per cell, with alternating A/C order. Gate: PASS.

Historical evidence

The earlier 30-cell same-host run on the same corpus passed 588/588 query-pair membership and float32 score comparisons and reported Natural Normal 2.41x C1 / 3.01x C10, Natural Mixed 2.11x C1 / 2.72x C10, and Boolean MUST C10 0.979x. That run supplies broader C1/C10 and full-query evidence; the current run binds the direction to this rebased head.

BVT and QA

QA required. Production entry point: positional FULLTEXT2 MATCH ... AGAINST (... IN NATURAL LANGUAGE MODE). The PR is ready for review after the current-head checks complete; no SQL or public interface changes are included.

@XuPeng-SH
XuPeng-SH requested a review from cpegeric August 14, 2026 08:51
@matrix-meow matrix-meow added the size/M Denotes a PR that changes [100,499] lines label Aug 14, 2026
@VioletQwQ-0
VioletQwQ-0 force-pushed the codex/fulltext2-lazy-phrase-positions branch from 9598358 to 33f02f4 Compare August 16, 2026 13:18
@XuPeng-SH

Copy link
Copy Markdown
Contributor

Review: Approve ✅

This is a well-evidenced performance optimization that correctly defers position decoding in phraseCursor until alignment, and introduces fillBlockDocs to skip redundant tf decoding during doc-only intersection. Benchmarks show 2.4–3.0× QPS improvement for phrase queries with no regression to boolean/WAND paths, and differential testing (588/588 bit-exact) provides strong correctness evidence.

One minor suggestion

fillBlockDocs partial-return contract (pkg/fulltext2/segment.go:160–193)

On corrupt data (binary.Uvarint failure or off >= len(data)), this function returns i < blen. The current caller (decodeDocs) handles this correctly via c.blen bounds checks, so there is no bug today. However, the existing fillBlock has the same behavior but has been battle-tested with callers written to that contract. To prevent future callers from assuming fillBlockDocs always populates exactly blockLen(b) slots, consider adding a brief note:

// Returns the number of docs actually decoded. On corrupt block data this may
// be less than blockLen(b); callers must use the return value as the valid
// slice length rather than assuming all blockLen(b) slots are populated.

This matches the defensive pattern already used in fillBlockPositions and makes the API contract explicit.

Verdict

Approve. The optimization is architecturally sound, the lazy-decode invariant is correctly tested, and the only actionable item is documenting the partial-return semantics to prevent future misuse.

@VioletQwQ-0
VioletQwQ-0 force-pushed the codex/fulltext2-lazy-phrase-positions branch from a8e9eff to c6e039f Compare August 17, 2026 05:55

@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-approving exact head after fixing the Mergify commit-message metadata: the required ## What this PR does / why we need it: section is now present and the PR title has been shortened.

@XuPeng-SH

Copy link
Copy Markdown
Contributor

@Mergifyio queue main

@mergify

mergify Bot commented Aug 17, 2026 •

Copy link
Copy Markdown
Contributor

Merge Queue Status

  • ✅ Entered queue — 2026-08-17 11:18 UTC · Rule: main · triggered by @XuPeng-SH with the @mergifyio queue command
  • 🟠 Checks running · in-place
  • 🚫 Left the queue — 2026-08-17 12:22 UTC · at b66120c91839aa2ec53f2a71cc0d025eb06894f2

This pull request spent 1 hour 3 minutes 28 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 #27165 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.

Failing checks:

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

@mergify mergify Bot added the queued label Aug 17, 2026
@XuPeng-SH
XuPeng-SH merged commit ec591dc into matrixorigin:main Aug 17, 2026
31 checks passed
@mergify mergify Bot added dequeued and removed queued labels Aug 17, 2026
XuPeng-SH added a commit that referenced this pull request Aug 27, 2026
## What type of PR is this?

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

## Which issue(s) this PR fixes:

issue #25541

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

This is a bounded backport of the FULLTEXT2 behavior closure from the
fixed
`upstream/main` reference to `4.2-dev`. It keeps FULLTEXT2 distinct from
classic FULLTEXT and preserves the target branch's parser/PERFORM/pipe
contracts.

Source/target closure:

- source `upstream/main`: `8e616a693458652cc26b3c4be45c6602dff298d4`
- target `upstream/4.2-dev`: `d2393868a7aaa6343518d80849fe4696aa3577e9`
- exact fork head: `325686d29c17b3729f32b837b5bc2144d33f0a9b`
- #25904 core: `966acb2a92bb740e57b0b7a181df2d21956e1d3`,
`0eb9a921ece274c956447640b41ad2a255079e8d`,
`403a99fb65304e75b82e75793448f0690a871d0e`,
`bfa83f42737ca6304c0af3f6913e70ccc961464`
- #27165 phrase-position decode:
`2b142144c3c24a2100d7d313e952717025d56aeb`
- #27171 FT2-only wrapped score/range closure:
`835e046faa9242dbe288bd72364a475e2132bbed`
- #27461/#27462 cache and cold-load closure:
`e4abf5e90d0b5e09590571ca78447e50806527c`
- #27598 readiness BVT closure:
`e3a7440e2ac32bac780669f33c656960e22cff22`

Current-head review repairs:

- Reverse constant-left `<`/`<=` before harvesting a lower-bound MATCH
membership driver; reject constant-left `>`/`>=` upper bounds
fail-closed.
- Route all FULLTEXT2 ISCP consumer errors through the non-blocking
helper and
  report `ctx.Err()` on cancellation.
- Restore the execution-level `fulltext2_wrapped_score.sql/.result` BVT
pair
  and replace restore/clone fixed sleeps with readiness waits.
- Refresh the ancestor-accurate backport manifest and clear all
  `git diff --check` trailing whitespace findings.
- Trim FULLTEXT2 SHOW CREATE option padding only at the terminal output
  boundary, preserving the shared renderer and vector-index behavior.
- Route wrapped-only FULLTEXT2 score predicates on either INNER JOIN
child
through the existing wrapped rewrite and keep the score comparison in a
  post-rewrite FILTER.

## Validation

- `make -C pkg/sql/parsers/dialect/mysql` — PASS
- `make generate-pb` — PASS; protoc 29.3 descriptor-only churn was
discarded
  and no unexpected generated diff remains
- `go test -mod=readonly ./pkg/fulltext2/... ./pkg/iscp ./pkg/sql/plan`
— PASS
- current-head focused `GOWORK=off go test -mod=readonly -count=1
-timeout 120s -run '^TestFulltext2WrappedMatchJoinChild$'
./pkg/sql/plan` — PASS
- current-head `GOWORK=off go test -mod=readonly -count=1
./pkg/sql/plan` — PASS
- current-head `GOWORK=off go build -mod=readonly ./pkg/sql/plan` and
  `GOWORK=off go vet -mod=readonly ./pkg/sql/plan` — PASS
- current-head SCA repair — removed the unreferenced
`applyJoinFullTextIndices`
wrapper; targeted plan tests, build, and vet pass; exact-head remote SCA
is
  pending
- current-head focused SHOW CREATE regression and catalog option tests —
PASS
- local `mo-cgo-test` wrapper — BLOCKED by missing `cgo/libmo.dylib`; no
CGo
  wrapper pass is claimed
- `go test -race -mod=readonly ./pkg/fulltext2/... ./pkg/iscp` — PASS
- `go build -mod=readonly ./cmd/mo-service` — PASS (macOS linker
rpath/path
  warnings only)
- base differential — exact target
`d2393868a7aaa6343518d80849fe4696aa3577e9`
  rejects `CREATE FULLTEXT2 INDEX`; this exact head parses it as
  `INDEX_CATEGORY_FULLTEXT2`
- BVT source parity and no-fixed-sleep scan — PASS
- canonical wrapped-score BVT now covers wrapped-only MATCH on both
INNER JOIN
child positions with qualifying and rejecting thresholds; exact-head
remote
  BVT remains pending
- exact-head semantic preflight — `PASS semantic=PASS`, diff hash
  `efc51153938b14e051372026b296c06e05696385ac674fa7f05f3a7217741d09`

## Scope and acceptance boundaries

- `QA required: yes`
- The PR was opened as Draft for preflight and is now **Ready for
review**.
Required CI, formal reviews, and Mergify remain pending; no remote pass
is
  claimed until they bind to this exact head.
- Build success, index creation/readiness, and elapsed workload duration
are
  not acceptance by themselves. No classic FULLTEXT result, fixed-commit
  product acceptance claim, or formal QPS claim is used here.
- The 2.3M frozen corpus and shared `freetier-01` workload remain
post-merge
gates. After merge, only the official immutable image/release workflow
may
produce the tag/digest; `freetier-01` must be upgraded through the
reviewed
GitOps `environment=new-dev + mode=mo + action=set` PR. No local image,
direct `4.2-dev` push, direct GitOps edit, kubectl mutation, or pod
restart
  is authorized.
- The first post-release test is a unique-database 15-minute
small-corpus
FULLTEXT2 shakeout with readiness polling, token-bucket DML, C1/C10
readers,
  and an independent correctness ledger. Only `MEASURED_PASS` with zero
correctness errors, no backlog, and complete observations may unlock the
  low-load two-hour continuous run.

Please keep issue #25541 open until QA explicitly reports PASS/FAIL.

---------

Co-authored-by: Eric Lam <[email protected]>
Co-authored-by: XuPeng-SH <[email protected]>
VioletQwQ-0 added a commit to VioletQwQ-0/matrixone that referenced this pull request Sep 17, 2026
…rigin#27165)

## What type of PR is this?

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

## Which issue(s) this PR fixes

issue matrixorigin#27155

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

Defer FULLTEXT2 phrase-position decoding until document alignment, so
sparse phrase intersections avoid decoding position blocks that are
never inspected while preserving query results and existing index
behavior.

## Summary

Positional FULLTEXT2 phrase cursors previously decoded document
ordinals, term frequencies, and positions together while aligning
posting lists. Sparse phrase intersections therefore decoded position
blocks that were never inspected.

This change separates document-block and position-block state. `doc()`
and `skipTo()` decode document ordinals only; positions are decoded only
after all phrase cursors align on a common document. Existing
query-local phrase buffers are reused and the unused phrase-TF scratch
is removed. WAND remains on the existing `fillBlock` path, and
single-slot/prefix phrases retain their existing fallback.

There is no SQL, DDL, index-format, FST, CDC, runtime-filter, scoring,
or membership change.

## Correctness and lifecycle

- Differential phrase-cursor tests compare document ordinals and phrase
TF with the materialized evaluator for build-side and serialized loaded
segments.
- Lazy-decode tests prove that `doc()` and `skipTo()` leave the position
block undecoded.
- Sparse-intersection and table-function tests exercise the production
search entry point.
- Results copy ordinal/TF scalars and do not alias pooled buffers; early
missing-term paths retain deferred buffer release.
- WAND parity, focused race, full FULLTEXT2 race, and dependent
table-function tests pass.

## Validation on current main

Base: `matrixorigin/matrixone@8b5dd17`

Head: `c6e039fdafd4f3ed67891ac64f5d7a042be73046`

Passed:

```text
go test ./pkg/fulltext2/... ./pkg/sql/colexec/table_function/...
go test -race ./pkg/fulltext2/...
go build ./cmd/mo-service
go vet ./pkg/fulltext2/... ./pkg/sql/colexec/table_function/...
git diff --check
semantic preflight: PASS
```

## Latest-main 2.3M-document A/B

The same-host paired run used 2,303,643 documents, the same read-only
positional gojieba FULLTEXT2 index, and fixed query packs:

- `natural_normal`: 200 queries, SHA-256
`f6ce089380452686462329a91b48da58e19d9399ec57ddc9c12fd8f224852934`
- `natural_mixed`: 188 queries, SHA-256
`a73f75109c0d460d020f2c587aec997fc7edd47150b46633535511cf28f91e94`
- `boolean_must`: 200 queries, SHA-256
`a5794b5e4c78513ae97098354d90da704d04ddbb1fd5d697599f1f3d876915bd`

The benchmark binaries were built from `A-main@8c34dc9` and
`C-phrase@a8e9eff`; the intervening upstream commit and the rebase-only
commit do not touch FULLTEXT2, docfilter, or the FULLTEXT planner/plugin
paths. The published PR head is the rebased `c6e039f`.

Correctness preflight passed all 82 selected differential queries with
identical PK membership and float32 score bits. All 10 performance cells
completed with zero errors and zero timeouts. The host was shared, so
absolute QPS/P99 are not published; these are paired direction results
only and are marked `PERF_INCONCLUSIVE_HOST_BUSY`.

| Workload | Candidate / main QPS | Candidate / main P99 | Repeat spread
|
|---|---:|---:|---:|
| natural_normal | **2.939x** | **0.155x** | 2.66% |
| natural_mixed | **2.689x** | **0.159x** | 3.65% |
| boolean_must control | **0.969x** | **1.054x** | single control |

The run used 15 seconds of warmup and 60 seconds of measurement per
cell, with alternating A/C order. Gate: PASS.

## Historical evidence

The earlier 30-cell same-host run on the same corpus passed 588/588
query-pair membership and float32 score comparisons and reported Natural
Normal 2.41x C1 / 3.01x C10, Natural Mixed 2.11x C1 / 2.72x C10, and
Boolean MUST C10 0.979x. That run supplies broader C1/C10 and full-query
evidence; the current run binds the direction to this rebased head.

## BVT and QA

QA required. Production entry point: positional FULLTEXT2 `MATCH ...
AGAINST (... IN NATURAL LANGUAGE MODE)`. The PR is ready for review
after the current-head checks complete; no SQL or public interface
changes are included.

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
VioletQwQ-0 added a commit to VioletQwQ-0/matrixone that referenced this pull request Sep 17, 2026
…rigin#27165)

## What type of PR is this?

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

## Which issue(s) this PR fixes

issue matrixorigin#27155

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

Defer FULLTEXT2 phrase-position decoding until document alignment, so
sparse phrase intersections avoid decoding position blocks that are
never inspected while preserving query results and existing index
behavior.

## Summary

Positional FULLTEXT2 phrase cursors previously decoded document
ordinals, term frequencies, and positions together while aligning
posting lists. Sparse phrase intersections therefore decoded position
blocks that were never inspected.

This change separates document-block and position-block state. `doc()`
and `skipTo()` decode document ordinals only; positions are decoded only
after all phrase cursors align on a common document. Existing
query-local phrase buffers are reused and the unused phrase-TF scratch
is removed. WAND remains on the existing `fillBlock` path, and
single-slot/prefix phrases retain their existing fallback.

There is no SQL, DDL, index-format, FST, CDC, runtime-filter, scoring,
or membership change.

## Correctness and lifecycle

- Differential phrase-cursor tests compare document ordinals and phrase
TF with the materialized evaluator for build-side and serialized loaded
segments.
- Lazy-decode tests prove that `doc()` and `skipTo()` leave the position
block undecoded.
- Sparse-intersection and table-function tests exercise the production
search entry point.
- Results copy ordinal/TF scalars and do not alias pooled buffers; early
missing-term paths retain deferred buffer release.
- WAND parity, focused race, full FULLTEXT2 race, and dependent
table-function tests pass.

## Validation on current main

Base: `matrixorigin/matrixone@8b5dd17`

Head: `c6e039fdafd4f3ed67891ac64f5d7a042be73046`

Passed:

```text
go test ./pkg/fulltext2/... ./pkg/sql/colexec/table_function/...
go test -race ./pkg/fulltext2/...
go build ./cmd/mo-service
go vet ./pkg/fulltext2/... ./pkg/sql/colexec/table_function/...
git diff --check
semantic preflight: PASS
```

## Latest-main 2.3M-document A/B

The same-host paired run used 2,303,643 documents, the same read-only
positional gojieba FULLTEXT2 index, and fixed query packs:

- `natural_normal`: 200 queries, SHA-256
`f6ce089380452686462329a91b48da58e19d9399ec57ddc9c12fd8f224852934`
- `natural_mixed`: 188 queries, SHA-256
`a73f75109c0d460d020f2c587aec997fc7edd47150b46633535511cf28f91e94`
- `boolean_must`: 200 queries, SHA-256
`a5794b5e4c78513ae97098354d90da704d04ddbb1fd5d697599f1f3d876915bd`

The benchmark binaries were built from `A-main@8c34dc9` and
`C-phrase@a8e9eff`; the intervening upstream commit and the rebase-only
commit do not touch FULLTEXT2, docfilter, or the FULLTEXT planner/plugin
paths. The published PR head is the rebased `c6e039f`.

Correctness preflight passed all 82 selected differential queries with
identical PK membership and float32 score bits. All 10 performance cells
completed with zero errors and zero timeouts. The host was shared, so
absolute QPS/P99 are not published; these are paired direction results
only and are marked `PERF_INCONCLUSIVE_HOST_BUSY`.

| Workload | Candidate / main QPS | Candidate / main P99 | Repeat spread
|
|---|---:|---:|---:|
| natural_normal | **2.939x** | **0.155x** | 2.66% |
| natural_mixed | **2.689x** | **0.159x** | 3.65% |
| boolean_must control | **0.969x** | **1.054x** | single control |

The run used 15 seconds of warmup and 60 seconds of measurement per
cell, with alternating A/C order. Gate: PASS.

## Historical evidence

The earlier 30-cell same-host run on the same corpus passed 588/588
query-pair membership and float32 score comparisons and reported Natural
Normal 2.41x C1 / 3.01x C10, Natural Mixed 2.11x C1 / 2.72x C10, and
Boolean MUST C10 0.979x. That run supplies broader C1/C10 and full-query
evidence; the current run binds the direction to this rebased head.

## BVT and QA

QA required. Production entry point: positional FULLTEXT2 `MATCH ...
AGAINST (... IN NATURAL LANGUAGE MODE)`. The PR is ready for review
after the current-head checks complete; no SQL or public interface
changes are included.

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
VioletQwQ-0 added a commit to VioletQwQ-0/matrixone that referenced this pull request Sep 17, 2026
…rigin#27165)

## What type of PR is this?

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

## Which issue(s) this PR fixes

issue matrixorigin#27155

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

Defer FULLTEXT2 phrase-position decoding until document alignment, so
sparse phrase intersections avoid decoding position blocks that are
never inspected while preserving query results and existing index
behavior.

## Summary

Positional FULLTEXT2 phrase cursors previously decoded document
ordinals, term frequencies, and positions together while aligning
posting lists. Sparse phrase intersections therefore decoded position
blocks that were never inspected.

This change separates document-block and position-block state. `doc()`
and `skipTo()` decode document ordinals only; positions are decoded only
after all phrase cursors align on a common document. Existing
query-local phrase buffers are reused and the unused phrase-TF scratch
is removed. WAND remains on the existing `fillBlock` path, and
single-slot/prefix phrases retain their existing fallback.

There is no SQL, DDL, index-format, FST, CDC, runtime-filter, scoring,
or membership change.

## Correctness and lifecycle

- Differential phrase-cursor tests compare document ordinals and phrase
TF with the materialized evaluator for build-side and serialized loaded
segments.
- Lazy-decode tests prove that `doc()` and `skipTo()` leave the position
block undecoded.
- Sparse-intersection and table-function tests exercise the production
search entry point.
- Results copy ordinal/TF scalars and do not alias pooled buffers; early
missing-term paths retain deferred buffer release.
- WAND parity, focused race, full FULLTEXT2 race, and dependent
table-function tests pass.

## Validation on current main

Base: `matrixorigin/matrixone@8b5dd17`

Head: `c6e039fdafd4f3ed67891ac64f5d7a042be73046`

Passed:

```text
go test ./pkg/fulltext2/... ./pkg/sql/colexec/table_function/...
go test -race ./pkg/fulltext2/...
go build ./cmd/mo-service
go vet ./pkg/fulltext2/... ./pkg/sql/colexec/table_function/...
git diff --check
semantic preflight: PASS
```

## Latest-main 2.3M-document A/B

The same-host paired run used 2,303,643 documents, the same read-only
positional gojieba FULLTEXT2 index, and fixed query packs:

- `natural_normal`: 200 queries, SHA-256
`f6ce089380452686462329a91b48da58e19d9399ec57ddc9c12fd8f224852934`
- `natural_mixed`: 188 queries, SHA-256
`a73f75109c0d460d020f2c587aec997fc7edd47150b46633535511cf28f91e94`
- `boolean_must`: 200 queries, SHA-256
`a5794b5e4c78513ae97098354d90da704d04ddbb1fd5d697599f1f3d876915bd`

The benchmark binaries were built from `A-main@8c34dc9` and
`C-phrase@a8e9eff`; the intervening upstream commit and the rebase-only
commit do not touch FULLTEXT2, docfilter, or the FULLTEXT planner/plugin
paths. The published PR head is the rebased `c6e039f`.

Correctness preflight passed all 82 selected differential queries with
identical PK membership and float32 score bits. All 10 performance cells
completed with zero errors and zero timeouts. The host was shared, so
absolute QPS/P99 are not published; these are paired direction results
only and are marked `PERF_INCONCLUSIVE_HOST_BUSY`.

| Workload | Candidate / main QPS | Candidate / main P99 | Repeat spread
|
|---|---:|---:|---:|
| natural_normal | **2.939x** | **0.155x** | 2.66% |
| natural_mixed | **2.689x** | **0.159x** | 3.65% |
| boolean_must control | **0.969x** | **1.054x** | single control |

The run used 15 seconds of warmup and 60 seconds of measurement per
cell, with alternating A/C order. Gate: PASS.

## Historical evidence

The earlier 30-cell same-host run on the same corpus passed 588/588
query-pair membership and float32 score comparisons and reported Natural
Normal 2.41x C1 / 3.01x C10, Natural Mixed 2.11x C1 / 2.72x C10, and
Boolean MUST C10 0.979x. That run supplies broader C1/C10 and full-query
evidence; the current run binds the direction to this rebased head.

## BVT and QA

QA required. Production entry point: positional FULLTEXT2 `MATCH ...
AGAINST (... IN NATURAL LANGUAGE MODE)`. The PR is ready for review
after the current-head checks complete; no SQL or public interface
changes are included.

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
@VioletQwQ-0
VioletQwQ-0 deleted the codex/fulltext2-lazy-phrase-positions branch December 1, 2026 03:47

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/enhancement size/M Denotes a PR that changes [100,499] lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants