Skip to content

perf(disttae): eliminate exact catalog lookup probe allocations - #27546

Merged
XuPeng-SH merged 5 commits into
matrixorigin:mainfrom
VioletQwQ-0:codex/issue-27235-exact-probe
Aug 25, 2026
Merged

perf(disttae): eliminate exact catalog lookup probe allocations#27546
XuPeng-SH merged 5 commits into
matrixorigin:mainfrom
VioletQwQ-0:codex/issue-27235-exact-probe

Conversation

@VioletQwQ-0

@VioletQwQ-0 VioletQwQ-0 commented Aug 24, 2026

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 #27235

What this PR does / why we need it:

This Draft PR preserves the existing exact-BTree catalog invalidation semantics while reusing the temporary lookup probes used by CatalogCache.HasNewerVersion.

  • Named database and named table lookups obtain a per-cache sync.Pool probe, fully overwrite its fields, run the existing Ascend and identity/timestamp checks, clear the probe through a shared release helper, and return it to the pool.
  • The public method signature, account-wide and database-only branches, prepared-plan/RC-cache query construction, mutation/replay/GC paths, and all SQL/wire/protobuf APIs are unchanged.
  • The probe is returned only after Ascend completes; a panic drops it instead of returning a potentially dirty object. Pool eviction by GC only causes a cold allocation and cannot change the result.

The first commit adds a legacy exact oracle, deterministic differential coverage, concurrent-reader/lifecycle checks, and a benchmark matrix for table/database histories 1/16/256/4096 in warmed-negative and changed states. The follow-up commits add automatic testing.AllocsPerRun gates, deterministic release/reset coverage, a frontend CheckTableDefChange smoke, and an RC getCachedTableByKey replay/version/GC/identity smoke.

This PR deliberately does not include the rejected account-bucket named-dependency scheme (147 measured false positives), the deferred precise shadow watermark, or any instrumentation/report API. #27447 remains Draft and is not rebased or merged.

Historical profile numbers (17,060,022,442 B and 52,996,163 objects) are owner attribution only. The A+C TPCC result (+0.7026%) is directional combination evidence; this PR makes no independent TPS, P95/P99, or +20% claim.

Validation

  • Exact differential tests, replay/alter/truncate/drop/recreate/GC sequence, direct dirty-probe reset, and concurrent readers: PASS.
  • Table and database warmed testing.AllocsPerRun gates require 0 allocations while asserting both negative and changed boolean results; cold and post-GC measurements are logged separately.
  • pkg/vm/engine/disttae/cache focused/full tests and full race: PASS through the repository CGo wrapper.
  • pkg/vm/engine/disttae RC consumer focused/full tests and full race: PASS through the repository CGo wrapper.
  • pkg/frontend CheckTableDefChange focused/full tests: PASS through the repository CGo wrapper.
  • Adaptive focused race stress for the new tests and owning-package race runs: PASS.
  • make build-with-prebuilt-native: PASS on a8efb132191943b7b1a40a00f023dd9e276ad7ae.
  • Escape analysis on the final head: no hot-path TableItem/DatabaseItem probe escape; only cold sync.Pool.New allocation remains.
  • Five-run benchmark matrix and benchstat: pooled warmed paths report 0 B/op, 0 allocs/op; final-head longer database-history control shows no stable regression.
  • Exact-head semantic preflight: PASS at a8efb132191943b7b1a40a00f023dd9e276ad7ae, diff hash f06d8c32c25b5f0c4b1eb04ab5a7c44b6e500a1184245994150639d6b4b93c37.
  • Plain GOWORK=off go build and go vet remain environment-blocked: a clean base reproduces the existing pkg/common/docfilter CGo declaration errors (C.mo_cbitmap_*/C.mo_croaring_*). They are not claimed as passes.

BVT: N/A — the changed contract is an internal lookup-probe allocation optimization with unchanged SQL semantics; SQL cannot assert probe allocation. Exact invalidation behavior is covered by the cache differential tests plus the frontend and RC consumer smoke tests. Full multi-CN SQL DDL validation remains a QA task.

QA required: yes. The direct consumer tests close the local wrapper/eviction path; prepared-plan and multi-CN RC DDL smoke remain QA validation. This PR is ready for human review only after the required remote checks and approval; it makes no claim that local consumer smoke replaces that QA.

@VioletQwQ-0

Copy link
Copy Markdown
Collaborator Author

Addressed the review findings on head a8efb132191943b7b1a40a00f023dd9e276ad7ae:

  • Added table/database testing.AllocsPerRun gates with warmed negative/changed boolean assertions; cold and post-GC observations are logged separately.
  • Added shared exact-object release helpers and a deterministic dirty-probe reset test; removed the nondeterministic sync.Pool.Get reset assertion.
  • Added frontend CheckTableDefChange and RC getCachedTableByKey consumer smoke coverage, including replay/version changes, GC, and identity recreation.
  • Reworked the local semantic preflight so direct cache cases no longer claim same_statement or consumer terminal coverage; it is PASS on the exact final head.

The PR remains Draft for now because the new-head MatrixOne ALL CI is pending and there is no approval/review decision yet. No SQL/multi-CN QA result is being inferred from the local consumer smoke tests.

@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 completed on exact head a8efb132191943b7b1a40a00f023dd9e276ad7ae.

The production change preserves the existing exact-BTree comparator, pivot fields, callback checks, and consumer semantics. The pooled pivot is not returned until synchronous Ascend completes, is fully overwritten on acquisition and zeroed before reuse; panic drops the active probe to GC, while sync.Pool GC eviction only restores the cold allocation path. CatalogCache remains pointer-owned, and no persistent/wire/public contract changes. Q1-Q3 and reuse-generation review found no leak, wait, stale-state, or unbounded-retention blocker.

Fresh reviewer evidence: all nine new focused cache/frontend/RC tests passed; the concurrent-reader test passed under -race -count=100; the cache owning package passed in full under -race; five-run table/database benchmarks at histories 1/16/4096 showed the pooled paths at 0 B/op, 0 allocs/op with consistently lower latency than the legacy 1 alloc/op controls. Exact-head CI is green. BVT is correctly N/A for this internal allocation optimization.

@XuPeng-SH
XuPeng-SH marked this pull request as ready for review August 25, 2026 23:55
@XuPeng-SH
XuPeng-SH requested a review from gouhongshen as a code owner August 25, 2026 23:55
@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 →

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

Labels

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