Skip to content

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

Closed

Description

@gouhongshen

Is there an existing issue for performance?

  • I have checked the existing issues.

Environment

  • MatrixOne image: v4.2.1-d2393868a-2026-08-28
  • Commit: d2393868a7aaa6343518d80849fe4696aa3577e9
  • Deployment: two CNs serving the MOI QA multi-tenant workload
  • Runtime settings observed in the affected CN: GOMEMLIMIT=35GiB, GOGC=100

Details of Performance

A 20-second alloc-space delta profile on an affected CN recorded approximately 11.6 GiB of allocations. Approximately 8.4 GiB (72%) was attributed directly to:

github.com/matrixorigin/matrixone/pkg/objectio.(*ReadFilterSearch).search
pkg/objectio/constructors.go:379

The corresponding implementation allocates a full-length []int64 whenever a search contains multiple terms:

marks := make([]int64, source.Length())

Each element is only used as a boolean mark. Consequently, every evaluated source vector allocates eight bytes per source row regardless of the number of matching rows. High-fanout filtered queries across many tenant databases amplify this into hundreds of MiB of short-lived allocations per second.

Observed during the same period:

  • Allocation rate: approximately 595 MiB/s.
  • Allocation at ReadFilterSearch.search: approximately 430 MiB/s.
  • Live heap after GC: approximately 3.5–5 GiB; GC goal approximately 7–10 GiB, well below GOMEMLIMIT.
  • GC cycles occurred roughly every 8–12 seconds, with concurrent marking lasting approximately 1–4.7 seconds per cycle.
  • CPU profiles during the workload showed a material share of CPU consumed by Go GC, affecting latency of unrelated foreground SQL.

This is not an out-of-memory-limit-driven GC problem. The immediate cause is sustained allocation churn, dominated by the full-source-length []int64 marks allocation.

Expected behavior

Multi-term cached-vector filtering should not allocate one int64 per source row for every search. The implementation should preserve ordering and deduplication semantics while using a compact/reusable representation, such as a bitmap/bitset, pooled scratch storage, or a merge strategy whose memory is proportional to matches.

A regression benchmark should cover multi-term searches over large vectors and assert both result correctness and bounded allocations.

Additional information

The MOI workload contains avoidable cross-workspace background scans and should be optimized independently. However, the allocation profile identifies a concrete amplification point inside MatrixOne: the same query volume should not require approximately 8.4 GiB of temporary int64 marks in 20 seconds. The same full-length marks implementation is also present on current main.

Activity

  1. self-assigned this
    on Sep 10, 2026
  2. added
    severity/s0
    and removed on Sep 10, 2026
  3. added a commit that references this issue on Sep 10, 2026
    6ad98a5
  4. added 3 commits that reference this issue on Sep 17, 2026
    a47cb3a
    0591182
    672abd5
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

area/performancekind/performanceseverity/s0

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions