Skip to content

fix: optimize bounded rows window sum - #27385

Merged
mergify[bot] merged 5 commits into
matrixorigin:mainfrom
iamlinjunhong:m-27352
Aug 20, 2026
Merged

mergify[bot] merged 5 commits into
matrixorigin:mainfrom
iamlinjunhong:m-27352

Conversation

@iamlinjunhong

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 #27352

What this PR does / why we need it:

fix: optimize bounded rows window sum

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

Reviewed the complete diff at exact head 528007883721f97a47439aed0793b382677d6197 (merge-base 2a38e2a4b50b92fefbef7f74ec9c9fe3f0d5cf3b). APPROVED.

The optimization is bounded by a clear semantic capability: only finite ROWS BETWEEN <n> PRECEDING AND CURRENT ROW SUM frames whose aggregate has an exact inverse use retained sliding state. Floating SUM, DISTINCT, AVG, and decimal forms without a wider safe state remain on the existing evaluator. The retained state advances monotonically across output chunks, is rebuilt at partition boundaries, and is released on completion, cancellation, non-sequential reuse, Reset, and Free. NULL, constant-vector, empty-state, prepared-bound, and output-tail behavior are preserved.

Exact-head validation:

  • All new bounded-window and prepared-bound tests passed 20 consecutive runs.
  • All new aggregate sliding-capability/null/constant/empty-removal tests passed 20 consecutive runs.
  • An independent deterministic differential probe compared 200 randomized nullable int32 inputs, partition layouts, bounds, and output-chunk splits against a direct frame-sum oracle; all passed with zero mpool residue.
  • git diff --check is clean; the PR is mergeable and all substantive CI checks are successful.

No P1/P2/P3 findings retained.

@aunjgr aunjgr 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 528007883721f97a47439aed0793b382677d6197 against base 2a38e2a4b50b92fefbef7f74ec9c9fe3f0d5cf3b.

The optimized path is narrowly admitted only for exact-inverse non-DISTINCT SUM states; floating SUM, AVG, DISTINCT, and overflow-sensitive decimal states retain the ordinary evaluator. The running one-group state closes across NULL/empty frames, constant vectors, output-chunk boundaries, partition resets, cancellation/error, Reset, and Free. Add/remove accounting restores the empty-frame NULL state and preserves source state while snapshots are merged into output groups.

Fresh owning-package tests passed for aggexec and window. The bounded-window benchmark stayed approximately flat from 0 through 1024 PRECEDING rows (about 11–13 ms for 80k rows), with no mpool leak. No blocking correctness, lifecycle, compatibility, or scale issue found.

@mergify mergify Bot added the queued label Aug 20, 2026
@mergify

mergify Bot commented Aug 20, 2026 •

Copy link
Copy Markdown
Contributor

Merge Queue Status

  • ✅ Entered queue — 2026-08-20 14:25 UTC · Rule: main · triggered by rule Automatic queue on approval for main
  • ✅ Checks passed · in-place
  • ✅ Merged — 2026-08-20 20:52 UTC · at 3b354e848320931c56a5dea2c49452b75d2d11a1 · squash

This pull request spent 6 hours 26 minutes 35 seconds in the queue, including 58 minutes 42 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 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
  • any of [🛡 GitHub branch protection]:
    • check-success = Matrixone Standlone CI / multi CN e2e BVT Test on Linux/x64(COMPOSE, PESSIMISTIC)
    • check-neutral = Matrixone Standlone CI / multi CN e2e BVT Test on Linux/x64(COMPOSE, PESSIMISTIC)
    • check-skipped = Matrixone Standlone CI / multi CN e2e BVT Test on Linux/x64(COMPOSE, PESSIMISTIC)

@mergify
mergify Bot merged commit f2bdb33 into matrixorigin:main Aug 20, 2026
25 of 26 checks passed
@mergify mergify Bot removed the queued label Aug 20, 2026
@iamlinjunhong
iamlinjunhong deleted the m-27352 branch August 23, 2026 17:14
VioletQwQ-0 pushed a commit to VioletQwQ-0/matrixone that referenced this pull request Sep 17, 2026
fix: optimize bounded rows window sum

Approved by: @XuPeng-SH, @aunjgr
VioletQwQ-0 pushed a commit to VioletQwQ-0/matrixone that referenced this pull request Sep 17, 2026
fix: optimize bounded rows window sum

Approved by: @XuPeng-SH, @aunjgr
VioletQwQ-0 pushed a commit to VioletQwQ-0/matrixone that referenced this pull request Sep 17, 2026
fix: optimize bounded rows window sum

Approved by: @XuPeng-SH, @aunjgr

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

size/L Denotes a PR that changes [500,999] lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants