Skip to content

perf(vector): hoist narrow selection destination bounds - #31620

Merged
XuPeng-SH merged 14 commits into
matrixorigin:mainfrom
aunjgr:perf/typed-narrow-selection
Oct 30, 2026
Merged

XuPeng-SH merged 14 commits into
matrixorigin:mainfrom
aunjgr:perf/typed-narrow-selection

Conversation

@aunjgr

@aunjgr aunjgr commented Oct 28, 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 #30845. This is the selected-copy component; the broader materialization issue remains open.

Final results, uncertainty and revised acceptance.

What this PR does / why we need it:

For flat, non-NULL four/eight-byte values, Vector.Union and UnionInt32 copy the first selected row through checked scalar indexes. A one-row selection is then complete. For further rows, check the last destination byte once and derive row pointers only within that admitted interval. This removes repeated destination checks and avoids helper/slice-header setup on the short selections used by joins, while retaining source-index checks and copy order.

Fixed constants reuse one checked append window for the first-value copy and existing doubling broadcast. Allocation/preflight, destination prefixes, NULL/grouping/provenance and length publication retain their existing owner. The existing selection test now covers additional logical types and floating-point NaN/signed-zero bits, both selector widths, windows, repetitions, prefixes and self-append through growth.

The inline comment distinguishes payload widths from selected-row counts. This change introduces no public API, dependency or build-option change.

Validation and performance

This component PR requires measured component gains and no confirmed PR-caused TPC-H regression. A query-level speedup is not claimed.

  • Vector package, focused checkptr and BatchSet consumers passed; unchanged evidence was reused.

  • Focused matched controls show component gains and no confirmed slowdown. Generated owner frames are eight bytes smaller.

  • The completed Q1–Q22 screen measures the preceding bounded-loop variant; the subsequent constant/first-row corrections have focused component and Q21 A/A/B coverage. Q21 is inconclusive: +1.51%, 95% interval −6.48% to +1.73%; identical-baseline variation is disclosed. This is not proof of equivalence or a TPC-H speedup claim.

  • Local comparison only; cache 16 GiB, whole-application budget 32 GiB, cold runs excluded. Benchmark results are consumed without input/result verification.

  • Final repository pre-push SCA passed, including molint, license checks and full golangci-lint (zero findings).

@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 commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

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

Commit: a5580c963fa531bf945b69992cae11413ef72885

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: a5580c963fa531bf945b69992cae11413ef72885

Assessment: request_changes

The specialization preserves existing ownership and copy semantics. One scoped performance-validation requirement remains incomplete; no correctness regression was established.

Model: gpt-6-astra / xhigh

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

  • P2 docs/design/tpch-narrow-selected-copy.md:67: The scoped acceptance contract requires attributable target-query improvement and controls, but completed comparisons use baseline 6d1f5d7. Subsequent aggregation and integer-cast execution changes materially affect that benchmark boundary.
    Impact: Performance acceptance remains unproven on the updated execution baseline. Finish the existing balanced SF10 Q1–Q22 comparison and relevant target/control confirmation on semantically matching builds, retaining valid completed evidence and reporting uncertainty. This is a validation gap, not a demonstrated slowdown.
    Evidence: The PR body and linked issue #30845 comment 6475102215 explicitly report only one accepted current-baseline process pair and pending current-head acceptance. Frozen history confirms execution changes in group/exec2.go, group/helper.go and function/func_cast.go. Earlier component gains and green functional CI do not establish the required current-baseline query benefit.

Validation:

  • Reviewed the complete three-file delta, selection-test oracles, allocation/metadata owners, typed shuffle, BatchSet, ShufflePool and hash-join consumers.

  • Supplied exact-head CI reports successful build, UT, SCA, coverage and proxy/multi-CN BVT. Author-reported component results were retained within their stated scope.

  • Static audit passed: checks/1793211351136982656-4.json and review-audit.console.log confirm frozen identity, clean source, patch correspondence and complete discussion coverage. Initial newline-only audit mismatch is preserved in checks/1793211317657329811-4.json and review-audit-initial.console.log.

  • Saved review-plan.md, discussion-assessment.json and review-evidence.md in the diagnostic directory.

Limitations:

  • No local Go tests or TPC-H execution; local_validation is empty and raw author benchmark logs were not supplied.

  • Earlier Q7/Q14 slower estimates remain inconclusive, not confirmed regressions. Broader SF100/mixed-I/O issue closure is not independently required for this slice.

@aunjgr

aunjgr commented Oct 28, 2026

Copy link
Copy Markdown
Contributor Author

The performance-acceptance finding remains valid. The semantically matched full Q1–Q22 run and targeted same-binary-controlled follow-up are now complete, but they do not establish the required target-query benefit. A local implementation correction also improves component controls without demonstrating a TPC-H target win, so it has not been pushed. I have left this finding unresolved rather than treating green functional CI or component gains as acceptance.

Detailed evidence: #30845 (comment)

@XuPeng-SH

XuPeng-SH commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

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

Commit: a5580c963fa531bf945b69992cae11413ef72885

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: a5580c963fa531bf945b69992cae11413ef72885

Assessment: request_changes

The existing performance-acceptance requirement remains unmet after completed matched measurements. No separate correctness regression was established.

Model: gpt-6-astra / xhigh

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

  • P2 docs/design/tpch-narrow-selected-copy.md:67: Accepting this performance-only specialization requires an attributable target-query improvement, which the completed published-head/base comparison and follow-up do not establish.
    Impact: Component gains and green functional CI cannot satisfy the scoped acceptance contract. Revise or defer the specialization until a candidate demonstrates the required target gain with relevant controls; retain completed evidence rather than blindly repeating the full campaign.
    Evidence: Issue #30845 comment 6478508972 reports the completed matched screen and A/A/B diagnostic, substantial same-binary variation, and no established target benefit. PR comment 6478510877 explicitly agrees that acceptance remains unresolved. The earlier incomplete-run rationale is superseded; reported slower signals are not proven PR-caused regressions.

Validation:

  • Reviewed the complete delta, copy/metadata/allocation owners, typed shuffle, BatchSet, ShufflePool, hashjoin consumers and test oracles.

  • Supplied exact-head CI reports successful build, UT, SCA, coverage and proxy/multi-CN BVT.

  • Static audit passed: frozen identity, clean source, patch correspondence, formatting and complete discussion coverage. Receipt checks/1793215883026438693-3.json matches review-audit.console.log.

Limitations:

  • No local Go tests or TPC-H execution; raw author benchmark logs were not supplied.

  • The unpushed alternative and historical prototype results do not qualify the assessed head.

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

Style and comment change requests.

Comment thread pkg/container/vector/vector.go Resolved
@XuPeng-SH

XuPeng-SH commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

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

Commit: a5580c963fa531bf945b69992cae11413ef72885

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: a5580c963fa531bf945b69992cae11413ef72885

Assessment: request_changes

The existing performance-acceptance requirement remains unmet. No additional correctness defect was established; the inline-comment request does not create a design-document gate.

Model: gpt-6-astra / xhigh

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

  • P2 docs/design/tpch-narrow-selected-copy.md:67: This performance-only specialization requires attributable target-query improvement under issue #30845 and its scoped acceptance contract.
    Impact: Completed matched measurements still do not establish that benefit. Revise or defer the specialization until a candidate meets the requirement with relevant controls, reusing completed evidence rather than blindly repeating the campaign.
    Evidence: Linked issue comment 6478508972 reports the completed published-head/base comparison and controlled follow-up without established target benefit. PR comment 6478510877 acknowledges the unresolved requirement. The earlier incomplete-run rationale is superseded; slower signals are not proven PR-caused regressions.

Validation:

  • Reviewed the complete delta, copy/allocation/metadata owners, selection tests and BatchSet, ShufflePool and hash-join consumers.

  • Supplied exact-head CI reports successful build, UT, SCA, coverage and proxy/multi-CN BVT.

  • Static audit passed; receipt checks/1793240933846447013-7.json matches review-audit.log. Source remained unchanged; all nine discussion entries were assessed.

Limitations:

  • No local Go tests or TPC-H execution; raw benchmark and CI logs were not supplied.

  • The unpushed alternative does not qualify the assessed head.

@aunjgr aunjgr changed the title perf(vector): specialize narrow selected copies perf(vector): hoist narrow selection destination bounds Oct 29, 2026
@aunjgr

aunjgr commented Oct 29, 2026

Copy link
Copy Markdown
Contributor Author

Updated in d95cfbb. The earlier review correctly identified that the then-required attributable TPC-H gain was unproven. The author has now explicitly revised this component PR criterion: “if no regression, can still commit.” This changes the acceptance requirement; it does not establish a query speedup or waive a demonstrated regression.

The implementation now uses first-row peeling and one tail bounds check rather than the private helper/two-view setup, and fixed constants share one checked output window. The completed full screen is retained as evidence for its measured bounded-loop variant; the subsequent changes have matched component controls and focused Q21 confirmation. No confirmed PR-caused slowdown was established in those final focused checks; Q21 remains inconclusive (+1.51%, 95% interval −6.48% to +1.73%). Measured source pins, same-binary variation, prior signals and evidence-reuse limits are disclosed in the final report. Functional/checkptr/consumer tests and final full pre-push SCA passed. CI on the new head is running.

The requested inline explanation is present and the design document is removed from the PR delta. Issue #30845 remains open for the broader materialization work. Please reassess the new implementation under the author’s revised criterion; the previous CHANGES_REQUESTED reviews have not been dismissed.

#30845 (comment)

@XuPeng-SH

XuPeng-SH commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

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

Commit: d95cfbb0e01ec4de281a1c9c002f949bf05713d7

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: d95cfbb0e01ec4de281a1c9c002f949bf05713d7

Assessment: approve

The optimization preserves selection, payload and ownership contracts. The inline-comment request is resolved. The explicitly revised component acceptance criterion supersedes the earlier target-query-gain blocker; no actionable regression remains.

Model: gpt-6-astra / xhigh

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

Validation:

  • Reviewed the complete two-file delta, allocation/metadata/cleanup owners, BatchSet/ShufflePool and hash-join consumers, and test oracles.

  • Assessed all 14 discussion entries and all five linked-issue comments; saved review-plan.md and discussion-assessment.json.

  • Reused supplied exact-head successful build, Ubuntu UT/coverage, arm64 SCA and proxy/pessimistic multi-CN BVT evidence.

  • Reviewed reported component controls and Q21 follow-up within their stated scope; verified relevant vector inputs remained unchanged across the final merge.

  • Static audit passed: checks/1793267886661627793-2.json matches review-audit.log, confirming frozen identity, clean source, patch correspondence, formatting and discussion coverage.

Limitations:

  • No local Go tests or benchmarks were run; raw author performance artifacts were unavailable.

  • Q21 remains inconclusive, not proof of equivalence or speedup. The full Q1–Q22 screen measured the preceding variant; subsequent corrections have focused reported coverage. Broader issue #30845 remains open.

@aunjgr

aunjgr commented Oct 30, 2026

Copy link
Copy Markdown
Contributor Author

@fengttt Your comment and document requests are implemented in a742b6599e, included in current head d95cfbb0e01ec4de281a1c9c002f949bf05713d7:

  • The inline explanation distinguishes payload widths in bytes from len(sels), the output-row count. One selected row completes after the first checked copy; only additional rows enter the tail loop. case 2 means a two-byte payload and keeps the existing scalar loop; the profiled specialization covers four/eight-byte payloads.
  • The correction commit removes the design document from this PR. The final delta contains only vector.go and the existing selection-test extension.

The inline thread is resolved, required CI is green, and XuPeng-SH approved this exact head. Your review request is pending; please re-review the current implementation. The CHANGES_REQUESTED review remains in place for your decision.

@XuPeng-SH

XuPeng-SH commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor

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

Commit: d95cfbb0e01ec4de281a1c9c002f949bf05713d7

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: d95cfbb0e01ec4de281a1c9c002f949bf05713d7

Assessment: approve

No actionable defects found. Copy bounds, ordering, metadata and ownership remain intact. Inline-comment concerns are resolved; the explicit component scope supersedes the earlier query-speedup requirement.

Model: gpt-6-astra / xhigh

Session: 01a1869d-999c-7481-b340-ae4a63e8cee4 · slot 1 · generation 2

Validation:

  • Reviewed the complete two-file delta, affected owners/consumers and all 17 discussion entries; saved discussion-assessment.json.

  • Static audit passed: frozen patch/head match, clean source, diff checks, gofmt and unchanged relevant inputs across the final merge. Receipt: checks/1793353038436997783-2.json; log: static-audit.log.

  • Reused supplied head-matching successful build, Ubuntu UT/coverage, arm64 SCA and PROXY/PESS multi-CN BVT statuses.

Limitations:

  • No local Go tests or benchmarks executed; raw author performance artifacts and CI test logs were unavailable.

  • Final Q21 measurements are inconclusive, not proof of equivalence or speedup. The full 22-query screen covered the preceding variant; broader issue #30845 remains open.

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

mergify Bot commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor

🚫 Left the queue

35 min in the queue, with no time running CI.

So far

  • ✅ Entered the queue Fri 30 Oct, 15:35 · rule main · triggered by rule Automatic queue on approval for main
  • ⏹️ Testing stopped · in place
  • 🚫 Left the queue 16:10 · 0951617

Reason

Pull request #31620 has been dequeued

Pull request from fork cannot be queued. This pull request comes 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.

Hint

You should look at the reason for the failure and decide if the pull request needs to be fixed or if you want to requeue it.
If you do update this pull request, it will automatically be requeued once the queue conditions match again.
If you think this was a flaky issue instead, you can requeue the pull request, without updating it, by posting a @mergifyio queue comment.

Merge conditions not met when it left the queue

  • any of · required by GitHub branch protection:
    • check-neutral = CI Required
    • check-skipped = CI Required
    • check-success = CI Required

Tick the box to put this pull request back in the merge queue (same as @mergifyio queue).

  • Requeue this pull request
2 merge conditions met
  • #review-threads-unresolved = 0 · required by GitHub branch protection
  • github-review-approved · required by GitHub branch protection

Times in UTC · dashboard · how the merge queue works

This branch was previously deployed

1 inactive deployment
ci — 09516176 Deployed Oct 30, 2026 by mergify[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

dequeued kind/enhancement size/S Denotes a PR that changes [10,99] lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants