Skip to content

perf(group): fuse decimal aggregate argument roots - #31987

Merged
mergify[bot] merged 4 commits into
matrixorigin:mainfrom
aunjgr:perf/aggregate-decimal-fusion
Nov 1, 2026
Merged

mergify[bot] merged 4 commits into
matrixorigin:mainfrom
aunjgr:perf/aggregate-decimal-fusion

Conversation

@aunjgr

@aunjgr aunjgr commented Nov 1, 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 #30860

Performance evidence: #30860 (comment)

Approved design: https://github.com/aunjgr/matrixone/blob/6e8c6dfb2ccc5f2799fe97076322083b218c26e2/docs/design/aggregate-decimal-fusion.md

What this PR does / why we need it:

Specialize complete aggregate arguments of the form x*(literal-y), including commuted multiplication, when Decimal64 leaves widen losslessly to Decimal128 and the bound product needs no scale adjustment. Evaluate the admitted arithmetic in one pass without cast/subtraction intermediates, preserving the bound decimal precision and scale.

Admit only aggregate argument roots after normal executor construction. Keep generic constructors, column evaluation, row alignment and writable-result ownership unchanged. Delegate ineligible inputs, unexpected masks and ownership-transferring evaluation to the generic tree; preserve existing reset/free and allocation-account ownership.

Validation

  • Owning colexec, group and function packages pass; scoped vet/lint report zero issues.

  • The 18-statement SQL case passes twice with normal expected-result comparison and verified teardown, including prepared aggregate reuse and DECIMAL(37,4) metadata. Kernel coefficients have an independent big.Int boundary oracle; allocation failure/reuse, NULL/constant/borrowed validity and generic fallbacks are covered.

  • Independent local SF10 Q1-Q22 comparison: four balanced process pairs, five measured warm calls/query/arm, first/cold calls excluded. Matching normal release binaries use eight physical CPUs, effective 16 GiB CN cache and a 32 GiB whole-application cap. Every arm passes the memory/CPU gates with zero physical I/O, spill, swap and OOM.

  • Q1 medians: main 934.30 ms, candidate 913.75 ms. Median paired change is -2.62% (small-sample paired interval -3.63% to -1.84%). Q14/Q15 remain inconclusive.

  • Full-screen slower signals in Q2/Q7/Q11 were not independently confirmed in four new balanced pairs with 16 warm calls/query. Q11 (+1.52%), Q18 (+2.14%) and Q21 (+0.82%) have positive but inconclusive estimates; these results do not prove equivalence. All raw warm calls and intervals are in the linked issue evidence. Broader SF100/mixed-I/O acceptance stays open.

  • Actual nil-mask component modes improve. A synthetic zero-row non-nil-mask wrapper call has +2.88% dispatch overhead; the only producer installs the wrapper at Group aggregate roots, whose caller always supplies nil. Generic masked constructors/parents remain unchanged and never receive this wrapper. This synthetic result is disclosed rather than labeled a passing masked performance test.

  • Fresh authoritative-main merge and full mo-pr-guard --pre-push gate pass, including package graph, molint, license headers and repository-wide lint (zero reported issues).

  • CI race-mode correction: the Group SUM consumer test now explicitly reads the existing Decimal256 aggregate result and checks its scale, while retaining the Decimal128 fused-argument assertion. Focused -race validation and the fresh-main/full pre-push gate pass. Production code and benchmark evidence are unchanged by this test correction.

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

@aunjgr

aunjgr commented Nov 1, 2026

Copy link
Copy Markdown
Contributor Author

Fixed the Ubuntu race-test failure at 8b02d0ba9c2e2895855267b8efb0f515b2ce85c6. The test used an unchecked Decimal128 getter on the existing Decimal256 SUM output, so normal execution could silently read its low limbs while -race correctly rejected the mismatch. It now asserts the carrier type, scale and value through a checked Decimal256 getter, and separately asserts that the fused argument remains Decimal128.

Focused TestGroupDecimalAggregateArgumentFusion with -race passes, and current main is merged with the full pre-push gate passing zero reported issues. Production arithmetic is unchanged; existing functional/performance evidence is retained. Fresh CI is triggered for this head.

@XuPeng-SH

XuPeng-SH commented Nov 1, 2026 •

Copy link
Copy Markdown
Contributor

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

Commit: 8b02d0ba9c2e2895855267b8efb0f515b2ce85c6

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: 8b02d0ba9c2e2895855267b8efb0f515b2ce85c6

Assessment: approve

The aggregate-only fusion preserves arithmetic, metadata, fallback, and ownership contracts. The Decimal256 test issue is resolved; no actionable findings remain.

Model: gpt-6-astra / xhigh

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

Validation:

  • Frozen-head CI records successful Ubuntu UT, arm64 SCA, shared build, and proxy/pessimistic multi-CN BVT.

  • Reviewed the complete delta, consumers, regression oracles, and all discussion entries; saved review-plan.md and discussion-assessment.json.

  • Reused author-reported package/SQL validation after confirming relevant production inputs are unchanged.

  • Local audit passed: independently recomputed 1,648 benchmark samples and verified source/discussion coverage. Receipt: checks/1793564891256898620-3.json; log: validation-audit-v2.log.

Limitations:

  • No fresh local Go/SQL execution; original test logs and benchmark resource traces were unavailable locally.

  • Performance evidence covers local SF10. Control estimates remain inconclusive; broader SF100/mixed-I/O acceptance remains open.

@mergify mergify Bot added the queued label Nov 1, 2026
@mergify

mergify Bot commented Nov 1, 2026 •

Copy link
Copy Markdown
Contributor

✅ Merged into main as ce17fc5 at 21:28 UTC

58 min in the queue, 57 min of it CI.

So far

  • ✅ Entered the queue Sun 1 Nov, 20:30 · rule main · triggered by rule Automatic queue on approval for main
  • ✅ Passed · in place
  • ✅ Merged 21:28 · ce17fc5 · squash
3 merge conditions met
  • #review-threads-unresolved = 0 · required by GitHub branch protection
  • github-review-approved · required by GitHub branch protection
  • any of · required by GitHub branch protection:
    • check-success = CI Required
    • check-neutral = CI Required
    • check-skipped = CI Required

Times in UTC · dashboard · how the merge queue works

This branch was previously deployed

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

Labels

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants