Skip to content

perf(optools): bound embedded race package overlap - #29807

Merged
XuPeng-SH merged 16 commits into
mainfrom
codex/ut-racing-critical-path
Oct 10, 2026
Merged

XuPeng-SH merged 16 commits into
mainfrom
codex/ut-racing-critical-path

Conversation

@XuPeng-SH

@XuPeng-SH XuPeng-SH commented Oct 10, 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 #29562. Original CPU/memory and CI-time acceptance remain open; this PR does not close that issue.

What this PR does / why we need it:

Keep one race-UT runner and the existing coverage, test inventories and required multi-CN cases. Reuse the existing dispatcher for bounded issues/embedded execution; defaults remain serial on every platform, with independent explicit two-process opt-ins until matched resource acceptance passes. Preserve conservative exclusion across package reordering. Remove test-only HAKeeper allocator wrappers and use the authoritative allocator.

Helper ownership correction

A helper's exit code cannot prove its separately admitted test/watchdog groups have stopped: live-child reproduction demonstrated unsafe report/artifact deletion after PIPE, HUP, KILL, explicit exit and nounset, including exits numerically matching ordinary success/failure. Compilation and ordinary issues fallback also had descendant-lifetime gaps.

  • Reset one completion file per existing eligible owner before admission. Execute the helper once in the existing background shell; acknowledge audited normal return or cancellation only after existing bounded drainage and joins. Never acknowledge from EXIT or acknowledge status125.
  • The common parent join checks completion against the reaped status and drains the still-owned helper group, including preparation/fallback children. Missing or inconsistent completion is terminal125 before PID release. Retain diagnostics and block report consumption, fallback and later admission; ordinary CURRENT/LIGHT exit contracts remain unchanged.
  • Compiler, metadata, inventory and plan-shard owners verify group drainage before clearing PID slots. Reuse existing TERM/KILL bounds. Final engine/plan binary and report-fragment deletion belongs to the existing parent report consumer after acknowledged join.
  • Extend real-entry regressions for live helper loss, stale/missing/malformed/mismatched completion, initialization failure, compiler descendants and issues fallback descendants. Keep normal failure, cancellation, failed-drain and report-association assertions. No coverage reduction or deadline increase.
  • Preserve portable fixture PID handling and native/fallback controls. Existing test-local cancellation diagnostics now distinguish root notification, group sweep and bare wait with job evidence; no production signal ordering changes.

CI fixture corrections

The rebase retains main's pre-opened, pinged progress connection for unrelated DROP. Its oracle proves independent progress while the competing lifecycle owner remains blocked; it does not impose a two-second SQL/commit timing requirement. The obsolete separate-transaction workaround is removed. Contender liveness, deadlock-victim, rollback and surviving-transaction assertions remain.

The cancellation mock published a readiness file through an external command and then repeatedly launched sleep processes. An executed private control showed that the file could be visible while the helper was still waiting for that external command, deferring its TERM trap beyond the fixture's four-tick grace. Replace that boundary with the existing FIFO/builtin-read pattern. Preserve the grace, harness deadline, 143 exit, complete report ordering, checked completion publication and survivor rejection. This closes the demonstrated fixture counterexample; the historical CI child's exact state is not established. Production runner behavior is unchanged by these fixture corrections.

Documentation correction

Both explicitly enabled waves use shared-gate/slot admission. The design now describes that scope and documents UT_ISSUES_BATCH_PARALLEL=1 UT_EMBEDDED_PACKAGE_PARALLEL=1 for complete serial rollback; changing the issues flag alone does not disable embedded pooling.

Embedded workload and ARM cleanup follow-up

  • Pair compatible passive SQL checks with an active CDC scenario running last. Retain all scenario assertions and the required two-CN case, reducing the selected workload from five cluster starts to three. Reuse SharedTestCluster for serialization, failure quarantine and retryable cleanup; a failed passive child prevents active admission.
  • Configure a one-second task fetch interval before constructing only the two CDC suite clusters. Production defaults, heartbeat, capacities, detector and watermark cadence remain unchanged. Ordinary cluster helpers keep their existing configuration.
  • Replace four unrelated truncate/reseed resets with row restoration in UPDATE IGNORE. Preserve its prepared execution across actual table truncation.
  • Rebind the EndTs test's existing process-local detector/updater to its current CN, avoiding an old closed executor after preceding CDC scenarios. Preserve EndTs timing, admission barrier and late-table assertions.
  • Stream process snapshots through the existing live-group predicate, conservatively reject incomplete/failed snapshots, and handle Bash 3.2 signal traps replacing PIPESTATUS. Use that same predicate for engine-fixture survivor checks so orphan zombies alone do not fail cleanup.

Validation before rebase

The results below apply to pre-rebase revision f5ecd91. Rebased revision d5ffd2a is based on main 590601d; rebase had one lifecycle-test conflict, and new CI plus affected validation are pending.

Pre-rebase follow-up checks on Darwin/arm64, Go1.27.1, source-matched native artifacts, repository CGo runner, matrixone_test/short/count1, GOMAXPROCS8:

  • Full owning embed/optools normal: PASS (387.727s / 143.714s).
  • Full owning embed/optools race: PASS (443.411s / 147.240s). Both paired CDC suites followed by EndTs pass in the same process; retained SQL/prepared and topology cases execute.
  • Linux/arm64, Bash5.2, Docker without init, full optools normal/race: PASS (68.921s / 68.219s). Native Bash3.2 pending-TERM regression is included in the owning passes.
  • Independent race QA: injected passive-child failure prevents active-child execution, completes actual cluster/admission cleanup, and allows a fresh cluster to execute SELECT1 successfully.
  • Configured incremental golangci-lint2.14.0, repository-pinned molint/vet, formatting, Bash syntax and diff checks: PASS, zero diagnostics. Unchanged inherited HAKeeper/issue consumer evidence and exact-head CI are reused; the changed initializer consumers are covered by full owning embed reruns.
  • Actual gpt-6.1-sol/xhigh design, EndTs design delta and complete fifteen-file overall review use persisted CLI sessions. Final evidence reconciliation passed in session 01a125ee-003e-7380-9f46-c160d40dda0e; committed source f5ecd91.

Three matched selected-workload race comparisons on Darwin/arm64, Go1.27.1, matrixone_test/short/count1, GOMAXPROCS8, with prebuilt binaries and serialized fresh test processes:

Median Original scenarios Updated same scenarios
Wall time 210.11 s 122.40 s
CPU time 87.18 s 69.58 s
Peak memory footprint 2,997,194,976 B 2,277,396,008 B
Cluster starts 5 3

All three comparisons passed. These are selected local execution measurements, excluding compilation. They establish neither whole-CI savings nor the original 600-second acceptance target.

Open acceptance

Related #29562 remains open. Defaults remain serial; full CI time and combined CPU/memory acceptance require matched CI measurements. Latest prior UT step took 88m09s with both wave concurrency settings at one. New-revision CI is pending.

Previously failing Linux/arm64/no-init cancellation had two failures in 100 runs. The snapshot candidate passed two race100 runs and owning-package checks in that environment. The exact intermittent Bash/signal root cause remains unproved; this is tested mitigation, not proof of ARM-only causality. Preserve existing completion evidence and refusal to admit subsequent work after failed drain. An uncatchably dead helper cannot immediately reclaim independent groups whose identities were held only by that helper.

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

@mergify mergify Bot added kind/enhancement kind/documentation Improvements or additions to documentation kind/test-ci labels Oct 10, 2026
@matrix-meow matrix-meow added the size/M Denotes a PR that changes [100,499] lines label Oct 10, 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.

Changes required: the previously reported ARM cancellation failure is not causally closed. Two of the three previous findings are fixed in code; there is one new, nonblocking documentation finding below. No new material production-code defect was established in this review.

Reviewed all changed hunks in the 10-file diff at f5e5b02ec776ac7f52aabda01832cefa897dce4d, against merge-base 8adb9d8f80c5bcbac7de51367faf38178208e937. No source edits or subagents were used.

Previous finding Current disposition
Two-process default adoption Fixed. Make and direct-runner defaults are both one; each wave requires its own explicit opt-in. Boundary tests cover independent configuration and invalid/empty values.
ARM cancellation lifecycle Still open. The recorded Linux/arm64 race repetitions on original reviewed commit a6c49f50 failed twice during cleanup, exceeded the harness deadline and required emergency cleanup of three live owned processes; the merge-base control passed. The current Linux/x86 passes, added diagnostics, fail-closed helper protocol and separate HeavyPlan fixture correction do not identify or repair that handoff. This is an unresolved historical failure, not a claim that I reproduced it on f5e5b02e. Diagnose runner versus fixture ownership and retain bounded cancellation/zero-survivor assertions when closing it.
Darwin BASHPID compatibility The identified code defect is fixed. Both harness and executable mocks use the shared caller-assigned PID helper, including the exec/PPID fallback. Native/fallback ownership controls passed. This does not assert that a fresh Darwin suite passed; the current Darwin CI job is skipped.

Design and engineering assessment:

  • Implementation/build delta: +205/-74. The existing dispatcher, admission manager and report consumer retain their responsibilities. Completion acknowledgment proves audited helper cleanup; the report-ready marker proves representation completeness. They carry different obligations, so the added acknowledgment is justified by the abrupt-loss counterexamples. The parent validates acknowledgment/status and drains the still-owned group before PID release; failure retains artifacts and blocks later admission. This contains uncatchable helper loss; it does not reclaim independent groups whose identities died with the helper.
  • The two-process cap and conservative exclusive classification bound optional execution. There is no second scheduler, duplicate cluster admission owner or database hot-path work. Removing HAKeeper's test-only allocation path in favor of the real Update path is coherent cleanup. The SQL change remains a test correction: its two-second DROP execution bound is preserved while commit durability uses the existing transaction context, with rollback and contender cleanup retained.
  • Test delta: +724/-62, reviewed separately. The important additions exercise real runner/admission/report boundaries, abrupt loss, PID identity and rejected consumption/admission; they are not justified merely by their size. The FIFO readiness correction removes an executed fixture race without relaxing cancellation status, drain or report-order assertions. Existing harnesses are reused; no extra embedded SQL cluster fixture was introduced.
  • Documentation delta: +98/-28. Measurements are identified as estimates or measured tradeoffs, and unresolved lifecycle work is explicit. The new P3 identifies a real mismatch in the rollback instructions: resetting only the issues flag leaves an explicitly enabled embedded pool active.

Validation evidence:

  • Reused still-valid author evidence for this head: full optools coverage/normal and race runs; focused cancellation race repetitions and Bash 5.1 control; SQL normal/race; fresh native build; configured incremental vet/molint/golangci checks with zero issues. Existing negative controls reject missing completion, premature report consumption and unrelated DROP blocked by exclusive G admission.
  • Fresh reviewer QA used a private Go overlay to replace the completion-file path with a directory after real helper admission and report creation. The real publication write failed. The existing oracles confirmed status 125, retained report/binary, rejected report consumption and later admission, and released the joined PID. Focused race test PASS, 1.028s. No tracked test/source modification remains.
  • At the last CI snapshot, Linux UT, coverage, SCA and build were still running; Darwin UT was skipped. Local evidence is not a claim of green CI or ARM closure.

I am narrowing the earlier whole-PR verdict: the unfinished combined 600-second/CPU/memory optimization target is not an independent blocker for this serial-default, opt-in increment. Matched full-wave resource evidence remains necessary before default adoption. The outstanding cancellation failure is a concrete lifecycle validation gap, not a speculative reason to add another scheduler or cleanup framework.

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

Changes required remain for the existing cancellation validation gap. Three of four previous comment threads are resolved; the ARM cancellation thread is still open. No new material code finding was established.

Reviewed head 4ca696fab27f8c116e92bb564971d5c01c9cd875, declared/fresh main d5faee3681a4d739d5e6e7be62ee4f54af5b09ce, merge-base 8adb9d8f80c5bcbac7de51367faf38178208e937. The executable/test diff versus the previously reviewed f5e5b02e is empty. I read the new documentation hunks, reused the complete ten-file review and valid model/evidence records, and rechecked the owner/consumer terminal paths. No source edits, subagents or test reruns in this review.

Previous comment Disposition at this head
Default adoption Resolved. Make and direct-runner defaults remain one, with independent explicit opt-in for each wave.
Darwin PID compatibility Resolved code defect. Caller-assigned portable PID handling covers both harness and executable mocks; ownership/fallback controls passed. Actual Darwin UT remains unverified/skipped, rather than being claimed as passed.
Two-wave serial rollback Resolved. The latest commit correctly scopes slot admission to either opted-in pool and specifies both flags for full serial rollback.
ARM cancellation lifecycle Still open, P2. The recorded cleanup timeouts and live-process emergency cleanup occurred on original reviewed commit a6c49f50; they are not new reproductions on 4ca696fa. Current passing x86 controls do not identify that failure's first stalled boundary or establish a causal repair. No ARM environment is available, as confirmed by the user.

The design is coherent for its stated containment contract. The dispatcher owns admission and helper PIDs; helpers own their test/watchdog groups; the parent consumer owns final report/artifact consumption. Completion acknowledgment establishes audited cleanup, while report-ready establishes representation completeness. Their distinct purposes justify the added confirmation. It closes executed false-success/unsafe-consumption counterexamples across helper classes instead of adding signal-specific exceptions or a second scheduler. Test-only HAKeeper allocator wrappers were removed and tests now use the authoritative Update path.

Unhappy-path audit Assessment
Q1: resource ownership PID publication, helper completion, group drainage and report consumption retain explicit owners. Missing/mismatched completion or failed drainage becomes terminal 125, retains evidence and prevents later admission. Uncatchable helper loss still cannot immediately reclaim independent groups whose identities died with it; the PR documents this containment limitation.
Q2: cancellation/termination Deferred TERM is replayed after publication; all owned groups receive TERM before the common bounded KILL sweep. Real stopped-watchdog controls completed sweep and join under Bash 5.2 and 5.1. The historical cancellation failure remains the unresolved exception requiring causal evidence.
Q3: bounded work/state Pools cap at two, high-footprint/unknown packages remain exclusive, and arrays/acknowledgments are bounded per run under the existing workspace lifetime. No database hot-path work, new queue or persistent protocol is introduced.

I reviewed the increments separately: implementation/build +205/-74; tests +724/-62; documentation +99/-28. Test size is not itself evidence of quality. The useful cases exercise real runner/admission/consumer boundaries, prove fault admission before asserting outcomes, retain exact cancellation/report/survivor oracles, and reuse fixtures. The FIFO correction removes an executed readiness race without increasing the cancellation deadline. The SQL test retains its two-second statement/admission bound, separates WAL commit latency using an explicit transaction, checks committed visibility and the pending competitor, and retains rollback/contender cleanup. No additional SQL cluster fixture was added.

Performance remains an opt-in tradeoff: the documented matched issues experiment saved 161.84 seconds but increased CPU 30.27% and peak memory 73.02%. This does not prove combined resource improvement. Serial defaults and the adoption gate are appropriate; the unfinished 600-second project is not an independent blocker for this increment. Additional helper confirmation I/O is confined to the existing CI control path.

Still-valid QA evidence includes the actual completion-publication I/O failure control (125, retained artifacts, rejected consumers/later admission), abrupt-loss/early-consumption negative controls, and stopped-watchdog publication controls: native race 6.856s, coverage-mode fixture 5.863s, and Bash 5.1 caller/mocks race 6.917s. These preserve the fault-reach, exact identity, 143, drain/join and zero-survivor assertions. Owning optools coverage/race, SQL normal/race, HAKeeper/native and configured incremental SCA remain valid because their semantic inputs are unchanged.

New CI evidence at executable revision f5e5b02e: coverage passed and arm64 SCA passed. Its CI Required failure reports matrixone-ci: cancelled; this is the aggregate result of cancelled dependencies, not a newly observed test failure. Current-head UT, coverage, SCA and build are still running; Darwin UT is skipped. No whole-CI pass is claimed.

The remaining action is precise: obtain a failing cancellation execution that identifies fixture release, helper TERM receipt/publication replay, group sweep or child join as the first stalled edge, then repair that owner and retain the bounded cancellation/zero-survivor assertions. Another passing stress run or speculative cleanup framework would not close this comment. This review adds no duplicate inline finding.

@XuPeng-SH

Copy link
Copy Markdown
Contributor Author

Deep review conclusion — rebased head d5ffd2a250922b27535c201c6ba27bcf5828d06c

Reviewed the complete 15-file change against base/merge-base 590601d62aa3c2fb6165d389ee710ed483c98da7, including implementation, tests, documentation, existing ownership, failure/cancellation paths and the rebase conflict. No subagents were used.

Conclusion: the incremental design is acceptable; no new confirmed P1/P2 code defect was found. Whole-project performance acceptance remains open.

Design and engineering quality

  • Scheduling remains with the existing dispatcher and cluster admission owner. Both pools default to one and require independent explicit opt-in. High-footprint packages run exclusively; unknown packages conservatively inherit that restriction. No second scheduler or admission state machine was introduced.
  • Helper completion acknowledgement addresses a distinct correctness requirement: a reaped helper may have exited before draining its independently owned groups. Admission clears stale acknowledgement; join verifies completion against the actual exit status. Missing/inconsistent acknowledgement fails closed with 125, preserves artifacts and prevents later admission. Binary/shard deletion was consolidated under the existing parent report consumer, with obsolete helper-side deletion removed.
  • The process probe uses the shared lifecycle implementation. Snapshot errors/interruption are conservative; PIPESTATUS length is checked before indexing for Bash 3.2. Zombie-only groups are distinguished from live descendants.
  • CDC fixture sharing reuses canonical SharedTestCluster ownership. Passive checks precede the active CDC tail; a failed child stops subsequent work. The active tail is followed by cluster destruction, without treating asynchronous DROP CDC as proof of safe reuse. FetchInterval=1s is confined to the two suites and applied before CN construction; ordinary callers, heartbeat settings, capacities and required topology are preserved.
  • EndTs rebinds detector/updater before task admission, after predecessor teardown. Its original temporal, replication, diagnostic and absence assertions remain. The full same-process suite ordering was verified.
  • UPDATE IGNORE replaces four irrelevant table rebuilds with row restoration while preserving the competing unique-key row and SQL/affected-row/result oracles. The prepared statement test across actual truncate/reseed remains intact.
  • HAKeeper removes test-only allocation helpers and exercises the existing Update/GetAllocateIDCmd path with Batch=1. No new allocator, persisted state or wire contract was introduced.
  • The rebase conflict preserves main's warm progress connection, unrelated DROP progress, shared/exclusive gate scenarios, deadlock victim/rollback and surviving transaction results. It does not restore the former two-second SQL/commit speed requirement.

Test quality and change cost

Implementation/build-entry changes are +223/-80, tests +1271/-522, and documentation +99/-28. These categories were reviewed separately. Much of the CDC textual diff is extraction/de-indentation (+77/-23 ignoring whitespace); all four original named scenarios and six type cases remain.

The shell tests exercise real signals, FIFOs, process groups, report consumption and survivor detection across publication, cancellation, failed drainage, abrupt exit, stale/missing/mismatched completion and subsequent-admission rejection. Separate topology/generation contracts, including EndTs, optimistic mode, transient diagnostics and upgrade/restart, remain independent. The existing 17 upgrade/recovery cluster starts were retained because they cover distinct persistent-state and interruption boundaries.

The existing private passive-failure challenge demonstrated that active work is skipped, actual teardown/admission release completes, and a subsequent fresh cluster can execute SELECT 1. Relevant ownership/control code is unchanged by rebase.

Validation completed on the rebased head

Check Result
Full pkg/embed normal, short/matrixone_test/count=1, Darwin/arm64 Go1.27.1 PASS 384.781s; 113 top-level passes
Full pkg/embed race, same configuration PASS 441.801s; 113 top-level passes, no race report
TestIssue29400CopyAlterRetainedGatePromotionFastFails normal PASS 9.88s, both gate scenarios
Same conflict test race PASS 10.40s, both gate scenarios
No-init Linux/arm64 coverage-mode cancellation + snapshot tests PASS 28.969s; 15 repetitions, four cancellation stages and eight snapshot cases per repetition
bash -n and complete-range git diff --check PASS

Full embed validation includes the paired CDC suites followed by EndTs in the same process, configuration boundaries, UPDATE coverage and upgrade/restart. The pre-existing external MySQL8 opt-in BVT was skipped because its endpoint was not configured; it is not counted as a pass.

Reused evidence was checked for semantic freshness: all optools implementation/tests, HAKeeper changed files and Go module inputs are unchanged by rebase. Prior full optools normal/race results on native system Bash3.2 and no-init Linux/arm64 Bash5.2 remain applicable. The ARM mitigation also has two race100 passes in the original failure environment. Coverage-mode optools reports no Go statements; it does not measure Bash branch coverage.

Review comments and remaining acceptance boundaries

All four review threads are now resolved. The ARM thread's latest closure explanation records the failure boundary, correction and relevant race/coverage evidence. Precise historical Bash signal causality and ARM-only scope remain unproved diagnostic limits. No current counterexample was found. An uncatchably killed helper still preserves evidence and rejects later admission; immediate reclamation of its independent groups is not claimed.

The three pre-rebase matched race pairs for the selected equivalent scenarios showed median wall 210.11 -> 122.40s (-41.7%), CPU 87.18 -> 69.58s (-20.2%), peak footprint 2.997 -> 2.277 GB (-24.0%) and cluster starts 5 -> 3. These are historical subset measurements supporting the design; they are not rebased whole-CI performance proof.

Whole-CI savings of at least 600 seconds and combined issues/embedded full-wave CPU/memory acceptance remain open. Existing two-process issues results increased CPU and peak memory, so retaining serial defaults is appropriate. At the end of this review, the rebased full CI had not reached terminal results. This review does not count pending CI as passed or claim completion of the larger optimization target.

This branch had an error being deployed

1 failed deployment
ci — b7590a15 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/documentation Improvements or additions to documentation kind/enhancement kind/refactor Code refactor kind/test-ci size/XXL Denotes a PR that changes 2000+ lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants