Skip to content

perf(vector): avoid redundant metadata work in UnionOne - #28666

Merged
XuPeng-SH merged 2 commits into
matrixorigin:mainfrom
aptend:perf/union-one-uniform-metadata
Sep 11, 2026
Merged

XuPeng-SH merged 2 commits into
matrixorigin:mainfrom
aptend:perf/union-one-uniform-metadata

Conversation

@aptend

@aptend aptend commented Sep 11, 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 #26768.

What this PR does / why we need it:

Avoid redundant metadata work in Vector.UnionOne when both vectors have ordinary conversion metadata, inherited runtime string domains, no row sidecars, and matching string-source ownership (or an empty destination).

In this case, metadata preflight cannot allocate or change representation. Skip the repeated lookups and prefix bitmap scans while preserving payload copying, NULL/grouping flags, source ownership, and all-NULL-prefix/reset semantics. Mixed or exceptional metadata uses the existing path. No stats assumptions, query-specific rules, new buffers, or configuration changes.

Pre-rebase measurements on 9a07655c54 with this identical production patch, single-node i7-11700 / 32 GiB RAM, 128 MiB spill and automatic merge disabled on both sides:

  • TPC-DS Q67 100G: 646.070s → 310.822s (51.9% less time, 2.08x speed) with GOGC=50 on both sides. Identical results, ordinary plans, scanned rows and bytes; no OOM or sampled compiler interference. Peak sampled anonymous memory: 15.119 → 14.996 GiB.
  • TPC-H 1G: all 22 queries, 20 rounds per version, identical results and no observed latency regression in the repeated fresh-service control. TPC-H 100G: all 22 ordinary plans identical; this is not a 100G execution-performance claim.
  • With default GOGC=100, the candidate also completed Q67 100G in 321.179s with identical results and no OOM. Memory headroom is tight: separate candidate and unchanged-baseline attempts crossed the harness's 16 GiB anonymous-memory guard and were stopped. Those are not passing runs or speedup measurements; this PR does not claim to fix that memory limit or complete Q67 1T.

After rebasing onto current main, full vector, batch, and hashjoin package tests pass. The focused metadata test covers NULL/constant/grouping rows, source/kind/domain transitions, explicit-text exclusion, and reset/reuse. Only implementation and focused tests/benchmarks are included; experiment data, fixtures and runtime settings remain outside the PR.

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

APPROVE at 6a61d63 against base cd8e8d9. No concrete blocker found.

Reviewed the complete two-file diff and the exact-head metadata helpers/caller contract. The fast-path predicate checks both vectors, not only the source: no provenance/source sidecar, uniform PrepareParamNone, inherited runtime string domain, and equal scalar source ownership unless the destination is empty. Under these conditions skipped preflights cannot require a new metadata representation. Direct scalar source propagation matches appendStringSourceAt, including NULL rows; marking prepareParamKindSeen matches ordinary-value propagation. prepareParamKindAppendStart is deliberately retained, preserving all-NULL-prefix semantics. Explicit text (row-domain representation), binary, mixed metadata, and source transitions remain on the existing path.

Payload/varlena copying, NULL/grouping flags and allocation paths are unchanged. FinalizeStringSourcePreflight remains on exits after successful preflight, including binary-preflight failure; Batch.UnionOne still preflights all columns and finalizes its retained state. ResetWithSameType clears the relevant provenance/domain state. No new shared state, retained references, serialized fields, or configuration is introduced.

The transition test checks every accumulated row after each append, NULL/grouping/source/kind/domain propagation, constant source selection and two reset/reuse generations, with an MPool cleanup assertion. The benchmark includes eligible ordinary and non-eligible typed-provenance cases. Additional allocator-failure or self-append controls would be supplementary, not a blocker: this optimization does not broaden the existing type/selection/ownership contract.

Validation limits: source/control-flow review only; I did not rerun native package tests, benchmarks, or large SQL workloads and did not wait for CI. Author-reported post-rebase package passes and pre-rebase Q67/TPC-H measurements remain separate evidence; no exact-head speedup or memory-limit fix is claimed by this review. Head/base were rechecked unchanged before submission.

@mergify mergify Bot added the queued label Sep 11, 2026
@mergify

mergify Bot commented Sep 11, 2026 •

Copy link
Copy Markdown
Contributor

Merge Queue Status

  • ✅ Entered queue — 2026-09-11 04:13 UTC · Rule: main · triggered by rule Automatic queue on approval for main
  • 🟠 Checks running · in-place
  • 🚫 Left the queue — 2026-09-11 04:14 UTC · at 36931e6d541c03be710f563bf0feabc3d358f86f

This pull request spent 1 minute 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

VioletQwQ-0 pushed a commit to VioletQwQ-0/matrixone that referenced this pull request Sep 17, 2026
…#28666)

## What type of PR is this?

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

## Which issue(s) this PR fixes:

Related to matrixorigin#26768.

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

Avoid redundant metadata work in `Vector.UnionOne` when both vectors
have ordinary conversion metadata, inherited runtime string domains, no
row sidecars, and matching string-source ownership (or an empty
destination).

In this case, metadata preflight cannot allocate or change
representation. Skip the repeated lookups and prefix bitmap scans while
preserving payload copying, NULL/grouping flags, source ownership, and
all-NULL-prefix/reset semantics. Mixed or exceptional metadata uses the
existing path. No stats assumptions, query-specific rules, new buffers,
or configuration changes.

Pre-rebase measurements on `9a07655c54` with this identical production
patch, single-node i7-11700 / 32 GiB RAM, 128 MiB spill and automatic
merge disabled on both sides:

- **TPC-DS Q67 100G: 646.070s → 310.822s (51.9% less time, 2.08x
speed)** with GOGC=50 on both sides. Identical results, ordinary plans,
scanned rows and bytes; no OOM or sampled compiler interference. Peak
sampled anonymous memory: 15.119 → 14.996 GiB.
- TPC-H 1G: all 22 queries, 20 rounds per version, identical results and
no observed latency regression in the repeated fresh-service control.
TPC-H 100G: all 22 ordinary plans identical; this is not a 100G
execution-performance claim.
- With default GOGC=100, the candidate also completed Q67 100G in
321.179s with identical results and no OOM. Memory headroom is tight:
separate candidate and unchanged-baseline attempts crossed the harness's
16 GiB anonymous-memory guard and were stopped. Those are not passing
runs or speedup measurements; this PR does not claim to fix that memory
limit or complete Q67 1T.

After rebasing onto current main, full `vector`, `batch`, and `hashjoin`
package tests pass. The focused metadata test covers
NULL/constant/grouping rows, source/kind/domain transitions,
explicit-text exclusion, and reset/reuse. Only implementation and
focused tests/benchmarks are included; experiment data, fixtures and
runtime settings remain outside the PR.

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
…#28666)

## What type of PR is this?

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

## Which issue(s) this PR fixes:

Related to matrixorigin#26768.

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

Avoid redundant metadata work in `Vector.UnionOne` when both vectors
have ordinary conversion metadata, inherited runtime string domains, no
row sidecars, and matching string-source ownership (or an empty
destination).

In this case, metadata preflight cannot allocate or change
representation. Skip the repeated lookups and prefix bitmap scans while
preserving payload copying, NULL/grouping flags, source ownership, and
all-NULL-prefix/reset semantics. Mixed or exceptional metadata uses the
existing path. No stats assumptions, query-specific rules, new buffers,
or configuration changes.

Pre-rebase measurements on `9a07655c54` with this identical production
patch, single-node i7-11700 / 32 GiB RAM, 128 MiB spill and automatic
merge disabled on both sides:

- **TPC-DS Q67 100G: 646.070s → 310.822s (51.9% less time, 2.08x
speed)** with GOGC=50 on both sides. Identical results, ordinary plans,
scanned rows and bytes; no OOM or sampled compiler interference. Peak
sampled anonymous memory: 15.119 → 14.996 GiB.
- TPC-H 1G: all 22 queries, 20 rounds per version, identical results and
no observed latency regression in the repeated fresh-service control.
TPC-H 100G: all 22 ordinary plans identical; this is not a 100G
execution-performance claim.
- With default GOGC=100, the candidate also completed Q67 100G in
321.179s with identical results and no OOM. Memory headroom is tight:
separate candidate and unchanged-baseline attempts crossed the harness's
16 GiB anonymous-memory guard and were stopped. Those are not passing
runs or speedup measurements; this PR does not claim to fix that memory
limit or complete Q67 1T.

After rebasing onto current main, full `vector`, `batch`, and `hashjoin`
package tests pass. The focused metadata test covers
NULL/constant/grouping rows, source/kind/domain transitions,
explicit-text exclusion, and reset/reuse. Only implementation and
focused tests/benchmarks are included; experiment data, fixtures and
runtime settings remain outside the PR.

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
…#28666)

## What type of PR is this?

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

## Which issue(s) this PR fixes:

Related to matrixorigin#26768.

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

Avoid redundant metadata work in `Vector.UnionOne` when both vectors
have ordinary conversion metadata, inherited runtime string domains, no
row sidecars, and matching string-source ownership (or an empty
destination).

In this case, metadata preflight cannot allocate or change
representation. Skip the repeated lookups and prefix bitmap scans while
preserving payload copying, NULL/grouping flags, source ownership, and
all-NULL-prefix/reset semantics. Mixed or exceptional metadata uses the
existing path. No stats assumptions, query-specific rules, new buffers,
or configuration changes.

Pre-rebase measurements on `9a07655c54` with this identical production
patch, single-node i7-11700 / 32 GiB RAM, 128 MiB spill and automatic
merge disabled on both sides:

- **TPC-DS Q67 100G: 646.070s → 310.822s (51.9% less time, 2.08x
speed)** with GOGC=50 on both sides. Identical results, ordinary plans,
scanned rows and bytes; no OOM or sampled compiler interference. Peak
sampled anonymous memory: 15.119 → 14.996 GiB.
- TPC-H 1G: all 22 queries, 20 rounds per version, identical results and
no observed latency regression in the repeated fresh-service control.
TPC-H 100G: all 22 ordinary plans identical; this is not a 100G
execution-performance claim.
- With default GOGC=100, the candidate also completed Q67 100G in
321.179s with identical results and no OOM. Memory headroom is tight:
separate candidate and unchanged-baseline attempts crossed the harness's
16 GiB anonymous-memory guard and were stopped. Those are not passing
runs or speedup measurements; this PR does not claim to fix that memory
limit or complete Q67 1T.

After rebasing onto current main, full `vector`, `batch`, and `hashjoin`
package tests pass. The focused metadata test covers
NULL/constant/grouping rows, source/kind/domain transitions,
explicit-text exclusion, and reset/reuse. Only implementation and
focused tests/benchmarks are included; experiment data, fixtures and
runtime settings remain outside the PR.

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

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