Skip to content

fix(objectio): compact multi-term read filter marks - #28610

Merged
XuPeng-SH merged 3 commits into
matrixorigin:mainfrom
gouhongshen:codex/fix-28609-read-filter-search
Sep 10, 2026
Merged

XuPeng-SH merged 3 commits into
matrixorigin:mainfrom
gouhongshen:codex/fix-28609-read-filter-search

Conversation

@gouhongshen

Copy link
Copy Markdown
Contributor

What type of PR is this?

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

Which issue(s) this PR fixes:

Fixes #28609

What this PR does / why we need it:

ReadFilterSearch used one int64 marker per source row when merging multiple filter terms. For large object blocks this created substantial allocation churn and GC CPU. This PR replaces the row marker array with a compact bitset, preserves ascending row-order output, and allocates the result slice to its exact match count. It also adds a regression test that checks combined searches do not allocate a block-sized marker array.

Tests:

  • go test ./pkg/objectio -count=1

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

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

Reviewed head e46f4e1 against live main/merge-base 24f2f6c. No blocking findings; approve.

The two-file change is a focused in-memory allocation fix, not a persisted/wire encoding change. For each valid row r, word r/64 and bit r%64 uniquely represent membership in the union. Range guards exclude invalid offsets and padding bits; duplicates are idempotent. Iterating words in order and removing the lowest set bit produces the same ascending, unique row coordinates as before, regardless of term order or individual term result order. Empty/single-term, NULL/type fail-open behavior and term-specific matching are unchanged.

The scratch bitset and result are per-call Go-owned storage. No shared mutation, pool/reuse generation, additional wait or cache-backed alias is introduced. Checked cache binding/error propagation and downstream selection/visibility filtering remain intact. Output storage is exactly 8matchedRows bytes plus the rounded bitset (~sourceRows/8 bytes); dense all-hit output therefore has a small extra bitmap allocation compared with the old shared marker/output backing array, while sparse searches eliminate the dominant 8sourceRows allocation. This tradeoff is appropriate for the reported allocation hotspot; it is not a claim that every match density or end-to-end workload is faster.

Validation: read the complete diff, issue #28609, live comments/review history, search constructors, matching/union path and cache/read consumers. Existing tests cover overlapping terms and conservative fallback, and the new allocation regression checks exact ordered hits across distant words. Independently checked 360 union/order model cases covering 0/1/63/64/65/127/128/129/8192 rows, duplicates, reversed/all/no matches and invalid offsets; this is a reference-model check, not execution of the native Go implementation. git diff --check passed. The author reports go test ./pkg/objectio -count=1; I did not independently rerun native tests or wait for CI. Head/base rechecked unchanged before submission.

@mergify

mergify Bot commented Sep 10, 2026 •

Copy link
Copy Markdown
Contributor

Merge Queue Status

  • ✅ Entered queue — 2026-09-10 07:17 UTC · Rule: main · triggered by rule Automatic queue on approval for main
  • 🟠 Checks running · in-place
  • 🚫 Left the queue — 2026-09-10 07:57 UTC · at 37a5a50e39ecc538ee45bb5c2c88cfeafb65c18c

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

Reason

The pull request can't be updated

This pull request seems to come 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, or update the branch manually.

Hint

You should update or rebase your pull request manually. If you do, this pull request will automatically be requeued once the queue conditions match again.
If you think this was a flaky issue, 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

@XuPeng-SH
XuPeng-SH merged commit 6ad98a5 into matrixorigin:main Sep 10, 2026
25 of 27 checks passed
@mergify mergify Bot added dequeued and removed queued labels Sep 10, 2026
VioletQwQ-0 pushed a commit to VioletQwQ-0/matrixone that referenced this pull request Sep 17, 2026
## What type of PR is this?

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

## Which issue(s) this PR fixes:

Fixes matrixorigin#28609

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

`ReadFilterSearch` used one `int64` marker per source row when merging
multiple filter terms. For large object blocks this created substantial
allocation churn and GC CPU. This PR replaces the row marker array with
a compact bitset, preserves ascending row-order output, and allocates
the result slice to its exact match count. It also adds a regression
test that checks combined searches do not allocate a block-sized marker
array.

Tests:

- `go test ./pkg/objectio -count=1`

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
VioletQwQ-0 pushed a commit to VioletQwQ-0/matrixone that referenced this pull request Sep 17, 2026
## What type of PR is this?

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

## Which issue(s) this PR fixes:

Fixes matrixorigin#28609

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

`ReadFilterSearch` used one `int64` marker per source row when merging
multiple filter terms. For large object blocks this created substantial
allocation churn and GC CPU. This PR replaces the row marker array with
a compact bitset, preserves ascending row-order output, and allocates
the result slice to its exact match count. It also adds a regression
test that checks combined searches do not allocate a block-sized marker
array.

Tests:

- `go test ./pkg/objectio -count=1`

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
VioletQwQ-0 pushed a commit to VioletQwQ-0/matrixone that referenced this pull request Sep 17, 2026
## What type of PR is this?

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

## Which issue(s) this PR fixes:

Fixes matrixorigin#28609

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

`ReadFilterSearch` used one `int64` marker per source row when merging
multiple filter terms. For large object blocks this created substantial
allocation churn and GC CPU. This PR replaces the row marker array with
a compact bitset, preserves ascending row-order output, and allocates
the result slice to its exact match count. It also adds a regression
test that checks combined searches do not allocate a block-sized marker
array.

Tests:

- `go test ./pkg/objectio -count=1`

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
XuPeng-SH added a commit that referenced this pull request Sep 23, 2026
…xes (#29292)

## What type of PR is this?

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

## Which issue(s) this PR fixes:

References #28530 and #28609. Backports #28799 and #28610 to `4.2-dev`.

The mpool change remains a scoped mitigation, not a claim that all costs
in #28530 are eliminated.

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

Backports two already-merged main fixes onto `4.2-dev` at
`7a68d42c4ec151f9af5890ee56b4d24afd87b843`, preserving original authors
and `cherry-pick -x` provenance:

1. **#28610** (`6ad98a5f5e8cbfd8f328836676f2186bfa2e09c7`): replace the
multi-term `ReadFilterSearch` int64-per-source-row marks with a compact
bitset and allocate the result to its exact size. Preserve
deduplication, ascending row order, and the existing single-term and
malformed-input paths. Include the allocation regression test.
2. **#28799** (`14e457608003381ef409fbf0c475e0a931633a28`): record
conservative per-pool pointer-shard hints and restrict destroy-time
on-heap ownership scans to those shards. Registry maps remain
authoritative; free does not clear hints; noLock pools and public
`OnHeapOutstanding()` behavior are unchanged. Include the
correctness/concurrency tests and scale benchmark.

### Release-branch adaptations

- Resolve the objectio import conflict by adding only `math/bits`;
unrelated main-only imports/implementations are not brought over.
- Omit the unrelated
`pkg/tests/issues/issue_277xx_ddl_consistency_test.go` adjustment
bundled with #28799: that test does not exist on `4.2-dev`. Keep all
direct mpool regression coverage.
- Preserve the release branch's existing allocation-account/lease
implementation. Accounted allocations are off-heap and do not require
on-heap hints.

Only four files change. No catalog/schema migration, configuration, wire
or on-disk format, dependencies, or CI workflow changes. No changes to
release tags or running deployments.

### Validation

Fresh local validation on Go 1.26.4, Darwin/arm64:

- `GOWORK=off go list -mod=readonly ./pkg/common/mpool ./pkg/objectio`:
PASS.
- `GOWORK=off go test -mod=readonly -count=1 -timeout=120s
./pkg/common/mpool`: PASS.
- `GOWORK=off go test -mod=readonly -race -json -count=1 -timeout=240s
./pkg/common/mpool`: PASS (full package).
- Repository `mo-cgo-test` wrapper, each with `-race -count=100
-timeout=120s`: PASS for `TestOnHeapShardHintsAreConservativeAndExact`
and `TestOnHeapShardHintsConcurrentPublicationAndCrossPoolFree`. Initial
JSON durations were below timer resolution; the adaptive budget
therefore used N=100.
- `.agents/skills/mo-dev/scripts/mo-cgo-test -v -count=1 -timeout=180s
./pkg/objectio`: PASS (full package, including allocation and legacy
predicate equivalence regressions; also a consumer of mpool).
- `go build -mod=readonly` and `go vet -mod=readonly` for both owning
packages with `GOWORK=off` and repository-local native include/library
paths: PASS. Native prerequisites were built from this worktree's
bundled thirdparty sources and CGo sources.
- `git diff --check` and `gofmt -l` for all four changed files: PASS.
- Self-review: exact ownership diagnostics, monotonic atomic hint
publication, cross-pool frees, fixed-size hint storage, bitset bounds,
result order and release-branch adaptations checked. No additional
lifecycle, external wait or persistent state introduced.

Full distributed BVT, end-to-end QA profiling and new performance
benchmarks were not run for this backport. CI remains required; no
end-to-end latency improvement is claimed from these unit tests.

---------

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Co-authored-by: XuPeng-SH <[email protected]>

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/bug Something isn't working size/S Denotes a PR that changes [10,99] lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

IDC-MO: ReadFilterSearch multi-term filtering causes excessive allocation and GC CPU

3 participants