Skip to content

perf(execution): reduce projection, spill and allocation overhead - #32391

Merged
XuPeng-SH merged 8 commits into
matrixorigin:mainfrom
aptend:perf/tpcds-45min-20261102
Nov 9, 2026
Merged

XuPeng-SH merged 8 commits into
matrixorigin:mainfrom
aptend:perf/tpcds-45min-20261102

Conversation

@aptend

@aptend aptend commented Nov 9, 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:

Reduce execution overhead without changing query plans, SQL semantics, spill thresholds, or concurrency policy:

  • Gather scattered fixed-width build-side rows in batches for eligible unique HashJoins, preserving probe order and existing metadata fallbacks.
  • Serialize selected variable-length Group spill rows directly into the existing accounted 64 KiB buffer. Wire bytes, disk accounting, cancellation, and direct-write fallback remain unchanged.
  • Allocate fresh fixed-state Window aggregates for their known output group count instead of always reserving 8,192 values. Preserve logical chunk indexing, NULL initialization, and ordinary Group allocation policy.
  • Reject an already-full mmap cache before preparing pages with MADV_FREE. Keep the original final locked admission check, byte bound, expiry, and unmap fallback.

Measured performance

Original TPC-DS 1T SQL on the same 64-logical-CPU / 251 GiB host, with automatic merge disabled, a 192 GiB service cgroup limit, agg_spill_mem=4 GiB, sort_spill_mem=512 MiB, and automatic join spill:

Change Query / pipeline DOP cap Control → candidate Time reduction
Window allocation Q51 / 64 189.86 → 178.71 s 5.9%
Window allocation Q51 / 16 200.12 → 183.93 s 8.1%
Window allocation Q47 / 64 61.34 → 57.98 s 5.5%
Window allocation Q57 / 64 44.12 → 38.12 s 13.6%
Full-cache precheck Q78 / 64 191.85 → 169.93 s 11.4%
Group spill serialization Q67 / 16, pair 1 434.07 → 304.76 s 29.8%
Group spill serialization Q67 / 16, pair 2 423.83 → 312.01 s 26.4%

Each comparison checks byte-identical query output and ordinary EXPLAIN output. Q78 has one completed A/B pair. Q67's default-DOP run with a 4 GiB aggregate threshold mostly avoids spilling, so the DOP16 result is not a default-configuration or full-suite speedup claim. The DOP16 cases ran on the same 64-CPU host, not a separate 16-core machine.

These measurements predate this rebase. The earlier full 99-file / 103-statement run passed with the first two changes; the complete four-change head has not had a full-suite rerun. TPC-H runtime non-regression is not yet established.

Validation

At rebased head 62d0420dfd, all seven owning packages passed normal tests with the repository CGo wrapper: malloc, mpool, vector, aggexec, Group, HashJoin, and Window. This includes upstream's Group capacity-retry regression. go vet, gofmt, and git diff --check passed. Tests and vet used production SIMD/v3 mode.

Local SCA passed with the repository-pinned molint and golangci-lint 2.14.0 in the SCA target's default build mode (no GOEXPERIMENT, GOAMD64=v1): make static-check-selected STATIC_CHECK_PACKAGES="./..." GOLANGCI_LINT_CONCURRENCY=2, zero findings. The repository's actual import/test graph selected 392/509 affected packages, crossing its full-scan threshold, so both analyzers checked the full repository.

An additional SIMD-tagged SCA attempt found two checkunsafe violations in unchanged vector metric files. The same focused command reproduced both at clean upstream b19ef50f05; that extra build mode is not reported as passing. No analyzer configuration or suppression was changed.

No benchmark data, profiles, run-specific fixtures, or experimental prototypes are included in the source changes.

Keep the logical aggregate chunk address space while avoiding full-chunk allocation and clearing for small fixed-state windows. Use bounded logical row views for compact destination vectors; preserve normal Group allocation and fallback paths.

Validate snapshot arithmetic, chunk extension, unsupported states and allocation rollback. Native TPC-DS Q51 improves at both DOP64 and DOP16 with identical results and plans; ordinary aggregate throughput remains near baseline.
@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 commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor

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

Commit: 62d0420dfd89248e4b85fc302c02103723bf86b3

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: 62d0420dfd89248e4b85fc302c02103723bf86b3

Assessment: approve

No blocking findings remain. The four fast paths reuse existing vector, spill, aggregate and cache owners. Measured component gains justify the narrow additions and safe logical-length views, with a small scalar-fill cost recorded as an accepted tradeoff.

Model: gpt-6.1-sol / max

Session: 01a1a004-90c3-73b1-acc9-3d4636452003 · slot 0 · generation 0

Validation:

  • Reviewed all 17 changed paths, both discussion entries, and the linked roadmap with its three comments.

  • Go1.27.1 SIMD/v3: all seven owning packages passed normal tests (1,880 top-level tests). Malloc passed its race suite and 300 focused adaptive race repetitions.

  • Boundary, metadata, byte-equivalence, allocation-failure/retry and cleanup oracles passed. Maintained component benchmarks and bounded ABBA base-source controls completed with nonempty selections.

  • Native prerequisites, formatting and frozen-source checks passed. Claimed execution was reconciled with retained logs and command/source/exit receipts in validation-review.json.

Limitations:

  • TPC-DS measurements and the older full-suite run predate the rebase; current full-suite and TPCH runtime non-regression are not established. Raw author performance/SCA logs were unavailable.

  • Local scalar SUM/AVG microbenchmarks increased about 4.9–6.7% (roughly 1.1–1.4ns per Fill); this is a component tradeoff, not proof of an end-to-end regression.

  • The initial toolchain-download timeout was an environment diagnostic; validation resumed successfully using the assigned caches and standard proxy.

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

mergify Bot commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor

❌ Left the queue · Matrixone CI execution / SCA Test on Linux/arm64 fails with this pull request

10 min in the queue, with no time running CI.

So far

  • ✅ Entered the queue Mon 9 Nov, 05:16 · rule main · triggered by rule Automatic queue on approval for main
  • ❌ Checks failed · in place
  • 🚫 Left the queue 05:26 · ab79196

The failure is in this pull request. It failed tested alone on top of main.

Reason

The merge conditions cannot be satisfied due to failing checks

  • CI Required

Failing checks:

To get back in the queue

  • Push a fix: the pull request is queued again once its queue conditions match.
  • If the failure is a flake, tick the box below to queue it again as it is.

Merge conditions not met when it left the queue

  • any of · required by GitHub branch protection:
    • check-neutral = CI Required
    • check-skipped = CI Required
    • check-success = CI Required

Requeue requested — the merge queue status continues in this comment ↓.

2 merge conditions met
  • #review-threads-unresolved = 0 · required by GitHub branch protection
  • github-review-approved · required by GitHub branch protection

Times in UTC · dashboard · how the merge queue works

@mergify

mergify Bot commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor

🚫 Left the queue · pull request dequeued

19 min in the queue, with no time running CI.

So far

  • ✅ Entered the queue Mon 9 Nov, 16:20 · rule main · triggered by rule Automatic queue on approval for main
  • ⏹️ Testing stopped · in place
  • 🚫 Left the queue 16:39 · be68656

Reason

Pull request #32391 has been dequeued

Pull request from fork cannot be queued. This pull request comes 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.

To get back in the queue

  • Push a change if one is needed: the pull request is queued again once its queue conditions match.
  • If no change is needed, tick the box below to queue it again as it is.

Tick the box to put this pull request back in the merge queue (same as @mergifyio queue).

  • Requeue this pull request

Times in UTC · dashboard · how the merge queue works

@XuPeng-SH

Copy link
Copy Markdown
Contributor

@Mergifyio refresh

@mergify

mergify Bot commented Nov 9, 2026

Copy link
Copy Markdown
Contributor

refresh

✅ Pull request refreshed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

dequeued 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