Skip to content

perf(optools): add opt-in bounded race UT waves - #29795

Merged
XuPeng-SH merged 6 commits into
matrixorigin:mainfrom
XuPeng-SH:codex/ut-racing-parallel-batches
Oct 10, 2026
Merged

XuPeng-SH merged 6 commits into
matrixorigin:mainfrom
XuPeng-SH:codex/ut-racing-parallel-batches

Conversation

@XuPeng-SH

@XuPeng-SH XuPeng-SH commented Oct 9, 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:

Related to #29562; follow-up to #29760.

What this PR does / why we need it:

Rebased onto main a6e19ccf7761. Adds optional bounded overlap to the existing race-UT dispatcher. Serial execution remains the default; opting into two processes retains complete package/root coverage and explicit same-process cluster isolation.

Design and behavior

  • Reuse the existing dispatcher for launch, deadlines, completion, NDJSON reports and bounded process drainage. Preparation failure may fall back before execution; runtime failure never reruns completed roots. Failed drainage retains status 125 and artifacts.
  • Reuse the cluster admission manager and its shared gate plus bounded process slots. Cross-process admission and intentional same-process borrowing are independent permission bits. A second cluster without WithConcurrentTestClusters fails before services start in both serial and pooled execution. Explicit borrowers retain the original slot/lock until the last lease releases; no extra manager, state machine or cached configuration is added.
  • Validate both parallel settings against the exact domain 1|2; two issues processes require four batches. Arithmetic-overflow inputs fail before preparation. Make tests separate configuration stdout from Git diagnostics and use real detached, untagged, shallow Git metadata.
  • Parse actual runner report records strictly: required package/action, expected-package membership, exact action, unique terminal records and complete expected coverage. Negative oracle cases cover missing, malformed, duplicate and unknown events. Existing real runner fixtures continue consuming the same checker.
  • Preserve explicit caller deadlines through metadata-fence lock acquisition and Commit; only unbounded callers receive the existing 30-second fallback. This removes the private deadline that expired after a 28.335-second gate wait and caused an unknown Commit response. Remove the restore test's second retry policy; cancellation, catalog errors and unknown Commit propagate unchanged.
  • Both original review comments are addressed: redundant parallel/batch and lock-nil guards are removed.

Verification

  • Complete owning admission and optools packages pass in ordinary/race modes; their unchanged semantics remain valid after rebase.
  • Fresh complete owning embed ordinary/race passes at the final rebased head: 401.6 / 488.6 seconds wall, including the new main CDC real-driver transient-failure regression, actual concurrent clusters and cleanup/rollback consumers. Real cluster suites run sequentially.
  • Focused permission, process-slot retention, actual Start and cleanup regressions pass in ordinary/race modes. Bounded exact-root race repeats pass: permission 73, slot lifetime 100, Start 25, admission lifecycle 100, completed rollback 100. N follows the existing 30-second budget and 100-run cap; owning packages are not repeated for stress.
  • Nineteen hand-authored report cases pass in normal/race modes, including both malformed-record counterexamples. Existing actual runner, issues-batch, failure-report, timeout and cancellation checks remain intact.
  • Final complete-PR incremental gofmt, Go vet, repository-pinned molint, golangci-lint v2.14.0, shell syntax and diff checks pass for the six-package affected closure.
  • Exact existing CI coverage parser and ignore rules, with the final complete PR diff and refreshed affected profiles: 35/39 modified blocks covered (89.74%), above the unchanged 75% threshold. Both new permission branches are covered.
  • Existing CN/compile, real two-CN restore, upgrade and issue28079 normal/race evidence is reused where the code and exercised paths remain unchanged. No new SQL BVT is needed for the test-admission/report correction.
  • Go 1.27.1, GOMAXPROCS=2, -p=2, authoritative CGo wrapper and private test namespaces; unrelated machine workloads are preserved.
  • Solution/design and independent final overall review use actual gpt-6.1-sol with xhigh reasoning; review artifacts remain outside tracked source.

Performance and scope

No new real cluster fixture, service setup, retry, goroutine or persistent state is introduced by the permission/oracle correction. Pure report cases and synthetic startup callbacks cover its boundaries. Serial defaults remain unchanged. Historical subset timings motivate the optional pool but do not establish successful matched full-job wall-time, CPU or peak-memory savings; those measurements are required before default adoption.

Separate #29802 owns the root cancellation follow-up. This PR preserves existing cancellation and failed-drain contracts. Remote CI for the newly published revision must be evaluated separately from local and historical evidence.

@XuPeng-SH
XuPeng-SH requested a review from fengttt as a code owner October 9, 2026 14:10
@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 →

@matrix-meow matrix-meow added the size/M Denotes a PR that changes [100,499] lines label Oct 9, 2026
@matrix-meow matrix-meow added size/L Denotes a PR that changes [500,999] lines and removed size/M Denotes a PR that changes [100,499] lines labels Oct 9, 2026
@XuPeng-SH XuPeng-SH changed the title perf(optools): parallelize bounded race UT waves perf(optools): add opt-in bounded race UT waves Oct 9, 2026

@XuPeng-SH XuPeng-SH left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Deep review — no blocking findings

Reviewed all 15 changed files at c656a714d8c4be5bf93f11a593572af25b784b2e against base/merge-base a6e19ccf7761016d95e788f4fc0c546dbea7dac9. This was a direct review without subagents.

Recommendation: merge the opt-in bounded-concurrency capability. Full CI performance acceptance remains unproven. This review is submitted as COMMENT because the authenticated account is also the PR author.

Design and correctness

  • The implementation reuses the existing dispatcher, admission manager, and SQL executor. It introduces no duplicate execution or transaction state machine.
  • Cross-process admission and explicit same-process cluster borrowing are independent permissions. Enabling the process pool no longer implicitly permits an additional local cluster. The last borrower retains the original slot and lock mode until release.
  • Admission remains owned by the cluster lifecycle. Incomplete service cleanup retains ownership; unproven process drainage preserves failure status 125 and diagnostic artifacts. Preparation fallback remains before execution, with no replay after runtime failure.
  • Metadata fencing preserves the operation owner's deadline through lock acquisition and Commit; only an unbounded caller receives the existing fallback. Unknown Commit outcomes and catalog errors still propagate. The redundant restore-test retry policy was removed.
  • The report oracle now rejects missing fields, unknown packages, duplicate events, incorrect actions, malformed JSON, and incomplete expected coverage.

Both actionable original review comments are resolved in source: the redundant parallel-versus-batch comparison and the duplicate lock-nil guard have been removed.

QA and validation

Qualified existing normal/race, focused repetition, and incremental static-check evidence was reconciled with the final revision. The rebase-sensitive complete embed normal/race runs passed, with 337 named passing events in each. Incremental coverage is 35/39 modified blocks, 89.74%, under the unchanged 75% threshold.

At this exact head, CI run 37987161273 has passing SCA, Ubuntu UT, coverage, COMPOSE/PESSIMISTIC multi-CN BVT, PROXY multi-CN BVT, and CI Required checks. Skipped jobs are not counted as passing evidence.

This review additionally ran a temporary Go-overlay challenge against the real dispatcher: two distinct process groups were confirmed simultaneously alive, both ignored TERM, and then the outer runner was canceled. The race-mode probe passed in 6.21 seconds: both groups were gone, the third command never started, status 143 was preserved, and artifacts were removed after drainage. No database cluster was started for this probe. One non-blocking suggestion to retain that scenario is attached inline.

Increment and performance assessment

Area Added Removed
Implementation, including test infrastructure 183 22
Tests 713 69
Documentation 75 1

The test increment was reviewed independently: it reuses existing fixtures, uses a subprocess where process-global admission requires isolation, and keeps malformed-report cases as cheap table-driven checks. No new real multi-CN framework is introduced.

Serial execution remains the default. There is still no matched successful full-wave serial/pool comparison for elapsed time, CPU, and peak memory, so this review does not establish an overall CI saving or resource reduction. Those measurements remain necessary before enabling the pool by default or claiming the broader performance goal is complete.

func TestEmbeddedPrebuiltOuterCancellationKillsResistantGroup(t *testing.T) {
script := embeddedSetup + `
for _, parallel := range []string{"1", "2"} {
for _, drain := range []string{"complete", "failed"} {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Non-blocking test improvement: retain a cancellation case with two simultaneously live, TERM-resistant worker groups.

This matrix varies parallelism, but the fixture keeps only package a blocked; b and c can finish immediately. It therefore does not directly assert cleanup of two live execution owners in the pooled mode.

I ran a temporary race-mode probe using the same harness: wait for readiness from two distinct live groups, make both ignore TERM, cancel the outer runner, then check both groups are gone, c never started, status 143 is preserved, and artifacts are cleaned. It passed in 6.21 seconds; no implementation failure was reproduced.

Consider replacing the existing parallel=2/drain=complete case with this scenario, retaining the serial and failed-drain cases. Replacing the case avoids adding another expensive cancellation fixture.

@XuPeng-SH
XuPeng-SH merged commit a9ddda3 into matrixorigin:main Oct 10, 2026
@XuPeng-SH
XuPeng-SH deleted the codex/ut-racing-parallel-batches branch October 10, 2026 00:51

This branch was previously deployed

1 inactive deployment
ci — c656a714 Deployed Oct 10, 2026 by XuPeng-SH
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kind/bug Something isn't working kind/enhancement kind/test-ci size/L Denotes a PR that changes [500,999] lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants