Skip to content

perf(tae): index logtail append ranges on demand - #32031

Merged
mergify[bot] merged 6 commits into
matrixorigin:mainfrom
aunjgr:perf/logtail-append-ranges
Nov 2, 2026
Merged

mergify[bot] merged 6 commits into
matrixorigin:mainfrom
aunjgr:perf/logtail-append-ranges

Conversation

@aunjgr

@aunjgr aunjgr commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor

What type of PR is this?

  • Improvement

Which issue(s) this PR fixes:

Related to #31374. Addresses the measured append-range scanning regression, while leaving the HNSW resource-admission incident open for matched combined-load validation.

The earlier source-level report is in #31350.

What this PR does / why we need it:

Incremental logtail collection currently scans all retained AppendNodes to find transactions to wait for, construct the physical selection, and build commit/abort vectors. Small intervals therefore become expensive as an object's history grows, and visits to older objects with unknown append bounds amplify that work.

Keep physical rows authoritative and admit a reader-owned timestamp index for repeated large-history reads with stable history or small changes. Completed nodes have immutable timestamp keys; unfinished nodes retain the transaction prepare-window check. Commit/rollback only record membership changes after index activation, with no change to PrepareCommit or the AppendNode layout. Readers build and refresh the index, then emit selection and commit/abort vectors in physical row order.

Use the physical scan for small histories, dense intervals and large completion batches. This avoids transferring the read improvement into writer overhead or batched-write regressions. Empty and single-node selections need no pointer scratch; sparse multi-node selections allocate one exact-capacity pointer slice. Derived state is accounted for and released with the append history. Existing catalog creation, late older-object append coverage and bookmark semantics are preserved.

Validation

  • Full updates, tables and logtail packages pass normally; owning updates/tables race checks pass.
  • Exact-cutoff concurrent collection and the transaction prepare-publication window each pass 100 focused race repetitions.
  • Existing engine replay, flush/append and append/GC consumers pass.
  • Regression cases cover physical/prepare order differences, inclusive bounds, aborted ranges, holes, replay, extension, deletion, release and completions published between index refresh and read relock.
  • Full repository standard pre-push gate passed at e1568b6bc0: read-only package graph, pinned molint, license header/dependency checks and golangci-lint (0 issues). Mergify subsequently merged main; all seven PR files remain byte-identical to that reviewed head. Latest-head CI is running.

Performance evidence

Local clean baseline/candidate worktrees, identical Go 1.27.1 SIMD/v3 and native inputs; six balanced process pairs. Warm setup and the first case/process sample are excluded. Profiles and forced-GC live-state measurements are separate from latency scoring. Benchmark scripts execute and drain; they perform no dataset, row, reference or checksum verification.

Control Baseline median Candidate median
8,192 nodes, empty interval 45.59 µs 0.205 µs
8,192 nodes, one returned row 86.78 µs 1.035 µs
8,192 nodes, 32 returned rows 90.64 µs 6.035 µs
Table operator, 64 older unknown-bound objects × 8,192 nodes 3.432 ms 0.02346 ms
1,024 writes, collect after each write 6.691 ms 1.787 ms
1,024 writes, collect after each 64 writes 0.6357 ms 0.5858 ms
Concurrent control: 128 writes plus collector drain, two physical CPUs 346.4 µs 111.2 µs
Writer p99 within that concurrent control 87.93 µs 3.15 µs

The concurrent unit's paired candidate/baseline ratio is 0.321, 95% bootstrap interval [0.285, 0.375]. Its collector p95/p99 and writer p95 also improve. Standalone writer controls at 64/1,024/8,192 nodes have ratios 1.007/1.017/1.013 with intervals [0.987,1.026]/[0.995,1.027]/[0.989,1.040]; those small differences are inconclusive. No confirmed regression remains in the scored warm read/writer/caller controls; this is not a universal zero-regression claim.

Separate CPU profiles attribute 76.8% of baseline one-row collection CPU to PreparedIn; the candidate removes the full-history scans and spends its time in indexed lookup, vector allocation and output construction.

Costs and limits

  • Live Go state for an indexed 8,192-node fixture rises from 168.1 to 227.4 B/node: approximately 59.3 B/node or 0.46 MiB/object additional metadata. This is included in the existing memory estimate. It contains references and index keys, without row-payload copies; deactivation/release drops the references.
  • Index construction and refresh are synchronous reader-owned work under the object write lock. Initial construction is outside the warm-latency figures. Small histories and large change batches retain the physical scan.
  • The older-object control exercises the real table operator/response builder and MVCC collector through a payload-free data seam. Candidate object visits remain conservative; the measurements establish cheaper collection, not fewer visited objects.
  • These are TAE/component/caller measurements, not HNSW SQL or Family throughput proof. [Bug]: main TKE HNSW SIFT128 100 并发查询出现 MergeTop/HashBuild 内存准入错误 #31374 remains open.

Avoid repeated full-history scans for incremental logtail collection. Retain physical row order and build a reader-owned timestamp index for completed append nodes when repeated reads have stable history or small changes.

Keep writer-only histories unindexed, record completions outside PrepareCommit, and use the physical scan for small histories, dense intervals and large completion batches. Preserve transaction prepare-window waits, rollback information and alignment of row selections with commit and abort vectors.

Release and account for all derived state with the owning append history. Add deterministic lifecycle and concurrency coverage together with isolated range, writer, collector and memory benchmarks.
@aunjgr
aunjgr requested a review from XuPeng-SH as a code owner November 2, 2026 10:25
@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 2, 2026 •

Copy link
Copy Markdown
Contributor

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

Commit: 2edc637600ead21207afa1ef4c978130d0078df3

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: 2edc637600ead21207afa1ef4c978130d0078df3

Assessment: approve

The scoped optimization preserves physical-row alignment, prepare-window waits, replay and cleanup ownership. Reported component gains justify the documented metadata and reader-build costs. No actionable findings remain.

Model: gpt-6-astra / xhigh

Session: 01a1869d-999c-7481-b340-ae4a63e8cee4 · slot 1 · generation 2

Validation:

  • Reviewed all seven changed files, affected consumers, both discussion entries and linked issue context.

  • Verified all seven files and relevant dependencies remain unchanged from the author's validation head e1568b6; reused reported package, race, stress and benchmark evidence.

  • Frozen exact-head CI records 13 successes, including UT, build, SCA and active BVT groups; 14 skips and 2 neutral results are not counted as passes.

  • Static audit passed with matching receipt checks/1793619889260687099-2.json and retained static-audit.log. Review records are saved in the diagnostic directory.

Limitations:

  • No fresh Go tests or benchmarks were run; raw author execution logs were not supplied.

  • Warm benchmarks exclude initial index construction. This approval does not establish resolution of the broader HNSW/combined-load incident.

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

mergify Bot commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor

✅ Merged into main as 035356d at 13:09 UTC

1 h 21 min in the queue, 1 h 7 min of it CI.

So far

  • ✅ Entered the queue Mon 2 Nov, 11:48 · rule main · triggered by rule Automatic queue on approval for main
  • ✅ Passed · in place
  • ✅ Merged 13:09 · 035356d · 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

@mergify
mergify Bot merged commit 035356d into matrixorigin:main Nov 2, 2026
@mergify mergify Bot removed the queued label Nov 2, 2026
gouhongshen added a commit to gouhongshen/matrixone that referenced this pull request Nov 2, 2026
…stream claimed 97 as narrow_scan in matrixorigin#32034); take upstream narrow-scan prefetch, virtual-timestamp reads, temporal integer casts, vector shuffle ownership, JSON concat and logtail append-range changes

GitHub reported the PR CONFLICTING (DIRTY): upstream matrixorigin#32034 added
`plan.Node.narrow_scan = 97` while this branch's unmerged additive
`ScanReadRole scan_read_role` sat on field 97.

Semantic resolution, both sides kept:
- upstream keeps `narrow_scan = 97` (shipped on main;
  `plan.pb.go` regenerated from the merged proto with the repository
  protoc/gogofast pipeline plus both postprocessors; toolchain verified
  byte-identical against upstream's committed bindings before use);
- this branch's additive `scan_read_role` moves 97 -> 98; nothing ever
  persisted 97 as scan_read_role (unmerged field), provenance comment
  updated in proto/plan.proto;
- `merged_descriptor_test.go` (upstream's merge-collision contract
  guard) extended to pin Node.narrow_scan=97 / Node.scan_read_role=98
  so a future regeneration cannot silently renumber or drop either;
- all other overlapping files auto-merged with both sides' hunks intact
  (upstream: table_scan/narrow-scan scope+operator plumbing, plan binder
  temporal/int-arg changes, disttae datasource, query_builder/types/
  deepcopy/base_binder/apply_indices).

Upstream batch: matrixorigin#31268 (virtual timestamp reads), matrixorigin#32001 (temporal
integer casts), matrixorigin#32020 (vector shuffle ownership), matrixorigin#32031 (logtail
append ranges), matrixorigin#32038 (python JSON-string concatenation; upstream's
own change, no PR-side code), matrixorigin#32034 (narrow-scan prefetch).

This branch was previously deployed

1 inactive deployment
ci — bb899f79 Deployed Nov 2, 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/XL Denotes a PR that changes [1000, 1999] lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants