Skip to content

perf(scan): filter cached fixed-width columns before materialization - #31785

Merged
mergify[bot] merged 19 commits into
matrixorigin:mainfrom
aunjgr:perf/exact-cached-scan-filter
Nov 1, 2026
Merged

mergify[bot] merged 19 commits into
matrixorigin:mainfrom
aunjgr:perf/exact-cached-scan-filter

Conversation

@aunjgr

@aunjgr aunjgr commented Oct 29, 2026 •

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:

Related to #30850; the broader materialization/performance acceptance task remains open.

Qualified full SF10 screen, independent Q18 confirmation, raw timings and resource receipts.

Design and ownership contract.

What this PR does / why we need it:

Evaluate admitted exact residual predicates while ObjectIO holds the existing column-cache lease, then materialize surviving physical rows into owned vectors once. This removes intermediate Boolean vectors and repeated materialization/shrink work for compound fixed-width predicates.

Compile complete ordered conjunctions of same-type integer, DATE and Decimal64 comparisons against resolved literals. BETWEEN inside a compound filter lowers to two comparisons. A standalone native BETWEEN stays on its existing fused vector evaluator: it already has one value pass, so replacing it adds selection/gather work rather than removing repeated predicate passes.

Preserve NULL truth, tombstones, physical row order, destination allocation/metadata and immutable cache input. Keep borrowed views private to ObjectIO and bound scratch to one block per sequential reader, released on reset/free. Unsupported expressions/representations, varlen projections, appendable blocks, rowid output and Top-K retain generic evaluation. Read/cache policy, SQL planning, stored formats and memory limits retain their existing owners.

Validation

The existing admission fixture verifies standalone native fallback, retained compound BETWEEN in separate-expression and AND forms, scan Prepare, nil/unsupported input, and existing reset/reuse. The table_scan owning package passes in default/v1 Go mode (0.093s); scoped configured vet/lint and the full latest-main pre-push gate pass with zero findings. The normal publication binary passes the existing SQL BVT twice on one owned instance, with teardown and SIGINT shutdown verified. The coverage failure was a five-minute admission wait in the upgrade fixture before any service started. Admission now uses test cancellation; each admitted SQL/recovery phase retains its five-minute work budget. All seven existing upgrade scenarios pass in coverage mode on the merged delivery head (71.281s). Existing ObjectIO/cache ownership checks are reused for unchanged code.

Performance evidence and limits

Matched local warm SF10 comparisons use Go1.27.1 SIMD/v3/alignment64 with identical release metadata, eight physical CPUs, effective16GiB CN cache and32GiB whole-application budget. Cold calls are excluded; scripts execute/drain without input/schema/table/row/reference/result/checksum verification. Measurement metadata stays in RAM until after capture, with unchanged CPU/compiler/I/O/spill/swap/OOM/pressure/pinning gates.

The qualified full Q1–Q22 SF10 screen retained three complete process pairs, five warm calls/query/arm. Q6, Q14 and Q15 have paired latency reductions of 36.46%, 21.99% and 29.21%. Q7 is +0.82%, with an observed pair range −4.71% to +13.47%; it remains inconclusive, without an equivalence or speedup claim. The screen’s Q18 +1.65% signal did not reproduce in four new balanced pairs with 16 warm calls/arm: +0.03%, small-sample interval −1.03% to +1.85%. Campaigns are reported separately, without pooling.

Real-Q7 profiling verifies the native BETWEEN/evalFilter path instead of exact-filter selection/gather. The experimental single-pass range kernel did not meet the longer Q7 check and was reverted. No unmerged selected-copy dependency is included.

The earlier full-suite attempts were resource-invalid. A runtime mmap trace exposed dynamically loaded libraries missing from the initial software pin set. Pinning the complete observed closure for both arms closed that measurement gap without relaxing limits. All eight new full-screen arms had zero physical I/O, spilling and swap; one whole pair was excluded for background CPU. The remaining sample size limits precision. No SF100/mixed-I/O acceptance or issue closure is claimed; a confirmed regression cannot be waived by gains elsewhere. External performance reassessment remains required.

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

@aunjgr

aunjgr commented Oct 30, 2026

Copy link
Copy Markdown
Contributor Author

The failed UT and coverage producer shared one accounting defect: a fallback with a complete nonnil column list was treated as a partial read, causing EXPLAIN ANALYZE to count surviving rows a second time. b531bd1 corrects the classification and extends the existing four-row test to preserve returned values and exact input row/byte counts.

The failing persisted prepared-DML case now passes in CI's v1/default Go mode with matrixone_test and coverage instrumentation; cached-reader consumers and full pre-push SCA pass locally. Upstream's temporary frontend enum compile break was reproduced on clean main and repaired by merging its published fix. Published head is 8dda3d8; fresh CI is running.

Q7 performance acceptance remains blocked. The previously posted latency results belong to a4c1bc9/1c80f16a2b and are not presented as measurements of the newly merged head.

@aunjgr

aunjgr commented Oct 30, 2026

Copy link
Copy Markdown
Contributor Author

Implemented the admission repair in 9b78b29242 (published head dedb4595c215857aa5ddb64c3e250365ad1a94da). A lone native BETWEEN already has one fused value pass, so it now retains its existing evaluator; larger admitted conjunctions, including compound BETWEEN, retain the cached exact path. The unsuccessful range experiment was reverted and the selected-copy probe is not included. No query-specific gate, threshold tolerance or configuration escape hatch was added.

Source-scoped evidence and raw execution/qualification receipts provide the current-head/current-main Q7 comparison and Q6/Q14 controls. All retained target arms pass the original gates. Q7 remains statistically inconclusive (+2.96%, observed three-pair range−1.26% to+9.30%); Q6−32.92%,Q14−19.21%. Prior-base Q7 confirmation is reported separately. This is not an equivalence or whole-suite PASS claim. The final full screen remains unqualified due host paging/reclaim and is explicitly left open; no regression is waived by gains elsewhere.

The owning tests, full pre-push SCA and final-binary two-run SQL BVT pass. Please reassess the implementation and scoped evidence; the broader issue is not being closed.

@aunjgr

aunjgr commented Oct 30, 2026

Copy link
Copy Markdown
Contributor Author

The new measurements and coverage repair are ready for reassessment.

  • Full warm SF10 Q1–Q22 table, source/ELF identities, raw timings and per-arm resource receipts: three qualified full-suite process pairs, with Q6 −36.46%, Q14 −21.99% and Q15 −29.21%. Q7 +0.82% remains inconclusive, with a −4.71% to +13.47% observed pair range; no equivalence/speedup claim. The screen's Q18 +1.65% signal was checked independently with four new balanced pairs and 16 warm calls/arm: +0.03%, interval −1.03% to +1.85%, no consistent slower signal. No campaign pooling or favorable-average waiver.
  • The earlier full-suite resource gap came from runtime-loaded libraries outside the initial software pin set. Both arms now pin the complete observed closure and account for its bytes under the same application limit. All eight new full-screen arms have zero physical I/O, spill and swap; one whole pair is excluded by the unchanged background CPU gate. SF100/mixed-I/O acceptance and issue closure remain open.
  • Coverage job failure was TestColumnsUpgradeInterruptedRouteResumes timing out after 4m59.999s in cluster admission, before service startup. Commit 3409427e9e separates test/job-bounded admission from five-minute SQL/recovery phase budgets. Pool capacity/exclusion, production lifecycle code and all scenario assertions remain unchanged. All seven existing upgrade scenarios pass in coverage mode on the merged delivery head: 71.281s. No new fixture or admission bypass.

Main is merged through c42cf40214; final source head is a4cd90fca9d853dae63d80001cd8616460b477d9. The performance capture retains explicit baseline d1594899b7 / candidate dedb4595c2 identities; the later test-only fix and common-main catalog/DML-target changes do not change the measured scan/reader/native BETWEEN/aggregate execution closure. These are reused source-pinned measurements, not a claim to have rebuilt and benchmarked the later merge. Full pre-push SCA passes; fresh CI applies to the new head.

…can-filter

# Conflicts:
#	pkg/embed/upgrade_metadata_cdc_test.go
#	pkg/embed/upgrade_metadata_test.go
@aunjgr

aunjgr commented Nov 1, 2026

Copy link
Copy Markdown
Contributor Author

Resolved the conflicts by merging main c7d7536bda into d8443d85765fd6f45d06de581da87c369f506ab9.

Retained main’s renamed/consolidated metadata-upgrade fixtures and its recovery admission-budget handling. The earlier shared-test repair now leaves no embed-test delta in this PR. The scan-filter changes and main’s restored long-scan cache policy are preserved.

The affected owning/consumer checks already passed. The required pre-push static gate passed with zero findings. Further benchmark verification was stopped at the requester’s instruction; this merge makes no new performance acceptance claim. Fresh CI is running on the new head.

@XuPeng-SH

XuPeng-SH commented Nov 1, 2026 •

Copy link
Copy Markdown
Contributor

mo-bot review · mo-bot-local · done

Commit: d8443d85765fd6f45d06de581da87c369f506ab9

Review completed. Read the assessment.

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

mo-bot review · mo-bot-local · review

Commit: d8443d85765fd6f45d06de581da87c369f506ab9

Assessment: approve

No actionable defects remain. Preserving native standalone BETWEEN and the qualified follow-up evidence resolve the prior Q7 concern for this scoped optimization.

Model: gpt-6-astra / xhigh

Session: 01a1869d-820c-7212-9788-aecfb86a4141 · slot 0 · generation 2

Validation:

  • Reviewed all 22 changed files, affected owners and consumers, linked issue context and nine discussion entries. Saved review-plan.md and discussion-assessment.json.

  • All six affected package suites passed normally and under -race with vet enabled. Receipts: checks/1793541017598450797-3.json and checks/1793541139730575788-3.json. Retained logs: owners-normal.stdout.log and owners-race.stdout.log.

  • Isolation preflight, native provenance and source audits passed. validation-audit.json reconciles commands, source fingerprints, terminal results and logs. Source remained unchanged.

  • Recalculated supplied benchmark timings and checked semantic source continuity; see performance-audit.json. Frozen HEAD CI reports successful build, UT, coverage, SCA and multi-CN BVT.

Limitations:

  • Performance measurements belong to supplied revisions dedb459/d1594899, not this HEAD. Q7 remains inconclusive; no new benchmark or SF100/mixed-I/O acceptance is claimed.

  • SQL/topology validation relies on frozen CI statuses and supplied reports; no local BVT was run.

@mergify mergify Bot added the queued label Nov 1, 2026
@mergify
mergify Bot merged commit 0df8dde into matrixorigin:main Nov 1, 2026
@mergify

mergify Bot commented Nov 1, 2026

Copy link
Copy Markdown
Contributor

✅ Merged into main as 0df8dde at 13:55 UTC

Less than a minute in the queue, with no time running CI.

So far

  • ✅ Entered the queue Sun 1 Nov, 13:55 · rule main · triggered by rule Automatic queue on approval for main
  • ✅ Checks skipped · PR is already up-to-date
  • ✅ Merged 13:55 · 0df8dde · squash
3 merge conditions met
  • #review-threads-unresolved = 0 · required by GitHub branch protection
  • github-review-approved · required by GitHub branch protection
  • any of · required by GitHub branch protection:
    • check-success = CI Required
    • check-neutral = CI Required
    • check-skipped = CI Required

Times in UTC · dashboard · how the merge queue works

This branch was previously deployed

1 inactive deployment
ci — d8443d85 Deployed Nov 1, 2026 by aunjgr
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kind/enhancement size/XL Denotes a PR that changes [1000, 1999] lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants