Skip to content

fix: align expression memory with hash build budget - #26455

Merged
mergify[bot] merged 6 commits into
matrixorigin:mainfrom
aptend:fix/26433-expression-budget-lifetime
Jul 30, 2026
Merged

mergify[bot] merged 6 commits into
matrixorigin:mainfrom
aptend:fix/26433-expression-budget-lifetime

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:

Fixes #26433

What this PR does / why we need it:

Expression executors retain reusable vector capacity across batches and resets. The previous HashBuild accounting replaced expression reservations independently from that physical lifetime, which could either undercount retained memory or double-charge reused capacity.

This PR:

  • introduces an explicit per-root expression memory lease tied to one HashBuild budget generation;
  • admits constant executor allocations before construction and reconciles them to retained capacity;
  • reserves only uncovered allocate-copy-free overlap when an executor grows, while retaining the admitted high-water mark;
  • accounts for IFF/CASE/COALESCE selected-result and selected-parameter scratch;
  • applies the same ownership model to initial spill, probe scatter, recursive re-spill, HashJoin, DedupJoin, and RightDedupJoin;
  • releases failed builder executors before replacement re-spill admission;
  • adds retained-versus-borrowed ownership accounting and lifecycle regression coverage.

Design boundary: this lease covers expressions participating in the shared HashBuild/spill working set. Resident probe expressions remain under normal process/mpool accounting; this is not a general query-memory budget.

Validation:

  • related six packages pass normal and race test suites;
  • all 21 new or directly modified behavioral tests pass race stress with count=100;
  • go build and go vet pass for all owning packages;
  • hashbuild package coverage: 81.4%;
  • final independent review converged with no findings.

@aptend
aptend requested review from XuPeng-SH and aunjgr as code owners July 30, 2026 09:06
@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 current head 5c5280b.

The previous P1 is resolved: array result bounds are now derived from the element width, including BF16/F16, and the max-width regressions verify that retained expression memory stays within the admitted reservation. I also checked constructor admission, high-water/replacement overlap, error cleanup, spill/re-spill ownership, Reset/Free generation boundaries, and the three join variants. No further blocking issues found.

Validation: all six affected packages pass normal tests and race tests; all 26 directly relevant tests pass individually with -race -count=100; go build and go vet pass; 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 14:36 UTC · Rule: main · triggered by rule Automatic queue on approval for main
  • ✅ Checks passed · in-place
  • ✅ Merged — 2026-07-30 15:16 UTC · at fac11e2041e56ec7c526b1b5b9ea18d69b90d939 · squash

This pull request spent 40 minutes 26 seconds in the queue, including 40 minutes 9 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 93e8b22 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
Expression executors retain reusable vector capacity across batches and resets. The previous HashBuild accounting replaced expression reservations independently from that physical lifetime, which could either undercount retained memory or double-charge reused capacity.

This PR:

- introduces an explicit per-root expression memory lease tied to one HashBuild budget generation;
- admits constant executor allocations before construction and reconciles them to retained capacity;
- reserves only uncovered allocate-copy-free overlap when an executor grows, while retaining the admitted high-water mark;
- accounts for IFF/CASE/COALESCE selected-result and selected-parameter scratch;
- applies the same ownership model to initial spill, probe scatter, recursive re-spill, HashJoin, DedupJoin, and RightDedupJoin;
- releases failed builder executors before replacement re-spill admission;
- adds retained-versus-borrowed ownership accounting and lifecycle regression coverage.

Design boundary: this lease covers expressions participating in the shared HashBuild/spill working set. Resident probe expressions remain under normal process/mpool accounting; this is not a general query-memory budget.

Validation:

- related six packages pass normal and race test suites;
- all 21 new or directly modified behavioral tests pass race stress with count=100;
- go build and go vet pass for all owning packages;
- hashbuild package coverage: 81.4%;
- final independent review converged with no findings.

Approved by: @XuPeng-SH
VioletQwQ-0 pushed a commit to VioletQwQ-0/matrixone that referenced this pull request Sep 17, 2026
Expression executors retain reusable vector capacity across batches and resets. The previous HashBuild accounting replaced expression reservations independently from that physical lifetime, which could either undercount retained memory or double-charge reused capacity.

This PR:

- introduces an explicit per-root expression memory lease tied to one HashBuild budget generation;
- admits constant executor allocations before construction and reconciles them to retained capacity;
- reserves only uncovered allocate-copy-free overlap when an executor grows, while retaining the admitted high-water mark;
- accounts for IFF/CASE/COALESCE selected-result and selected-parameter scratch;
- applies the same ownership model to initial spill, probe scatter, recursive re-spill, HashJoin, DedupJoin, and RightDedupJoin;
- releases failed builder executors before replacement re-spill admission;
- adds retained-versus-borrowed ownership accounting and lifecycle regression coverage.

Design boundary: this lease covers expressions participating in the shared HashBuild/spill working set. Resident probe expressions remain under normal process/mpool accounting; this is not a general query-memory budget.

Validation:

- related six packages pass normal and race test suites;
- all 21 new or directly modified behavioral tests pass race stress with count=100;
- go build and go vet pass for all owning packages;
- hashbuild package coverage: 81.4%;
- final independent review converged with no findings.

Approved by: @XuPeng-SH
VioletQwQ-0 pushed a commit to VioletQwQ-0/matrixone that referenced this pull request Sep 17, 2026
Expression executors retain reusable vector capacity across batches and resets. The previous HashBuild accounting replaced expression reservations independently from that physical lifetime, which could either undercount retained memory or double-charge reused capacity.

This PR:

- introduces an explicit per-root expression memory lease tied to one HashBuild budget generation;
- admits constant executor allocations before construction and reconciles them to retained capacity;
- reserves only uncovered allocate-copy-free overlap when an executor grows, while retaining the admitted high-water mark;
- accounts for IFF/CASE/COALESCE selected-result and selected-parameter scratch;
- applies the same ownership model to initial spill, probe scatter, recursive re-spill, HashJoin, DedupJoin, and RightDedupJoin;
- releases failed builder executors before replacement re-spill admission;
- adds retained-versus-borrowed ownership accounting and lifecycle regression coverage.

Design boundary: this lease covers expressions participating in the shared HashBuild/spill working set. Resident probe expressions remain under normal process/mpool accounting; this is not a general query-memory budget.

Validation:

- related six packages pass normal and race test suites;
- all 21 new or directly modified behavioral tests pass race stress with count=100;
- go build and go vet pass for all owning packages;
- hashbuild package coverage: 81.4%;
- final independent review converged with no findings.

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 kind/enhancement size/XXL Denotes a PR that changes 2000+ lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Design]: align ExpressionExecutor retained capacity with HashBuild budget lifetime

3 participants