Skip to content

perf(test): reduce race UT issues runtime and memory pressure - #30216

Merged
XuPeng-SH merged 9 commits into
matrixorigin:mainfrom
XuPeng-SH:codex/ut-race-major-costs-20261014
Oct 15, 2026
Merged

XuPeng-SH merged 9 commits into
matrixorigin:mainfrom
XuPeng-SH:codex/ut-race-major-costs-20261014

Conversation

@XuPeng-SH

@XuPeng-SH XuPeng-SH commented Oct 14, 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.

What this PR does / why we need it:

Latest delivered update: c10856f4e943feed62ec40a9102f40e79873227b

  • Final policy retains the previously validated issues and DML/SQL optimization. Embed, isolated issues and upgrade remain on the ordinary path. The dispatcher and its selection tests are byte-identical to c477. This adopts the alternative requested in the latest review; no dormant experimental flag is added.
  • Retain the fixes discovered while challenging reordered execution: five dedicated-cluster roots release both existing canonical shared-fixture owners before starting their own cluster. The lock-only port lease unit gets a private temporary namespace; real cluster port leasing is unchanged.
  • Fix the actual Coverage failure in TestFuzzingDiskS3: ToCacheData makes CachedData authoritative and permits raw Data=nil. Require nonnil CachedData and compare all expected bytes; defer vector release before Read, including error/FailNow. A deterministic full-async-queue seed write and cold read reproduce the old assertion failure in0.03s (raw_len=0, expected_len=3, cached_matches=true); the corrected test keeps8workers x128operations. No production buffer retention/copy. Queue saturation as the trigger of the original CI incident remains unproven.
  • Local PASS: final optools normal/race (75 roots /315 terminals each); full embed normal (123 roots /408 terminals,2existing skips,207.062s); full fileservice normal/race (423 roots /930 terminals each,6existing skips); targeted Coverage with CI's506-package instrumentation (3 roots /11 terminals); fuzz race93repetitions; five dedicated-cluster roots each race count=3; lock-only lease race count=100; three-package incremental vet/configured lint0issues; gofmt/shell/diff. No new complete-repository Coverage verdict is claimed.
  • The corrected complete ten-package final-policy baseline passed297roots /1091terminals,15existing skips, no failures/duplicates/max/OOM, with released report/binary ownership. The temporary expanded-policy arm also passed the identical inventory. It reduced wall1016.10→826.21s (3m09.89s,18.69%) and PSS occupancy20.70%, but CPU rose1167.96→1195.10s (+2.32%). That expansion is not adopted: it does not meet the CPU objective, and the original-versus-expanded issues-plus-ten adoption comparison was not run. Do not add its savings to historical PR results.
  • Prior-head c477 CI: race UT, ARM64 SCA and both enabled multi-CN BVT jobs passed. Its three red checks have one real failure: the fuzz oracle; Coverage merge explicitly reports a failed producer, and CI Required reports UT Coverage failure. See that run. Final-head CI is newly triggered and pending; reviewer confirmation is pending.
  • Accessible evidence now includes historical complete Make raw terminal inventory (gzip/base64 plus decode instructions and original report hash), both historical and experimental terminal/resource records, exact commands/frozen functions, source/native fingerprints, final selection receipts and final delivery review. Final-source and experimental-source manifests are explicitly separate. Local-only paths are no longer the only evidence.

Shorten long race-test process lifetimes at the existing dispatcher, partitioner,
cluster admission, shared deadline and cleanup owners:

  • Issues: eight round-robin batches, at most two processes, GOMAXPROCS=2 for execution. Every process retains its complete two-CN topology. Compilation and the caller retain their CPU budgets.
  • DML and SQL integration: four round-robin batches, at most two processes, GOMAXPROCS=2. All other embedded packages remain in one ordinary go test -race -p1 command. The real SQL TestMain executes for discovery and every batch, closes the canonical fixture and propagates cleanup failures.
  • Reuse one batching executor. Unknown TestMain contracts remain ineligible. Only the audited SQL caller receives the private cleanup-only permission; no inferred TestMain parsing or environment override is added.
  • Disable embedded prebuild for the new issues default to avoid overlapping compilation with two running clusters. Existing prebuild and package-pool overrides remain available. UT_EMBEDDED_BATCHES=1 restores the original complete-scope embedded command; direct script defaults remain conservative.
  • Publish each report owner before preparation, join/drain before consumption, and release it before admitting the next package. Runtime failures never rerun roots. A failed drain stops admission and retains diagnostics; an ordinary test failure preserves failure while executing remaining selected packages.

Fix test-quality defects exposed during the work: CDCNoPrimaryKeyRejected retained account PITR and could make a later wide-table ALTER fail. Its existing deferred cleanup now removes CDC/PITR before the database, including early assertion failure. DML's table equality oracle now checks streaming errors after iteration. The complete local Make run also exposed inherited scheduler settings in the mock harness and host-timezone-dependent logger/path expectations. The common harness now starts from real runner defaults plus explicit case overrides; existing admission cases inject hostile parent settings. Time oracles use explicit zones, retaining UTC and adding negative/half-hour offsets and a prior-day path boundary. No production SQL/storage behavior, data, topology, assertions or CI coverage/BVT selection is removed.

Measured cumulative result for this PR (before the latest rebase)

Both policies execute issues plus all ten embedded packages, including compilation and teardown. Same kernel/base 1ae2858b382e8249e7b419969c1e45ca74b7f176, source 7f6510b86d001baa0249f86c034d810a8855b0c5, Go 1.27.1/Linux amd64, GCC 14.2, identical initial caches, actual eight-CPU quota, 16 GiB aggregate limit and swap disabled. Both policies include the fixture correction and run sequentially.

Complete changed wave Wall s CPU s Peak PSS GiB Peak cgroup GiB PSS GiB-s
Original four serial issues batches + overlapping prebuild 1717.49 2239.19 5.96 10.29 3267.14
Eight pooled issues batches + bounded DML/SQL generations 1263.43 1939.48 5.91 8.70 2723.30

The complete changed wave saves 454.06 seconds (7m34s, 26.44%). CPU falls 13.38%, cgroup peak 15.42%, PSS occupancy 16.65% and anonymous-memory occupancy 14.64%. PSS peak is nearly flat (-0.89% in this pair). Neither arm has memory-limit/OOM events. No universal OOM or flakiness guarantee is claimed.

All 475 roots / 2636 terminal tests match: 2621 pass and the same 15 existing skips, with no new skips, failed roots, duplicate terminals or malformed JSON. Only four runtime PITR timestamp names are normalized. All eleven package selections exit successfully. This is the original-versus-combined PR difference counted once; earlier compilation proxies or older merged optimizations are not added again.

These figures cover the changed critical wave, not the entire CI job. The actual CI ten-minute target remains unverified. The interrupted 8-GiB baseline hit its memory limit and is excluded; the final pair uses CI's actual 16-GiB budget.

Coverage UT visibility correction

The coverage job exposed an unsupported cross-session visibility assumption in
TestIssue29148PreparedOwnerPolicyLifecycle: after ADD RULE committed on CN0,
the migrated reader on CN1 could still select a pre-commit logtail snapshot.
The second failed SET ROLE already invalidates its cache; invalidation alone
does not establish visibility of another session's commit.

For the two migrated cases, capture the writer's nonempty committed timestamp
and reuse the existing bounded testutils.WaitLogtailApplied before that SET
ROLE. Retain all five cases, migration RPC checks, old/new row results,
NeedReprepare and explicit recreation/cleanup. Same-CN cases retain their
existing RC commit barrier. Production consistency semantics are unchanged.

Validation

  • Current rebased source: PASS: all five TestIssue29148PreparedOwnerPolicyLifecycle cases in normal mode (7.390s), Coverage set mode with the same 506-package instrumentation scope as CI (10.909s; profile generated), and race (17.892s, plus the adaptive count=1 confirmation at 11.516s). Fresh full optools race: 75 roots / 315 passing terminal tests (61.760s). Incremental gofmt/vet/configured lint/shell/diff checks pass for all six changed Go packages, 0 issues. The coverage command executes the affected root only; no fresh complete-repository Coverage/BVT/full-Make rerun is claimed.
  • Current design/final review: gpt-6.1-sol / xhigh; approved design in pr30216-coverage-failure-20261014/design.json, final overall review in pr30216-coverage-failure-20261014/final-review.json. Current validation receipts and source fingerprints: pr30216-coverage-failure-20261014/validation-results.json.
  • The full Make race run and matched performance pair below were performed before this rebase; they are historical evidence, not a new full-suite or CI timing result on the new base.

Previous delivered source: c477e5612c1453a1b84b44e4c581025a1fdb8016, rebased onto main 678b72b9292cd5e9e26c90b469e575322bb0f617. The historical full Make run below used explicit batch count 4 before this rebase and the new test-only visibility correction; the current focused checks validate the correction on the new base.

  • Historical full local CI race selection before the latest rebase, through the real Make entry point: PASS at 37511213693c1e5ee302f0688447e09c3ff70fdc: make ut SKIP_TEST= UT_SHARD=all UT_PARALLEL=8 UT_EMBEDDED_BATCHES=4, 32m18.42s, Make exit 0, 430 passing packages plus 80 packages without tests; 27,735 passing roots and 74,128 passing root/subtest terminals, 73 existing skipped terminals. No failed, duplicate or malformed test terminals. Peak cgroup memory 7.19 GiB, memory-limit/OOM events and swap use zero; owned scope drained and inactive. The first attempt failed three test packages; its diagnostics are preserved and the fixes were included before this successful full rerun. Final Make default 4 is the same explicitly exercised policy
  • Before rebase, incremental go vet and configured golangci-lint v2.14: all five changed packages pass, 0 issues. Final default/config-test static checks: PASS: final complete optools race (75 roots / 315 terminal tests), real Make default and explicit 1 rollback cases, and renewed five-package vet/lint/format/shell/diff checks, 0 issues
  • Before rebase, full optools race: 75 roots / 315 passing terminal tests; no skips. Existing rollback, TestMain cleanup failure, preparation fallback, deadline, report ownership, cancellation and failed-drain oracles are retained.
  • Before rebase, real same-process isolation challenge: CDC -> legacy wide ALTER -> CDC -> legacy wide ALTER, -count=2 -shuffle=20261014, all four pass and the actual TestMain exits successfully. This exact CDC->wide sequence failed before the cleanup fix.
  • Existing admission/port/lifecycle race evidence is retained. BVT and Coverage commands/cases are unchanged; their passing checks at 1ae2858b remain applicable to unchanged production behavior. No new full local BVT run is claimed.
  • Before rebase, design, source and independent resource/inventory review: actual gpt-6.1-sol / xhigh. Final delivery review: gpt-6.1-sol / xhigh; source and resource/inventory approvals retained, final policy/evidence review recorded in final-delivery-review.json

Evidence and reproduction

Accessible terminal/resource evidence is linked in the latest update above. Full local diagnostic reports and independent-review artifacts are also indexed at:
/home/xupeng/.codex/issue-to-pr/matrixone/ut-race-stage3-20261014/evidence-index.json.

The index points to the exact source manifest and native hashes, frozen commands,
both complete raw JSON reports and package receipts, cgroup CPU/memory counters,
PSS samples, inventory comparison, case-isolation trace, SCA logs and full Make UT inputs/results. Native hashes were captured before the subsequent full Make rebuilt the isolated worktree's own native installation; the borrowed worktree was not modified.

To reproduce the two policies through the full runner, use separate identical caches and run sequentially under eight CPUs, 16 GiB and no swap:

# Original policy
GOMAXPROCS=8 UT_TIMEOUT=40 make ut SKIP_TEST= UT_SHARD=all UT_PARALLEL=8 \
  UT_ISSUES_BATCHES=4 UT_ISSUES_BATCH_PARALLEL=1 \
  UT_PREBUILD_EMBEDDED=1 UT_EMBEDDED_PACKAGE_PARALLEL=1 UT_EMBEDDED_BATCHES=1
# Proposed policy
GOMAXPROCS=8 UT_TIMEOUT=40 make ut SKIP_TEST= UT_SHARD=all UT_PARALLEL=8 \
  UT_ISSUES_BATCHES=8 UT_ISSUES_BATCH_PARALLEL=2 \
  UT_PREBUILD_EMBEDDED=0 UT_EMBEDDED_PACKAGE_PARALLEL=1 UT_EMBEDDED_BATCHES=4

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

Copy link
Copy Markdown
Contributor Author

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

Commit: 1ae2858b382e8249e7b419969c1e45ca74b7f176

Review completed. Read the assessment.

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

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

Commit: 1ae2858b382e8249e7b419969c1e45ca74b7f176

Assessment: request_changes

Reviewed the complete six-file delta and affected owners. The design coherently reuses existing scheduling, admission, deadline and cleanup paths. No implementation defect was confirmed, but the resource-validation gate for enabling pooled execution remains open.

Model: gpt-6-astra / xhigh

Session: 01a12d8f-7dea-77c2-a565-38d45b5564e4 · slot 0 · generation 0

  • P2 Makefile:612: Default race UT now runs eight issues batches with two concurrent cluster processes.
    Impact: Validation requirement: the documented resource-adoption gate is not independently verifiable. Passing scheduler harness tests does not establish complete real-workload coverage or acceptable CPU and memory costs.
    Evidence: The PR reports 179 roots, 1548 terminal results and improved combined resource usage at base a33dcfb, while acknowledging increased standalone issues peak memory. However, evidence.json.local_validation is empty, and no raw workload/resource logs, commands, native-input fingerprints or terminal receipts are supplied. Recover those artifacts and establish compatibility with this head, or repeat the bounded serial-versus-eight-batch comparison, checking inventory equivalence, CPU, memory peaks/occupancy and limit/OOM events. A full CI rerun is not required to close this finding.

Validation:

  • Preflight passed. Full optools tests passed in normal and race modes: 73 root tests and 290 terminal results each, without failures or skips.

  • Focused race repetitions passed: TestIssuesBatchesUseBoundedProcessPool ×100; TestIssuesRootDispatchDrainsHeartbeat ×25.

  • go vet ./optools, shell syntax and git diff --check passed.

  • Commands, logs, exit receipts and clean frozen-head fingerprints were reconciled in /home/xupeng/.local/state/mo-bot/jobs/7ab0c171f8213bdbcfe65408/attempt-1/validation-audit.json. Source remained unchanged.

Limitations:

  • Real MatrixOne workload and resource measurements remain author-reported; local checks exercised the scheduler harness.

  • The supplied CI snapshot contains unfinished substantive checks. Pending CI alone is not the finding.

  • Linked issue #29562's body was absent from the frozen evidence; its contract was assessed through the PR description and design document.

@XuPeng-SH

Copy link
Copy Markdown
Contributor Author

mo-bot work · mo-bot-local · reviewing

Commit: 1ae2858b382e8249e7b419969c1e45ca74b7f176

Review in progress.

@XuPeng-SH

Copy link
Copy Markdown
Contributor Author

Updated in f730068. This addresses the confirmed fixture-isolation and fileservice oracle defects; it also extends the same bounded batching owner to embed/isolated/upgrade without dropping roots or topology.

For the evidence-accessibility request in #30216 (review): commands, unmodified terminal-event records, resource counters/PSS samples, source/native fingerprints and terminal receipts are now readable at https://gist.github.com/XuPeng-SH/5d49ae8334646c2c67b538e21e40cccc . Historical and current revisions are explicitly separated. Local-only paths are no longer the only evidence supplied. Current complete matched comparison is still running; its raw terminals/resources and final results will be appended there. No new timing gain or reviewer approval is claimed while that gate is pending.

The latest c477 CI run confirms race UT, SCA and both enabled multi-CN BVT jobs passed. The real Coverage failure is the fuzz raw-Data assertion. Coverage merge's log states the required producer failed, and CI Required reports UT Coverage failure; these are dependent red checks, not three independent defects.

The cache contract is now tested directly: a deterministic full async queue skips seed write cache-fill, then a cold read succeeds with correct CachedData. Restoring the old assertion makes this fail with raw_len=0, expected_len=3, cached_matches=true. The corrected root keeps all 8 workers x128 operations and releases the vector on errors/assertion failure. The exact queue saturation trigger of the original CI incident is still unproven. Full fileservice normal/race, optools normal/race, targeted CI-scope coverage, isolation repetitions and incremental SCA all pass. New-head CI and the additional full-scope local comparison are pending; PR body lists the scope precisely.

@XuPeng-SH

XuPeng-SH commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor Author

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

Commit: f73006879c9846c65fbb0dfdd2c5b24b959f9de0

Review completed. Read the assessment.

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

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

Commit: f73006879c9846c65fbb0dfdd2c5b24b959f9de0

Assessment: request_changes

Reviewed all 18 changed files and their callers. Reusing the existing batching, deadline, admission and cleanup owners is sound; the fixture and cache-oracle corrections preserve their contracts. One required validation gate remains open for the expanded default.

Model: gpt-6-astra / xhigh

Session: 01a12d8f-7dea-77c2-a565-38d45b5564e4 · slot 0 · generation 0

  • P2 optools/run_ut.sh:2543: Default Make execution now splits embed, issues/isolated and upgrade into four batches with two concurrent processes.
    Impact: Validation requirement: the expanded default lacks the required complete-wave inventory and resource comparison. Historical savings do not establish the CPU, memory or fixture-generation costs of concurrently batching these additional packages. This is an unmet adoption gate, not an observed production regression.
    Evidence: The reconciled historical candidate executed these three packages once each. The frozen PR and published archive README explicitly mark the current ten-package comparison pending. docs/design/pr29760-race-ut-critical-path.md:101 and :143 require that comparison before default adoption. Complete the original-versus-current issues-plus-ten-package comparison, including compilation, with identical cache conditions, eight CPUs, 16 GiB and no swap; retain matching terminal inventories and CPU/PSS/cgroup measurements satisfying the documented limits. Alternatively, keep these three packages on the ordinary path until the gate passes.

Validation:

  • Preflight passed. Current-head optools normal and race runs each passed 75 roots and 318 terminal tests using the supplied test-exec. Receipts 1792021176439009645-3.json and 1792021262263253242-3.json match retained logs, commands, clean-source fingerprints and exit 0.

  • Shell syntax, changed-Go formatting and diff checks passed; 737 published input hashes matched the frozen checkout.

  • Independently reconciled historical terminal maps: 475 roots and 2,636 terminal tests in both arms. Recomputed savings: 454.06 seconds, 13.38% CPU, 15.42% cgroup peak and 16.65% PSS occupancy. These measurements cover the older scheduling policy.

  • Evidence reconciliation and review scope are retained in /home/xupeng/.local/state/mo-bot/jobs/e0c601ad86ce4e57ec58f931/attempt-1/review-record.json and author-evidence-audit.json. Source remains unchanged.

Limitations:

  • No fresh native MatrixOne suite or complete resource comparison was run locally. Published narrower test results do not close the expanded-policy gate.

  • Historical full-Make evidence lacks its complete raw terminal inventory. Current CI was unfinished in the frozen snapshot; pending CI alone is not the finding.

@XuPeng-SH

Copy link
Copy Markdown
Contributor Author

Final follow-up c10856f addresses the remaining expanded-default gate from review5526158928 using the stated alternative: embed/isolated/upgrade remain ordinary; dispatcher and selection tests exactly match validated c477. The original issues/DML/SQL optimization and all CI/fixture fixes remain.

The matched incremental experiment completed successfully with identical297roots/1091terminals/15existing skips, no failure/duplicate/max/OOM: wall1016.10→826.21s, PSS occupancy−20.70%, CPU+2.32%. Because the CPU objective and the expanded original-versus-current adoption gate were not met, this experiment is not adopted and its savings are not added to historical PR savings. No experimental switch or parallel scheduler was introduced.

Final optools normal/race each75roots315terminals PASS; full embed normal123roots408terminals PASS; full fileservice normal/race and targeted CI-instrumented Coverage plus incremental SCA PASS. The one local runner build failure from inherited obsolete CGO linker flags is archived; explicit gcc/cleared flags rerun passed without source changes.

The accessible evidence archive now also includes all historical full-Make raw terminal events (gzip/base64 with decode instructions and original report SHA), closing the missing complete terminal inventory limitation: https://gist.github.com/XuPeng-SH/5d49ae8334646c2c67b538e21e40cccc . See final-delivery.json and final-source-inputs.json for final-head scope. New CI and independent reviewer confirmation are pending; no whole-CI ten-minute claim is made.

@XuPeng-SH

XuPeng-SH commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor Author

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

Commit: c10856f4e943feed62ec40a9102f40e79873227b

Review completed. Read the assessment.

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

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

Commit: c10856f4e943feed62ec40a9102f40e79873227b

Assessment: approve

Reviewed all 18 changed files, affected owners and review concerns. The design reuses existing scheduling, deadline and cleanup implementations while preserving test coverage. The expanded batching policy was withdrawn, and recovered evidence closes the earlier adoption-validation gaps. No actionable findings remain.

Model: gpt-6-astra / xhigh

Session: 01a12d8f-8e48-7622-ad17-b605f08450ce · slot 1 · generation 0

Validation:

  • Audited 80 published artifacts, verified 79 artifact hashes and 737 source hashes against this head. Final dispatcher and Make policy match c477; historical frozen function bodies match after documented native-flag adaptation.

  • Reconciled retained results: final optools normal/race each 75 roots and 315 terminal results; embed normal 123/408; fileservice normal/race each 423/930; focused coverage 3/11. Existing skips remain explicit.

  • Recomputed historical comparison: identical 475 roots and 2,636 terminal results, including 15 skips; wall time decreased 26.44%, CPU 13.38%, cgroup peak 15.42% and PSS occupancy 16.65%, with no memory-limit/OOM events. Current final-policy embedded baseline completed 297 roots and 1,091 terminals.

  • Recovered complete historical Make terminal inventory: 430 passing packages, 80 packages without tests, 74,128 passing test terminals and 73 skips; no duplicate or failed terminals. Reconciled prior c477 CI results for unchanged closures.

  • Local shell syntax, formatting, diff and evidence checks passed. Clean-head, command and exit receipts 1792022233309177932-4.json and 1792022554060482740-4.json match retained logs. Detailed records: /home/xupeng/.local/state/mo-bot/jobs/e8b84a4c243f60eea8b423be/attempt-1/validation-audit.json and review-record.json.

Limitations:

  • No fresh native suite was executed locally; compatible retained author and CI evidence was reused. Historical full Make and performance results are not new-head full-suite measurements.

  • Final-head substantive CI was unfinished in the frozen snapshot. Whole-CI timing and the original cache failure's queue-saturation trigger remain unverified.

  • Linked issue #29562's body was unavailable; its contract was assessed through the frozen PR description and design.

This branch was previously deployed

1 inactive deployment
ci — dae7dcd3 Deployed Oct 15, 2026 by XuPeng-SH
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/L Denotes a PR that changes [500,999] lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants