Skip to content

perf(disttae): reduce logtail replay allocations - #26234

Merged
XuPeng-SH merged 4 commits into
matrixorigin:mainfrom
ck89119:issue-26182-main
Jul 27, 2026
Merged

XuPeng-SH merged 4 commits into
matrixorigin:mainfrom
ck89119:issue-26182-main

Conversation

@ck89119

@ck89119 ck89119 commented Jul 27, 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 #26182

What this PR does / why we need it:

HandleRowsInsert and HandleRowsDelete converted the same protobuf vectors
individually before converting the complete batch, creating redundant vector
wrappers on every replayed batch. Reuse the vectors from the single
ProtoBatchToBatch conversion instead, and add allocation benchmarks for both
paths.

On Apple M1 Pro, the benchmarks changed as follows:

Benchmark Before After
Insert 1,344 B/op, 14 allocs/op 992 B/op, 12 allocs/op
Delete 1,840 B/op, 18 allocs/op 1,312 B/op, 15 allocs/op

Validation:

  • mo-cgo-test -count=1 -timeout=180s ./pkg/vm/engine/disttae/logtailreplay
  • mo-cgo-test -count=1 -timeout=240s ./pkg/vm/engine/disttae
  • CGo-aware compile checks for both packages
  • Allocation benchmarks with -benchmem -count=3

make static-check still reports the same pre-existing unused identifiers in
pkg/common/malloc/sane_allocator_cache.go on both the clean base and this
change.

@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 review done. I didn't find any merge-blocking correctness, lifecycle, or unhappy-path issues in the current diff.

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

mergify Bot commented Jul 27, 2026 •

Copy link
Copy Markdown
Contributor

Merge Queue Status

  • ✅ Entered queue — 2026-07-27 10:04 UTC · Rule: main · triggered by rule Automatic queue on approval for main
  • 🟠 Checks running · in-place
  • 🚫 Left the queue — 2026-07-27 13:16 UTC · at c95361f7559f9e400607b2084071fdbb80d3c443

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

Reason

The pull request can't be updated

expected head sha didn’t match current head ref.

Hint

You should update or rebase your pull request manually. If you do, this pull request will automatically be requeued once the queue conditions match again.
If you think this was a flaky issue, you can requeue the pull request, without updating it, by posting a @mergifyio queue comment.

Requeued — the merge queue status continues in this comment ↓.

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

Codex automated review

No findings. The change safely reuses the already-retained decoded batch; protobuf-backed vectors do not own or free input buffers, so behavior and lifecycle are preserved while redundant wrappers are removed. Existing PR discussions contain no actionable review feedback. Focused tests could not run because the checkout lacks cgo/libmo.dylib.

@mergify

mergify Bot commented Jul 27, 2026 •

Copy link
Copy Markdown
Contributor

Merge Queue Status

  • ✅ Entered queue — 2026-07-27 13:54 UTC · Rule: main · triggered by rule Automatic queue on approval for main
  • 🚫 Left the queue — 2026-07-27 14:22 UTC · at a8d2c887fc30b80612c6e2a77e21c9986ad54c3a

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

Reason

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

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 f38af2b into matrixorigin:main Jul 27, 2026
1 of 3 checks passed
@mergify mergify Bot removed the queued label Jul 27, 2026
@ck89119
ck89119 deleted the issue-26182-main branch July 27, 2026 14:27
mergify Bot pushed a commit that referenced this pull request Jul 29, 2026
…#26287)

Cherry-picks #26234 to `4.2-dev`.

`HandleRowsInsert` and `HandleRowsDelete` converted the same protobuf vectors
individually before converting the complete batch, creating redundant vector
wrappers on every replayed batch. This change reuses the vectors from the
single `ProtoBatchToBatch` conversion and adds allocation benchmarks for both
paths.

Approved by: @gouhongshen, @XuPeng-SH
VioletQwQ-0 pushed 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
- [x] Test and CI
- [ ] Code Refactoring

## Which issue(s) this PR fixes:

Fixes matrixorigin#26182

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

`HandleRowsInsert` and `HandleRowsDelete` converted the same protobuf
vectors
individually before converting the complete batch, creating redundant
vector
wrappers on every replayed batch. Reuse the vectors from the single
`ProtoBatchToBatch` conversion instead, and add allocation benchmarks
for both
paths.

On Apple M1 Pro, the benchmarks changed as follows:

| Benchmark | Before | After |
| --- | --- | --- |
| Insert | 1,344 B/op, 14 allocs/op | 992 B/op, 12 allocs/op |
| Delete | 1,840 B/op, 18 allocs/op | 1,312 B/op, 15 allocs/op |

Validation:

- `mo-cgo-test -count=1 -timeout=180s
./pkg/vm/engine/disttae/logtailreplay`
- `mo-cgo-test -count=1 -timeout=240s ./pkg/vm/engine/disttae`
- CGo-aware compile checks for both packages
- Allocation benchmarks with `-benchmem -count=3`

`make static-check` still reports the same pre-existing unused
identifiers in
`pkg/common/malloc/sane_allocator_cache.go` on both the clean base and
this
change.

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Co-authored-by: XuPeng-SH <[email protected]>
VioletQwQ-0 pushed 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
- [x] Test and CI
- [ ] Code Refactoring

## Which issue(s) this PR fixes:

Fixes matrixorigin#26182

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

`HandleRowsInsert` and `HandleRowsDelete` converted the same protobuf
vectors
individually before converting the complete batch, creating redundant
vector
wrappers on every replayed batch. Reuse the vectors from the single
`ProtoBatchToBatch` conversion instead, and add allocation benchmarks
for both
paths.

On Apple M1 Pro, the benchmarks changed as follows:

| Benchmark | Before | After |
| --- | --- | --- |
| Insert | 1,344 B/op, 14 allocs/op | 992 B/op, 12 allocs/op |
| Delete | 1,840 B/op, 18 allocs/op | 1,312 B/op, 15 allocs/op |

Validation:

- `mo-cgo-test -count=1 -timeout=180s
./pkg/vm/engine/disttae/logtailreplay`
- `mo-cgo-test -count=1 -timeout=240s ./pkg/vm/engine/disttae`
- CGo-aware compile checks for both packages
- Allocation benchmarks with `-benchmem -count=3`

`make static-check` still reports the same pre-existing unused
identifiers in
`pkg/common/malloc/sane_allocator_cache.go` on both the clean base and
this
change.

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Co-authored-by: XuPeng-SH <[email protected]>
VioletQwQ-0 pushed 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
- [x] Test and CI
- [ ] Code Refactoring

## Which issue(s) this PR fixes:

Fixes matrixorigin#26182

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

`HandleRowsInsert` and `HandleRowsDelete` converted the same protobuf
vectors
individually before converting the complete batch, creating redundant
vector
wrappers on every replayed batch. Reuse the vectors from the single
`ProtoBatchToBatch` conversion instead, and add allocation benchmarks
for both
paths.

On Apple M1 Pro, the benchmarks changed as follows:

| Benchmark | Before | After |
| --- | --- | --- |
| Insert | 1,344 B/op, 14 allocs/op | 992 B/op, 12 allocs/op |
| Delete | 1,840 B/op, 18 allocs/op | 1,312 B/op, 15 allocs/op |

Validation:

- `mo-cgo-test -count=1 -timeout=180s
./pkg/vm/engine/disttae/logtailreplay`
- `mo-cgo-test -count=1 -timeout=240s ./pkg/vm/engine/disttae`
- CGo-aware compile checks for both packages
- Allocation benchmarks with `-benchmem -count=3`

`make static-check` still reports the same pre-existing unused
identifiers in
`pkg/common/malloc/sane_allocator_cache.go` on both the clean base and
this
change.

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

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 kind/test-ci size/M Denotes a PR that changes [100,499] lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] TPCC warehouse=1000 Go GC 长暂停(500-900ms)导致 Lock wait timeout(4.2-dev / main 均偶现)

4 participants