Skip to content

fix(hashbuild): align batch copy budget with allocation - #26438

Merged
mergify[bot] merged 3 commits into
matrixorigin:mainfrom
aptend:fix/26413-hashbuild-batch-budget
Jul 30, 2026
Merged

mergify[bot] merged 3 commits into
matrixorigin:mainfrom
aptend:fix/26413-hashbuild-batch-budget

Conversation

@aptend

@aptend aptend commented Jul 30, 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:

issue #26413

What this PR does / why we need it:

HashBuild budget admission estimated copied batches from source allocation plus empirical multipliers. That model diverged from CopyIntoBatches: large external-table batches are split into 8192-row destinations, varlen payloads can be copied differently for whole, const, and shared-area vectors, and allocator capacity is rounded per destination. The mismatch could either admit an allocation that later exceeded its reservation or reject memory that actually fit.

This change:

  • caps each new destination batch at DefaultBatchSize;
  • projects destination data and varlen-area capacity using the same segmentation and GrowCapacity behavior as the copy path;
  • accounts for partial-tail replacement peak and retained delta without empirical payload multipliers;
  • adds regression coverage for 50K-row external batches, const/shared-area varlen vectors, exact multi-segment capacity, partial tails, and false-admission boundaries.

Verification:

@aptend
aptend requested review from XuPeng-SH and aunjgr as code owners July 30, 2026 04:59
@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.

Deep-reviewed exact head 08259098d46ab0991f797cfa3345d285ed9a2356. The projection now follows the actual copy path: every new destination is capped at 8192 rows, fixed/header and varlen-area capacities use mpool.GrowCapacity, whole-source/shared-area and const vectors match their respective UnionBatch branches, and partial-tail admission covers replacement peak plus retained deltas before subsequent segments. Reservation cleanup/reconciliation and operator reuse remain balanced.

I also probed a reused const-varlen area against actual allocation; the copy path materializes only the live const payload as projected, so no hidden under-bound was found. Changed tests passed under race, the full pkg/sql/colexec/hashbuild package passed, and the dependent TestBatches path passed with the deterministic CGo wrapper. CI is green.

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

mergify Bot commented Jul 30, 2026 •

Copy link
Copy Markdown
Contributor

Merge Queue Status

  • ✅ Entered queue — 2026-07-30 07:55 UTC · Rule: main · triggered by rule Automatic queue on approval for main
  • ✅ Checks passed · in-place
  • ✅ Merged — 2026-07-30 08:54 UTC · at ac08b8aa240ef1d19c78b6695a39c754c5f65542 · squash

This pull request spent 59 minutes 6 seconds in the queue, including 33 minutes 28 seconds running CI.

Required conditions to merge
  • #review-threads-unresolved = 0 [🛡 GitHub branch protection]
  • github-review-approved [🛡 GitHub branch protection]
  • any of [🛡 GitHub branch protection]:
    • check-success = Matrixone Standlone CI / e2e BVT Test on Linux/x64(LAUNCH, PESSIMISTIC)
    • check-neutral = Matrixone Standlone CI / e2e BVT Test on Linux/x64(LAUNCH, PESSIMISTIC)
    • check-skipped = Matrixone Standlone CI / e2e BVT Test on Linux/x64(LAUNCH, PESSIMISTIC)
  • any of [🛡 GitHub branch protection]:
    • check-success = Matrixone CI / UT Test on Ubuntu/x86
    • check-neutral = Matrixone CI / UT Test on Ubuntu/x86
    • check-skipped = Matrixone CI / UT Test on Ubuntu/x86
  • any of [🛡 GitHub branch protection]:
    • check-success = Matrixone CI / SCA Test on Linux/arm64
    • check-neutral = Matrixone CI / SCA Test on Linux/arm64
    • check-skipped = Matrixone CI / SCA Test on Linux/arm64
  • any of [🛡 GitHub branch protection]:
    • check-success = Matrixone Compose CI / multi cn e2e bvt test docker compose(PROXY)
    • check-neutral = Matrixone Compose CI / multi cn e2e bvt test docker compose(PROXY)
    • check-skipped = Matrixone Compose CI / multi cn e2e bvt test docker compose(PROXY)
  • any of [🛡 GitHub branch protection]:
    • check-success = Matrixone Utils CI / Coverage
    • check-neutral = Matrixone Utils CI / Coverage
    • check-skipped = Matrixone Utils CI / Coverage
  • any of [🛡 GitHub branch protection]:
    • check-success = Matrixone UT Coverage / UT Coverage on Ubuntu/x86
    • check-neutral = Matrixone UT Coverage / UT Coverage on Ubuntu/x86
    • check-skipped = Matrixone UT Coverage / UT Coverage on Ubuntu/x86

@mergify
mergify Bot merged commit 7d40b3d into matrixorigin:main Jul 30, 2026
24 of 25 checks passed
@mergify mergify Bot removed the queued label Jul 30, 2026
VioletQwQ-0 pushed a commit to VioletQwQ-0/matrixone that referenced this pull request Sep 17, 2026
…#26438)

HashBuild budget admission estimated copied batches from source allocation plus empirical multipliers. That model diverged from `CopyIntoBatches`: large external-table batches are split into 8192-row destinations, varlen payloads can be copied differently for whole, const, and shared-area vectors, and allocator capacity is rounded per destination. The mismatch could either admit an allocation that later exceeded its reservation or reject memory that actually fit.

This change:

- caps each new destination batch at `DefaultBatchSize`;
- projects destination data and varlen-area capacity using the same segmentation and `GrowCapacity` behavior as the copy path;
- accounts for partial-tail replacement peak and retained delta without empirical payload multipliers;
- adds regression coverage for 50K-row external batches, const/shared-area varlen vectors, exact multi-segment capacity, partial tails, and false-admission boundaries.

Verification:

- issue matrixorigin#26413 real Parquet self-join succeeds with `part_id` 1 and 7 returning 50,000 rows each;
- focused changed tests pass under `-race -count=100`;
- full `colexec` and `hashbuild` packages pass under race;
- `colexec`, `hashbuild`, and `spillutil` package tests pass;
- owning packages pass `go build` and `go vet`.

Approved by: @XuPeng-SH
VioletQwQ-0 pushed a commit to VioletQwQ-0/matrixone that referenced this pull request Sep 17, 2026
…#26438)

HashBuild budget admission estimated copied batches from source allocation plus empirical multipliers. That model diverged from `CopyIntoBatches`: large external-table batches are split into 8192-row destinations, varlen payloads can be copied differently for whole, const, and shared-area vectors, and allocator capacity is rounded per destination. The mismatch could either admit an allocation that later exceeded its reservation or reject memory that actually fit.

This change:

- caps each new destination batch at `DefaultBatchSize`;
- projects destination data and varlen-area capacity using the same segmentation and `GrowCapacity` behavior as the copy path;
- accounts for partial-tail replacement peak and retained delta without empirical payload multipliers;
- adds regression coverage for 50K-row external batches, const/shared-area varlen vectors, exact multi-segment capacity, partial tails, and false-admission boundaries.

Verification:

- issue matrixorigin#26413 real Parquet self-join succeeds with `part_id` 1 and 7 returning 50,000 rows each;
- focused changed tests pass under `-race -count=100`;
- full `colexec` and `hashbuild` packages pass under race;
- `colexec`, `hashbuild`, and `spillutil` package tests pass;
- owning packages pass `go build` and `go vet`.

Approved by: @XuPeng-SH
VioletQwQ-0 pushed a commit to VioletQwQ-0/matrixone that referenced this pull request Sep 17, 2026
…#26438)

HashBuild budget admission estimated copied batches from source allocation plus empirical multipliers. That model diverged from `CopyIntoBatches`: large external-table batches are split into 8192-row destinations, varlen payloads can be copied differently for whole, const, and shared-area vectors, and allocator capacity is rounded per destination. The mismatch could either admit an allocation that later exceeded its reservation or reject memory that actually fit.

This change:

- caps each new destination batch at `DefaultBatchSize`;
- projects destination data and varlen-area capacity using the same segmentation and `GrowCapacity` behavior as the copy path;
- accounts for partial-tail replacement peak and retained delta without empirical payload multipliers;
- adds regression coverage for 50K-row external batches, const/shared-area varlen vectors, exact multi-segment capacity, partial tails, and false-admission boundaries.

Verification:

- issue matrixorigin#26413 real Parquet self-join succeeds with `part_id` 1 and 7 returning 50,000 rows each;
- focused changed tests pass under `-race -count=100`;
- full `colexec` and `hashbuild` packages pass under race;
- `colexec`, `hashbuild`, and `spillutil` package tests pass;
- owning packages pass `go build` and `go vet`.

Approved by: @XuPeng-SH

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/bug Something isn't working 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