Skip to content

perf(fulltext2): probe loaded primary keys without boxing - #27248

Merged
XuPeng-SH merged 6 commits into
matrixorigin:mainfrom
VioletQwQ-0:codex/fulltext2-zero-copy-membership
Aug 29, 2026
Merged

XuPeng-SH merged 6 commits into
matrixorigin:mainfrom
VioletQwQ-0:codex/fulltext2-zero-copy-membership

Conversation

@VioletQwQ-0

@VioletQwQ-0 VioletQwQ-0 commented Aug 17, 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 #27247

What this PR does / why we need it:

FULLTEXT2 non-INCLUDE WHERE filtering probes a primary-key runtime membership filter for candidate documents. Loaded segments already hold immutable canonical PK content bytes in their mmap-backed docmap, but the previous path decoded each key into a boxed Go value and encoded it again for docfilter.

This PR probes the loaded docmap content directly when its representation matches the runtime-filter source vector:

  • integer, BIT, temporal, decimal, and ordinary varlena PKs use the borrowed loaded path;
  • build-side segments retain the typed fallback;
  • UUID retains the typed fallback because docmap stores a 36-byte canonical string while docfilter hashes the raw 16-byte value;
  • malformed loaded PK metadata fails closed without falling through to another representation.

There is no SQL, DDL, index-format, FST, CDC, runtime-filter wire-protocol, score, or public-interface change.

Review closure

TestLoadedContainsPkTypes uses the production Builder -> Finish -> Serialize -> Deserialize chain and asserts the resulting segment is loaded (pks == nil). It now also records the actual slice passed to MembershipFilter.Test:

  • every non-empty, non-UUID probe must share the exact backing memory returned by loaded pkContent, proving the borrowed path rather than merely byte-equivalent decode/re-encode;
  • UUID must be an independent 16-byte probe and must not alias the 36-byte canonical docmap content;
  • build-side fallback, invalid ordinals, missing offsets, truncated docmaps, invalid lengths, and empty varlena content remain covered.

UUID allocation-free parsing and a conditional raw-16 on-disk design are intentionally out of scope and tracked in #27800.

Exact-head validation

Base: matrixorigin/matrixone@b7892451b3d3df7ca998d45a215d07b20c415ecb

Head: 13673ea3812433e8d70dfdf845b1b120d169797f

Passed locally on macOS/arm64 with current-branch MatrixOne CGo prerequisites:

GOWORK=off mo-cgo-test -run '^(TestLoadedContainsPkTypes|TestPkContentRejectsInvalidAccess|TestContainsPkTypes)$' -count=1 ./pkg/fulltext2
GOWORK=off mo-cgo-test -count=1 ./pkg/fulltext2 ./pkg/common/docfilter
GOWORK=off mo-cgo-test -run '^TestFulltext2Search' -count=1 ./pkg/sql/colexec/table_function
GOWORK=off mo-cgo-test -race -run '^TestLoadedContainsPkTypes$' -count=12 ./pkg/fulltext2
GOWORK=off mo-cgo-test -race -count=1 ./pkg/fulltext2
go build -mod=readonly ./pkg/fulltext2 ./pkg/common/docfilter ./pkg/sql/colexec/table_function
go vet -mod=readonly ./pkg/fulltext2 ./pkg/common/docfilter ./pkg/sql/colexec/table_function
gofmt -d pkg/fulltext2/coverage_query_membership_test.go
git diff --check
semantic preflight: PASS exact-head=13673ea3812433e8d70dfdf845b1b120d169797f diff-hash=0145f5ee15474d71aa047fc60e6d94ce2bc9b8e378656ff3ad1d351657c9a186

BVT: N/A — this changes the representation and allocation behavior inside the existing membership probe without changing SQL-visible membership or score semantics. The equivalent deterministic regression crosses the production segment serialization/loading boundary, builds a real runtime-vector membership payload, and invokes the production loaded-segment membership entry point. Existing FULLTEXT2 BVT behavior is unchanged.

Historical 2.3M-document directional evidence

The earlier shared-host paired run completed 36/36 cells with zero errors and zero timeouts:

Workload Candidate / baseline QPS Baseline P99 Candidate P99
non-INCLUDE 0.1%, C10 1.310x 204.23 ms 156.02 ms
non-INCLUDE 1%, C10 1.288x 238.86 ms 185.69 ms
non-INCLUDE 10%, C10 1.115x 420.13 ms 374.51 ms
no-WHERE control, C10 0.997x 46.49 ms 46.92 ms

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

These are historical directional results from a busy shared host (PERF_INCONCLUSIVE_HOST_BUSY), not current-head absolute QPS/P99 publication data.

QA

QA required: yes

  • Production entry point: non-INCLUDE FULLTEXT2 WHERE filtering using PK runtime membership on loaded segments.
  • Automated terminal coverage: serialized loaded segments, runtime-vector payloads, all supported PK representations, malformed metadata, ordinal bounds, and UUID/build-side fallback.
  • Remaining gate: fresh exact-head CI and renewed reviewer confirmation.

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

@VioletQwQ-0

Copy link
Copy Markdown
Collaborator Author

Thanks for the follow-up review. The loaded-path test already used the production Builder -> Finish -> Serialize -> Deserialize chain, but its byte-copy oracle could not distinguish true borrowing from decode-and-reencode. The new exact-head test now also asserts loaded.pks == nil and checks backing-memory identity: every non-empty non-UUID slice passed to MembershipFilter.Test must alias the loaded pkContent/pkRaw storage. UUID is the intentional control and must instead be an independent raw 16-byte probe, not the 36-byte canonical docmap content. Build-side fallback and malformed loaded metadata remain covered. UUID allocation-free parsing and conditional raw-16 storage are tracked separately in #27800 and are not mixed into this PR. Fresh local package, table-function, focused/full race, build, vet, diff-check, and semantic-preflight validation passed on head 13673ea381.

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

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.

5 participants