Skip to content

Remove per-row boolean wrapper calls from inline scan filters - #31306

Merged
XuPeng-SH merged 5 commits into
matrixorigin:mainfrom
aunjgr:perf/scan-bool-selection
Oct 27, 2026
Merged

XuPeng-SH merged 5 commits into
matrixorigin:mainfrom
aunjgr:perf/scan-bool-selection

Conversation

@aunjgr

@aunjgr aunjgr commented Oct 26, 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 and #30838.

What this PR does / why we need it:

Inline table-scan filters currently fetch every boolean through a cached generic wrapper, including a per-row interface call. Read the already-evaluated flat boolean slice once, split nullable/non-nullable selection loops once per vector, and check null bits only for true values. Keep the existing wrapper behavior for constant results.

Preserve stable row order, SQL UNKNOWN rejection, predicate/error order, eager compaction and late-materialization original-row mappings. The expression executor still owns the result; the slice is borrowed only during the current filter call. Selection pooling, allocation accounting and cleanup retain their existing owners.

Validation: full table_scan/readutil suites; empty/tiny/boundary masks, true/false/NULL, constants and representation reuse, eager/late mappings, and short-circuit error order; 81 statements across three existing SQL fixtures. The maintained owner benchmark includes mask restoration and shows unchanged allocation counts. Independent SF10 Q1-Q22 timings and separate Q4/Q6/Q12/Q19 profiles use a configured/observed 16 GiB CN cache and a 32 GiB whole-application budget, excluding cold runs and requiring zero measured I/O/spill/swap. In the complete SF10 comparison, paired latency improves 5.51% on Q4, 10.17% on Q6 and 5.16% on Q12; none of Q1-Q22 has a slowdown signal. Q19's 3.14% lower point estimate remains inconclusive. Separate Q4 profiling attributes a 33.77% reduction to boolean access plus selection, with 6.43% fewer whole-application instructions. Exact measured commits, intervals and resource receipts are reported separately.

@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 26, 2026

Copy link
Copy Markdown
Contributor Author

Independent SF10 acceptance: main ccfca4f7fd, candidate f49472fb3f

This branch contains only the scan selection change. It contains neither #31034 nor the shuffle candidate, and uses normal default-alignment builds with matching GOAMD64=v3/GOEXPERIMENT=simd and source-validated native artifacts. No PGO or production source overlay.

Six balanced fresh-process pairs; three scored warm executions of every unchanged Q1-Q22 per process. Cold warmups excluded. Paired bootstrap intervals resample process blocks. Every slower signal would require independent confirmation and block publication; no average offsets regressions.

Query Main, s Scan, s Paired change Paired 95% interval
Q1 1.469384 1.456328 -0.74% [-3.40%, +0.92%]
Q2 0.053836 0.050823 -4.61% [-17.58%, +4.52%]
Q3 0.412941 0.410960 -4.69% [-10.75%, +2.48%]
Q4 0.322416 0.304788 -5.51% [-7.18%, -4.70%]
Q5 0.386307 0.376816 -1.72% [-6.94%, +1.41%]
Q6 0.241769 0.225364 -10.17% [-13.90%, -4.07%]
Q7 0.379549 0.360055 -5.42% [-7.48%, -2.02%]
Q8 0.357115 0.356871 -2.68% [-5.60%, +4.31%]
Q9 0.738973 0.739417 -1.43% [-7.79%, +0.06%]
Q10 0.612315 0.595959 -4.39% [-6.76%, +1.03%]
Q11 0.097038 0.094198 -1.56% [-5.30%, +1.13%]
Q12 0.460230 0.440094 -5.16% [-9.51%, -0.19%]
Q13 0.354848 0.349628 -3.13% [-11.66%, +5.08%]
Q14 0.260037 0.236942 -7.07% [-15.37%, -4.56%]
Q15 0.461530 0.426349 -7.40% [-9.17%, -5.85%]
Q16 0.139703 0.131851 -3.79% [-12.35%, +1.52%]
Q17 0.278659 0.255798 -8.20% [-15.61%, -5.58%]
Q18 1.223058 1.161322 -5.25% [-20.72%, +2.08%]
Q19 0.623171 0.605581 -3.14% [-9.20%, +0.99%]
Q20 0.399323 0.366067 -6.92% [-15.80%, -5.58%]
Q21 1.491806 1.451588 -2.23% [-9.40%, +0.14%]
Q22 0.115160 0.111533 -4.05% [-6.56%, +1.36%]

Q4, Q6 and Q12 have improvement signals. Q19 has a −3.14% point estimate with a [−9.20%, +0.99%] interval, so it is not counted as a demonstrated gain. None of all22 has a slowdown signal.

All 12 latency arms and 8 separate profile arms passed the all-memory gates: configured/observed CN SHARED cache 16 GiB, CPUs0-7 physical, controller8-15, whole-application cap32GiB including private native image and pinned software, no swap, spill budget2GiB. Measured physical reads/writes, spill events, swap and OOM are zero; no sustained memory pressure. The largest conservative application footprint is 23.95GiB.

Separate Q4 profile (100 warm calls per build, timings excluded from latency scoring):

Metric per call Main Scan Change
Sampled boolean access + evalFilter exclusive CPU, ms 272.222 180.303 -33.77%
Whole-application cycles:u 10313422304 9574368128 -7.17%
Whole-application instructions:u 27069320605 25330027259 -6.43%

The boolean wrapper leaf disappears; date-value wrappers remain and are not claimed as removed. The selected CPU figure combines the boolean wrapper with evalFilter so moving work between the two cannot create an apparent saving. PMU counters were not multiplexed. Q6/Q12/Q19 profiles are also retained separately.

The maintained complete-owner benchmark includes the identical bounded mask restoration in both builds. Six balanced process pairs discard the first result per case/process: mixed/all-true 256/8192-row cases improve about52–61%, nullable about15–16%; all-false about73–84%. All allocation counts and bytes are unchanged, and constant negative controls have no slowdown signal.

Correctness: full table_scan and readutil suites; empty/tiny/boundary, true/false/NULL/constant masks, eager and late original-row mappings, class reuse and error short-circuiting. Existing inline_filter, pk_filter_nested_boolean and decimal_bool_context SQL fixtures pass81/81 statements. No dataset/schema/row-count/checksum/result verification is performed by the benchmark scripts. SQL result assertions exist only in separate correctness fixtures.

The final delivery head 5dc4952077 merges main's CREATE TASK database guard. That path is not exercised by this SELECT-only campaign; all four files in the measured scan change are byte-identical. Functional evidence is reused for the unchanged scan/reader closure, and the full standard pre-push/static gate runs on the delivery head. No new post-merge timing run is claimed.

Artifacts retained locally under build/independent-scan-shuffle-wave: scan-sf10/{sources.json,protocol.json,jobs.json,timing-analysis.json,verdict.json}, per-arm resource/cache/completion/compiler-monitor receipts and exact binary identities, eight perf.record/perf.stat pairs, scan-mask-attribution.json, scan-owner/{analysis.json,samples.json,quality.json}, owning-suite logs and scan-sql/verdict.json.

@XuPeng-SH

XuPeng-SH commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

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

Commit: 5dc495207781d0cda1acee0b57bd75d7da3a08bf

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: 5dc495207781d0cda1acee0b57bd75d7da3a08bf

Assessment: request_changes

The complete four-file implementation review found no correctness defect. Direct selection fits the existing owner and preserves null semantics, ordering, compaction, cleanup and late-materialization mappings. Both owning suites passed. Approval remains blocked only on reconciling the required performance evidence; the author's reported results and source applicability were assessed, but the underlying campaign artifacts were unavailable.

Model: gpt-6-astra / xhigh

Session: 01a13dcf-1517-7f90-b3f9-c5f9f9e7031b · slot 0 · generation 1

  • P2 pkg/sql/colexec/table_scan/table_scan.go:352: Accepting this hot-path optimization under the performance gate documented in docs/design/scan-bool-selection.md:19.
    Impact: Validation requirement: provide access to the already-retained campaign's source/binary identities, terminal receipts, timing samples, resource records and profile/PMU evidence. Reconcile target gains, full-query regression results and allocation/resource gates before approval. A new campaign is unnecessary if the existing artifacts qualify.
    Evidence: issue_comments:6420582925 reports substantial gains and names build/independent-scan-shuffle-wave artifacts, but evidence.json.local_validation is empty and the referenced artifact directory was absent from 105 checked existing checkout roots. The report therefore cannot be reconciled to its underlying executions. Source audit confirms all four measured files match this head and the intervening merge only changes CREATE TASK. Passing functional tests cannot establish performance acceptance. See source-evidence-audit.json, validation-audit.json and discussion-assessment.json.

Validation:

  • Full table_scan and readutil suites passed: 136 top-level tests, including mask boundaries, constant/flat representation reuse, error ordering, chained filters and original-row mappings. Receipt: checks/1793033839129796038-3.json; retained output: owner-tests.log.

  • Isolation preflight passed. Native prerequisites were built through the repository owner and subsequently verified against clean-head source inputs and artifact bytes: checks/1793033773180333151-3.json.

  • Verified measured-source equivalence and read the complete frozen discussion. discussion-assessment.json covers all three nonempty items exactly once.

  • Final evidence audit passed with the frozen source unchanged: checks/1793034104949204015-4.json. Artifact hashes are retained in review-artifact-inventory.json.

Limitations:

  • Reported Q4/Q6/Q12 gains of 5.51%/10.17%/5.16%, unchanged allocations and profile reductions remain author-reported measurements. Q19's inconclusive result is explicitly acknowledged; no regression is inferred.

  • SF10 and SQL fixtures were not rerun locally. Frozen exact-head UT, SCA and multi-CN/PROXY BVT statuses are successful, but raw CI logs were not supplied.

  • Implementation and test review is complete; performance-artifact reconciliation is the remaining acceptance work.

@aunjgr

aunjgr commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor Author

Correction to the evidence description — 2026-10-27: The historical query worker f881dfc604c11c29067ec5ccfcabbeeb357f40bc did validate declared schemas and query metadata and normalized, counted, serialized and SHA-256-hashed results inside the timed window (legacy manifest checks and timed result capture). The release guide's statement that its scripts performed no schema or result-checksum work is incorrect. The selected replay did not compare rows to a reference or re-verify input tables. Its timing includes client result capture, and the magnitude of that cost has not been isolated. The existing evidence remains historical; an execution-and-drain-only rerun is required for that protocol.

Address P2: the retained campaign is now publicly auditable

The complete retained evidence is available in the PR31306 scan evidence release. All46 compressed data files are separate assets, with an integrity ledger, audit guide and executable offline reconciliation. There is no new campaign or code change in this response.

Start with:

The release also has one complete receipts asset for each of20 accepted arms, and eight independently compressed full symbolized perf-script profiles with their separate PMU files. They retain sampling periods, symbols, IPs and call paths; reading them does not require the original local checkout paths. Terminal results, cleanup, resource/cache/spill/host records and worker/software identities are included.

To reconcile without running MO:

gh release download scan-31306-5dc4952077-20261027 --repo aunjgr/mo-tpch-profiles --dir scan-evidence
cd scan-evidence
sha256sum -c SHA256SUMS
python3 audit.py

The recorded offline audit passes:46 compressed identities,20 terminal/resource receipts, all22 paired query intervals reconstructed from execution receipts,12 owner allocation/byte controls, and the Q4 exclusive boolean-wrapper plus evalFilter CPU figure recomputed from the complete symbolized profiles. The largest conservative application footprint is23.95GiB. Deferred cleanup symbols are distinct and excluded from that explicitly stated exclusive-function metric.

The measured main is ccfca4f7fd, candidate f49472fb3f, and delivery 5dc4952077; the source hashes and the review's source audit establish all four candidate files are identical after the CREATE TASK merge. Q4/Q6/Q12 gains, inconclusive Q19 and positive point estimates remain as reported; no new-head timing claim or averaging away of a regression is introduced. Cold warmups and profile timings stay excluded, and the offline audit checks execution metadata rather than TPC-H input or query values.

This addresses the artifact-access gap in the current review. Please reconcile the existing campaign against these assets; implementation and test scope remain unchanged.

@aunjgr
aunjgr requested a review from XuPeng-SH October 26, 2026 18:33
@XuPeng-SH

XuPeng-SH commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

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

Commit: 5dc495207781d0cda1acee0b57bd75d7da3a08bf

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: 5dc495207781d0cda1acee0b57bd75d7da3a08bf

Assessment: approve

Reviewed the complete four-file delta and frozen discussion. Direct boolean selection fits the existing scan owner and preserves NULL semantics, ordering, cleanup and late-materialization mappings without new state or allocations. Independent reconciliation of the published campaign resolves the earlier performance-evidence blocker. No actionable findings remain.

Model: gpt-6-astra / xhigh

Session: 01a13dcf-1586-7a01-9000-d45e20995cf8 · slot 1 · generation 1

Validation:

  • Full table_scan and readutil suites passed: 136 top-level tests, no failures or skips. Receipt: checks/1793040869979975936-2.json; output: owning-tests.log.

  • Isolation preflight passed. Matching native prerequisites were built through make cgo and verified against 194 frozen-source inputs; native-inputs.json and native-outputs.json retain provenance.

  • Independent campaign audit passed: 46 compressed assets, 20 execution/resource receipts, all 22 paired query intervals, 12 owner controls and eight profiles. Receipt: checks/1793040825748939604-2.json; details: independent-campaign-audit.json.

  • Reproduced Q4/Q6/Q12 improvements of 5.51%/10.17%/5.16%, Q4 selected-mask CPU reduction of 33.77% and whole-application instruction reduction of 6.43%. Owner allocations were unchanged; no query had a slowdown signal.

  • Verified observed 16 GiB CN cache, 32 GiB application limit and zero measured physical I/O, spill, swap and OOM across all 20 arms. Maximum conservative footprint was 23.95 GiB.

  • Measured scan files match delivery exactly; intervening changes only add an unrelated CREATE TASK guard. Retained separate SQL evidence reports 81 passing statements.

  • discussion-assessment.json accounts for all six nonempty discussion items. Final receipt/log reconciliation and unchanged-source audit passed: checks/1793041027648626504-2.json, final-audit.log and validation-audit.json.

Limitations:

  • SF10 and SQL campaigns were reused, not rerun locally. Q19 remains inconclusive; six process pairs do not establish universal absence of regressions.

  • Profiles were audited from full symbolized streams and PMU logs; original perf.record binaries were not supplied. Empty/one-row benchmarks were not separately scored.

  • Frozen CI statuses support UT/SCA/BVT success, but raw CI logs and full linked-issue bodies were not supplied; contract assessment uses the frozen PR discussion and design document.

@mergify mergify Bot added the queued label Oct 26, 2026
@mergify

mergify Bot commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

Merge Queue Status

  • ✅ Entered queue — 2026-10-26 18:58 UTC · Rule: main · triggered by rule Automatic queue on approval for main
  • 🚫 Left the queue — 2026-10-26 18:58 UTC · at 5dc495207781d0cda1acee0b57bd75d7da3a08bf

This pull request spent 18 seconds in the queue, with no time running CI.

Reason

The pull request can't be updated

GitHub response: refusing to allow a GitHub App to create or update workflow .github/workflows/ci-scope-check.yml without workflows permission
GitHub only lets Mergify write to .github/workflows/ with the workflows permission. An organization owner can accept Mergify's pending permissions at https://dashboard.mergify.com/orgs/matrixorigin/repositories.

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.

Requeued — the merge queue status continues in this comment ↓.

@mergify mergify Bot added dequeued and removed queued labels Oct 26, 2026
@mergify

mergify Bot commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

Merge Queue Status

  • ✅ Entered queue — 2026-10-26 19:14 UTC · Rule: main · triggered by @aunjgr with the merge queue checkbox
  • 🚫 Left the queue — 2026-10-26 19:15 UTC · at 5dc495207781d0cda1acee0b57bd75d7da3a08bf

This pull request spent 52 seconds in the queue, with no time running CI.

Reason

The pull request can't be updated

GitHub response: refusing to allow a GitHub App to create or update workflow .github/workflows/ci-scope-check.yml without workflows permission
GitHub only lets Mergify write to .github/workflows/ with the workflows permission. An organization owner can accept Mergify's pending permissions at https://dashboard.mergify.com/orgs/matrixorigin/repositories.

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

@mergify mergify Bot added the queued label Oct 26, 2026

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