Skip to content

perf(frontend): reuse SELECT result columns - #25701

Merged
XuPeng-SH merged 2 commits into
matrixorigin:mainfrom
VioletQwQ-0:codex/p1-result-columns
Jul 15, 2026
Merged

XuPeng-SH merged 2 commits into
matrixorigin:mainfrom
VioletQwQ-0:codex/p1-result-columns

Conversation

@VioletQwQ-0

Copy link
Copy Markdown
Collaborator

What type of PR is this?

  • API-change
  • BUG
  • Improvement
  • Documentation
  • Feature
  • Test and CI
  • Code Refactoring

Which issue(s) this PR fixes:

issue #25472

What this PR does / why we need it:

The ordinary SELECT response path built result column definitions twice: once
to produce MySQL protocol columns and again to populate Session.rs. Under the
prepared point-select workload, the duplicate GetResultColumnsFromPlan call
was a recurring allocation hotspot.

This PR builds the result column definitions once for a SELECT handled by
TxnComputationWrapper, converts that same snapshot into MySQL columns, and
reuses it for Session.rs. Other computation wrappers and statement types keep
the existing path, including the special SHOW COLUMNS metadata handling.

Changes:

  • split MySQL column conversion from result column construction;
  • return MySQL columns and result column definitions together for ordinary
    SELECT statements;
  • cover metadata equivalence, result-column mutation isolation, SHOW COLUMNS
    behavior, prepared compile reuse, and allocation counts.

Validation:

  • go test ./pkg/frontend -count=1
  • go test -race ./pkg/frontend -run 'TestGetSelectColumns' -count=1
  • go test ./pkg/frontend -run '^$' -bench '^BenchmarkGetSelectColumns$' -benchmem -count=3
    • duplicate construction: 736 B/op, 6 allocs/op
    • reused construction: 440 B/op, 4 allocs/op
  • Remote 1000-VU point-select A/B/A on mo-srv-129, based on 2865ed6cc:
    • baseline mean: 177,857 TPS, 25.0 KB and 317.1 mallocs per query
    • patched mean: 178,904 TPS, 24.7 KB and 314.8 mallocs per query
    • GetResultColumnsFromPlan.func1 alloc space: 3.02 GB/30s to 1.44 GB/30.7s

Throughput and average latency remained neutral; the intended benefit is lower
allocation churn on the SELECT response path.

@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 current head (054802d). The SELECT-only fast path preserves metadata semantics and ownership isolation while eliminating the duplicate result-column construction. SHOW COLUMNS and non-Txn wrappers retain the legacy path, and prepared execution reuse is covered. I found no blocking correctness, lifecycle, unhappy-path, or performance issue. Local validation passed: focused tests x20, focused race test, full frontend package, build, vet, and the benchmark consistently reproduced 736 B/6 allocs down to 440 B/4 allocs.

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

mergify Bot commented Jul 15, 2026 •

Copy link
Copy Markdown
Contributor

Merge Queue Status

  • ✅ Entered queue — 2026-07-15 11:46 UTC · Rule: main · triggered by rule Automatic queue on approval for main
  • 🟠 Checks running · in-place
  • 🚫 Left the queue — 2026-07-15 11:59 UTC · at 89b22fdfc956a874455adce18ed29e62b46bf137

This pull request spent 12 minutes 21 seconds in the queue, with no time running CI.

Waiting for
  • any of: [🛡 GitHub branch protection]
    • check-neutral = Matrixone Compose CI / multi cn e2e bvt test docker compose(PESSIMISTIC)
    • check-skipped = Matrixone Compose CI / multi cn e2e bvt test docker compose(PESSIMISTIC)
    • check-success = Matrixone Compose CI / multi cn e2e bvt test docker compose(PESSIMISTIC)
  • any of: [🛡 GitHub branch protection]
    • check-neutral = Matrixone Standlone CI / Multi-CN e2e BVT Test on Linux/x64(LAUNCH, PROXY)
    • check-skipped = Matrixone Standlone CI / Multi-CN e2e BVT Test on Linux/x64(LAUNCH, PROXY)
    • check-success = Matrixone Standlone CI / Multi-CN e2e BVT Test on Linux/x64(LAUNCH, PROXY)
  • any of: [🛡 GitHub branch protection]
    • 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)
    • check-success = Matrixone Standlone CI / e2e BVT Test on Linux/x64(LAUNCH, PESSIMISTIC)
  • any of: [🛡 GitHub branch protection]
    • check-neutral = Matrixone CI / UT Test on Ubuntu/x86
    • check-skipped = Matrixone CI / UT Test on Ubuntu/x86
    • check-success = Matrixone CI / UT Test on Ubuntu/x86
  • any of: [🛡 GitHub branch protection]
    • check-neutral = Matrixone Utils CI / Coverage
    • check-skipped = Matrixone Utils CI / Coverage
    • check-success = Matrixone Utils CI / Coverage
  • any of: [🛡 GitHub branch protection]
    • check-neutral = Matrixone CI / SCA Test on Linux/arm64
    • check-skipped = Matrixone CI / SCA Test on Linux/arm64
    • check-success = Matrixone CI / SCA Test on Linux/arm64
All conditions
  • any of [🛡 GitHub branch protection]:
    • check-neutral = Matrixone Compose CI / multi cn e2e bvt test docker compose(PESSIMISTIC)
    • check-skipped = Matrixone Compose CI / multi cn e2e bvt test docker compose(PESSIMISTIC)
    • check-success = Matrixone Compose CI / multi cn e2e bvt test docker compose(PESSIMISTIC)
  • any of [🛡 GitHub branch protection]:
    • check-neutral = Matrixone Standlone CI / Multi-CN e2e BVT Test on Linux/x64(LAUNCH, PROXY)
    • check-skipped = Matrixone Standlone CI / Multi-CN e2e BVT Test on Linux/x64(LAUNCH, PROXY)
    • check-success = Matrixone Standlone CI / Multi-CN e2e BVT Test on Linux/x64(LAUNCH, PROXY)
  • any of [🛡 GitHub branch protection]:
    • 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)
    • check-success = Matrixone Standlone CI / e2e BVT Test on Linux/x64(LAUNCH, PESSIMISTIC)
  • any of [🛡 GitHub branch protection]:
    • check-neutral = Matrixone CI / UT Test on Ubuntu/x86
    • check-skipped = Matrixone CI / UT Test on Ubuntu/x86
    • check-success = Matrixone CI / UT Test on Ubuntu/x86
  • any of [🛡 GitHub branch protection]:
    • check-neutral = Matrixone Utils CI / Coverage
    • check-skipped = Matrixone Utils CI / Coverage
    • check-success = Matrixone Utils CI / Coverage
  • any of [🛡 GitHub branch protection]:
    • check-neutral = Matrixone CI / SCA Test on Linux/arm64
    • check-skipped = Matrixone CI / SCA Test on Linux/arm64
    • check-success = Matrixone CI / SCA Test on Linux/arm64
  • #review-threads-unresolved = 0 [🛡 GitHub branch protection]
  • github-review-approved [🛡 GitHub branch protection]
  • github-review-decision = APPROVED [🛡 GitHub branch protection]

Reason

Pull request #25701 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.

Failing checks:

Hint

You should look at the reason for the failure and decide if the pull request needs to be fixed or if you want to requeue it.
If you do update this pull request, it will automatically be requeued once the queue conditions match again.
If you think this was a flaky issue instead, you can requeue the pull request, without updating it, by posting a @mergifyio queue comment.

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

  • Requeue this pull request

@XuPeng-SH
XuPeng-SH merged commit d195d5b into matrixorigin:main Jul 15, 2026
23 of 24 checks passed
@mergify mergify Bot added dequeued and removed queued labels Jul 15, 2026
@VioletQwQ-0
VioletQwQ-0 deleted the codex/p1-result-columns branch July 20, 2026 10:02
VioletQwQ-0 added a commit to VioletQwQ-0/matrixone that referenced this pull request Sep 17, 2026
## What type of PR is this?

- [ ] API-change
- [ ] BUG
- [x] Improvement
- [ ] Documentation
- [ ] Feature
- [ ] Test and CI
- [ ] Code Refactoring

## Which issue(s) this PR fixes:

issue matrixorigin#25472

## What this PR does / why we need it:

The ordinary `SELECT` response path built result column definitions
twice: once
to produce MySQL protocol columns and again to populate `Session.rs`.
Under the
prepared point-select workload, the duplicate `GetResultColumnsFromPlan`
call
was a recurring allocation hotspot.

This PR builds the result column definitions once for a `SELECT` handled
by
`TxnComputationWrapper`, converts that same snapshot into MySQL columns,
and
reuses it for `Session.rs`. Other computation wrappers and statement
types keep
the existing path, including the special `SHOW COLUMNS` metadata
handling.

Changes:

- split MySQL column conversion from result column construction;
- return MySQL columns and result column definitions together for
ordinary
  `SELECT` statements;
- cover metadata equivalence, result-column mutation isolation, `SHOW
COLUMNS`
  behavior, prepared compile reuse, and allocation counts.

Validation:

- `go test ./pkg/frontend -count=1`
- `go test -race ./pkg/frontend -run 'TestGetSelectColumns' -count=1`
- `go test ./pkg/frontend -run '^$' -bench '^BenchmarkGetSelectColumns$'
-benchmem -count=3`
  - duplicate construction: 736 B/op, 6 allocs/op
  - reused construction: 440 B/op, 4 allocs/op
- Remote 1000-VU point-select A/B/A on `mo-srv-129`, based on
`2865ed6cc`:
  - baseline mean: 177,857 TPS, 25.0 KB and 317.1 mallocs per query
  - patched mean: 178,904 TPS, 24.7 KB and 314.8 mallocs per query
- `GetResultColumnsFromPlan.func1` alloc space: 3.02 GB/30s to 1.44
GB/30.7s

Throughput and average latency remained neutral; the intended benefit is
lower
allocation churn on the SELECT response path.

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
VioletQwQ-0 added a commit to VioletQwQ-0/matrixone that referenced this pull request Sep 17, 2026
## What type of PR is this?

- [ ] API-change
- [ ] BUG
- [x] Improvement
- [ ] Documentation
- [ ] Feature
- [ ] Test and CI
- [ ] Code Refactoring

## Which issue(s) this PR fixes:

issue matrixorigin#25472

## What this PR does / why we need it:

The ordinary `SELECT` response path built result column definitions
twice: once
to produce MySQL protocol columns and again to populate `Session.rs`.
Under the
prepared point-select workload, the duplicate `GetResultColumnsFromPlan`
call
was a recurring allocation hotspot.

This PR builds the result column definitions once for a `SELECT` handled
by
`TxnComputationWrapper`, converts that same snapshot into MySQL columns,
and
reuses it for `Session.rs`. Other computation wrappers and statement
types keep
the existing path, including the special `SHOW COLUMNS` metadata
handling.

Changes:

- split MySQL column conversion from result column construction;
- return MySQL columns and result column definitions together for
ordinary
  `SELECT` statements;
- cover metadata equivalence, result-column mutation isolation, `SHOW
COLUMNS`
  behavior, prepared compile reuse, and allocation counts.

Validation:

- `go test ./pkg/frontend -count=1`
- `go test -race ./pkg/frontend -run 'TestGetSelectColumns' -count=1`
- `go test ./pkg/frontend -run '^$' -bench '^BenchmarkGetSelectColumns$'
-benchmem -count=3`
  - duplicate construction: 736 B/op, 6 allocs/op
  - reused construction: 440 B/op, 4 allocs/op
- Remote 1000-VU point-select A/B/A on `mo-srv-129`, based on
`2865ed6cc`:
  - baseline mean: 177,857 TPS, 25.0 KB and 317.1 mallocs per query
  - patched mean: 178,904 TPS, 24.7 KB and 314.8 mallocs per query
- `GetResultColumnsFromPlan.func1` alloc space: 3.02 GB/30s to 1.44
GB/30.7s

Throughput and average latency remained neutral; the intended benefit is
lower
allocation churn on the SELECT response path.

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
VioletQwQ-0 added a commit to VioletQwQ-0/matrixone that referenced this pull request Sep 17, 2026
## What type of PR is this?

- [ ] API-change
- [ ] BUG
- [x] Improvement
- [ ] Documentation
- [ ] Feature
- [ ] Test and CI
- [ ] Code Refactoring

## Which issue(s) this PR fixes:

issue matrixorigin#25472

## What this PR does / why we need it:

The ordinary `SELECT` response path built result column definitions
twice: once
to produce MySQL protocol columns and again to populate `Session.rs`.
Under the
prepared point-select workload, the duplicate `GetResultColumnsFromPlan`
call
was a recurring allocation hotspot.

This PR builds the result column definitions once for a `SELECT` handled
by
`TxnComputationWrapper`, converts that same snapshot into MySQL columns,
and
reuses it for `Session.rs`. Other computation wrappers and statement
types keep
the existing path, including the special `SHOW COLUMNS` metadata
handling.

Changes:

- split MySQL column conversion from result column construction;
- return MySQL columns and result column definitions together for
ordinary
  `SELECT` statements;
- cover metadata equivalence, result-column mutation isolation, `SHOW
COLUMNS`
  behavior, prepared compile reuse, and allocation counts.

Validation:

- `go test ./pkg/frontend -count=1`
- `go test -race ./pkg/frontend -run 'TestGetSelectColumns' -count=1`
- `go test ./pkg/frontend -run '^$' -bench '^BenchmarkGetSelectColumns$'
-benchmem -count=3`
  - duplicate construction: 736 B/op, 6 allocs/op
  - reused construction: 440 B/op, 4 allocs/op
- Remote 1000-VU point-select A/B/A on `mo-srv-129`, based on
`2865ed6cc`:
  - baseline mean: 177,857 TPS, 25.0 KB and 317.1 mallocs per query
  - patched mean: 178,904 TPS, 24.7 KB and 314.8 mallocs per query
- `GetResultColumnsFromPlan.func1` alloc space: 3.02 GB/30s to 1.44
GB/30.7s

Throughput and average latency remained neutral; the intended benefit is
lower
allocation churn on the SELECT response path.

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>

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/enhancement 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