Skip to content

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

Merged
mergify[bot] merged 2 commits into
matrixorigin:4.2-devfrom
ck89119:issue-26182-4.2-dev
Jul 29, 2026
Merged

mergify[bot] merged 2 commits into
matrixorigin:4.2-devfrom
ck89119:issue-26182-4.2-dev

Conversation

@ck89119

@ck89119 ck89119 commented Jul 28, 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:

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.

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

@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 vectors from the already-required full batch conversion; ownership, lifetime, replay semantics, API compatibility, and error behavior remain intact while redundant allocations are removed. Existing discussions contain no actionable feedback. Formatting and diff checks pass; focused tests could not start because the checkout lacks the required cgo/libmo.dylib.

@mergify

mergify Bot commented Jul 28, 2026 •

Copy link
Copy Markdown
Contributor

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

@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-reviewed at head 8b363ea for the 4.2-dev context. The patch is byte-for-byte patch-equivalent to merged #26234. Proto-backed vectors remain non-owning views, the already-retained batch/RowEntry lifetime is unchanged, and removing the redundant wrappers introduces no leak, double free, wait edge, or accumulation. Full logtailreplay and disttae tests, full logtailreplay race, go vet, diff checks, and 3x allocation benchmarks passed locally (insert 992 B/12 allocs; delete 1312 B/15 allocs).

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

mergify Bot commented Jul 28, 2026 •

Copy link
Copy Markdown
Contributor

Merge Queue Status

  • ✅ Entered queue — 2026-07-28 16:29 UTC · Rule: release-4.2 · triggered by rule Automatic queue on approval for release-4.2
  • ❌ Checks failed · in-place
  • 🚫 Left the queue — 2026-07-28 17:06 UTC · at 9a560d9a64775032413f7732dc755bdf7e75492c

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

Waiting for any of
  • 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
All conditions
  • 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
  • #review-threads-unresolved = 0 [🛡 GitHub branch protection]
  • github-review-approved [🛡 GitHub branch protection]
  • 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 Standlone CI / e2e BVT Test on Linux/x64(LAUNCH, PESSIMISTIC)
    • 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)
  • 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 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)

Reason

The merge conditions cannot be satisfied due to failing checks

Failing checks:

Hint

You may have to fix your CI before adding the pull request to the queue again.
If you update this pull request, to fix the CI, 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.

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

@mergify

mergify Bot commented Jul 29, 2026 •

Copy link
Copy Markdown
Contributor

Merge Queue Status

  • ✅ Entered queue — 2026-07-29 03:47 UTC · Rule: release-4.2 · triggered by rule Automatic queue on approval for release-4.2
  • ✅ Checks skipped · PR is already up-to-date
  • ✅ Merged — 2026-07-29 03:47 UTC · at 9a560d9a64775032413f7732dc755bdf7e75492c · squash

This pull request spent 12 seconds in the queue, including 1 second 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 / 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 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 Standlone CI / e2e BVT Test on Linux/x64(LAUNCH, PESSIMISTIC)
    • 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)
  • 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 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)

@mergify
mergify Bot merged commit dd72a6b into matrixorigin:4.2-dev Jul 29, 2026
44 of 46 checks passed
@ck89119
ck89119 deleted the issue-26182-4.2-dev branch July 29, 2026 03:51

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.

4 participants