Skip to content

test: reduce race UT fixture lifecycle overhead - #29025

Merged
XuPeng-SH merged 2 commits into
matrixorigin:mainfrom
XuPeng-SH:codex/race-ut-systematic-optimization-20260916
Sep 17, 2026
Merged

XuPeng-SH merged 2 commits into
matrixorigin:mainfrom
XuPeng-SH:codex/race-ut-systematic-optimization-20260916

Conversation

@XuPeng-SH

Copy link
Copy Markdown
Contributor

Summary

  • Consolidate the two static Arrow policy scenarios into one test-scoped four-CN fixture.
  • Keep ForceMaterialize borrow/materialize and GateDisabled/distributed-fallback on separate CNs and databases.
  • Keep BVT, restart, and rollout/drain tests on their existing dedicated lifecycles.

Why

Race UT evidence from #28956 and #28885 shows that the apparently slow Arrow cases spend most of their time waiting for embedded-cluster admission and service startup. The global cluster admission lock is an intentional resource-safety boundary; this change reduces one compatible lifecycle instead of bypassing that lock or increasing default cluster concurrency.

The two static policy matrices are independent, have no restart/fault boundary, and use disjoint state. Sharing their lifecycle removes one cluster admission/start/close cycle without removing a policy mode, assertion, or behavioral case.

Coverage and lifecycle safety

  • CN0: Arrow enabled, S3 enabled, distributed enabled, borrow path.
  • CN1: Arrow enabled, S3 enabled, distributed enabled, ForceMaterialize path.
  • CN2: Arrow disabled, S3 enabled, distributed enabled, gate-disabled path.
  • CN3: Arrow enabled, S3 enabled, distributed disabled, soft-fallback path.
  • The fixture is owned by the combined test and closed with t.Cleanup before later package tests acquire the global admission lock.
  • Startup rollback retains cleanup ownership when StartTestCluster returns a non-nil cluster with an error.

The former focused test names are preserved as nested subtests:

TestArrowLoadStaticPolicyModes/TestArrowLoadForceMaterializeFallback

TestArrowLoadStaticPolicyModes/TestArrowLoadGateModes

Validation

  • Baseline, two independent race lifecycles: package elapsed 32.538s.
  • Combined static-policy race test: 15.867s in the final focused run; earlier A/B package elapsed 17.39s.
  • Full pkg/tests/arrowload race run on the lifecycle consolidation: passed, package elapsed 74.612s, wall 90.21s.
  • Final focused command: GOWORK=off go test -mod=readonly -race -json ./pkg/tests/arrowload -run '^TestArrowLoadStaticPolicyModes$' -count=1.

This PR does not claim that one local package run proves the entire 70-minute race-UT suite improvement; CI should measure the constrained-runner effect and memory impact of the four-CN fixture.

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

Self-review comment for current head cb7e868: no blocker found.

@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 self-review of current head cb7e868.

Scope: all 3 changed files and the complete fixture lifecycle.

  • The two static policy scenarios share one 4-CN fixture but retain distinct CN policies, databases, subtest names, and metric/result oracles.
  • Each SQL connection registers cleanup before the parent cluster cleanup; therefore child DB handles close before cluster teardown, including assertion/failure paths.
  • BVT/restart remains on its dedicated lifecycle, so no later subtest depends on invalidated connections or restarted CN generation.
  • Current required CI and Ubuntu UT/race evidence are green.
  • No evidence-backed P0/P1/P2 finding.

Non-blocking note: four CNs remain alive instead of two, so the performance claim is reduced fixture startup/lifecycle overhead, not peak resident-memory reduction.

Decision: no blocker; comment-only because this is my own PR.

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

Force re-review for exact head cb7e868.

Re-read all 3 changed files and the complete lifecycle:

  • The two static policy scenarios now share one four-CN fixture, but use distinct CN indices, policies, databases, and subtest oracles. CN0/CN1 retain borrow/materialize behavior; CN2/CN3 retain disabled-gate and distributed-soft-fallback behavior.
  • The fixture is registered for cleanup, SQL handles are registered before cluster cleanup, and the separate restart/BVT lifecycle is not merged into this static-policy fixture.
  • The change reduces repeated fixture startup/lifecycle overhead; it does not claim reduced peak resident memory because four CNs remain alive.
  • Required CI and Ubuntu UT/SCA evidence are green, and the PR is mergeable without conflicts; it is only behind the base branch.

No evidence-backed P0/P1/P2 blocker found. Comment-only because this is the review requester's own PR.

@XuPeng-SH
XuPeng-SH merged commit d7d1eb4 into matrixorigin:main Sep 17, 2026
20 checks passed
@XuPeng-SH
XuPeng-SH deleted the codex/race-ut-systematic-optimization-20260916 branch September 17, 2026 01:25
VioletQwQ-0 pushed a commit to VioletQwQ-0/matrixone that referenced this pull request Sep 17, 2026
## Summary

- Consolidate the two static Arrow policy scenarios into one test-scoped
four-CN fixture.
- Keep ForceMaterialize borrow/materialize and
GateDisabled/distributed-fallback on separate CNs and databases.
- Keep BVT, restart, and rollout/drain tests on their existing dedicated
lifecycles.

## Why

Race UT evidence from matrixorigin#28956 and matrixorigin#28885 shows that the apparently slow
Arrow cases spend most of their time waiting for embedded-cluster
admission and service startup. The global cluster admission lock is an
intentional resource-safety boundary; this change reduces one compatible
lifecycle instead of bypassing that lock or increasing default cluster
concurrency.

The two static policy matrices are independent, have no restart/fault
boundary, and use disjoint state. Sharing their lifecycle removes one
cluster admission/start/close cycle without removing a policy mode,
assertion, or behavioral case.

## Coverage and lifecycle safety

- CN0: Arrow enabled, S3 enabled, distributed enabled, borrow path.
- CN1: Arrow enabled, S3 enabled, distributed enabled, ForceMaterialize
path.
- CN2: Arrow disabled, S3 enabled, distributed enabled, gate-disabled
path.
- CN3: Arrow enabled, S3 enabled, distributed disabled, soft-fallback
path.
- The fixture is owned by the combined test and closed with `t.Cleanup`
before later package tests acquire the global admission lock.
- Startup rollback retains cleanup ownership when `StartTestCluster`
returns a non-nil cluster with an error.

The former focused test names are preserved as nested subtests:

`TestArrowLoadStaticPolicyModes/TestArrowLoadForceMaterializeFallback`

`TestArrowLoadStaticPolicyModes/TestArrowLoadGateModes`

## Validation

- Baseline, two independent race lifecycles: package elapsed `32.538s`.
- Combined static-policy race test: `15.867s` in the final focused run;
earlier A/B package elapsed `17.39s`.
- Full `pkg/tests/arrowload` race run on the lifecycle consolidation:
passed, package elapsed `74.612s`, wall `90.21s`.
- Final focused command: `GOWORK=off go test -mod=readonly -race -json
./pkg/tests/arrowload -run '^TestArrowLoadStaticPolicyModes$' -count=1`.

This PR does not claim that one local package run proves the entire
70-minute race-UT suite improvement; CI should measure the
constrained-runner effect and memory impact of the four-CN fixture.
VioletQwQ-0 pushed a commit to VioletQwQ-0/matrixone that referenced this pull request Sep 17, 2026
## Summary

- Consolidate the two static Arrow policy scenarios into one test-scoped
four-CN fixture.
- Keep ForceMaterialize borrow/materialize and
GateDisabled/distributed-fallback on separate CNs and databases.
- Keep BVT, restart, and rollout/drain tests on their existing dedicated
lifecycles.

## Why

Race UT evidence from matrixorigin#28956 and matrixorigin#28885 shows that the apparently slow
Arrow cases spend most of their time waiting for embedded-cluster
admission and service startup. The global cluster admission lock is an
intentional resource-safety boundary; this change reduces one compatible
lifecycle instead of bypassing that lock or increasing default cluster
concurrency.

The two static policy matrices are independent, have no restart/fault
boundary, and use disjoint state. Sharing their lifecycle removes one
cluster admission/start/close cycle without removing a policy mode,
assertion, or behavioral case.

## Coverage and lifecycle safety

- CN0: Arrow enabled, S3 enabled, distributed enabled, borrow path.
- CN1: Arrow enabled, S3 enabled, distributed enabled, ForceMaterialize
path.
- CN2: Arrow disabled, S3 enabled, distributed enabled, gate-disabled
path.
- CN3: Arrow enabled, S3 enabled, distributed disabled, soft-fallback
path.
- The fixture is owned by the combined test and closed with `t.Cleanup`
before later package tests acquire the global admission lock.
- Startup rollback retains cleanup ownership when `StartTestCluster`
returns a non-nil cluster with an error.

The former focused test names are preserved as nested subtests:

`TestArrowLoadStaticPolicyModes/TestArrowLoadForceMaterializeFallback`

`TestArrowLoadStaticPolicyModes/TestArrowLoadGateModes`

## Validation

- Baseline, two independent race lifecycles: package elapsed `32.538s`.
- Combined static-policy race test: `15.867s` in the final focused run;
earlier A/B package elapsed `17.39s`.
- Full `pkg/tests/arrowload` race run on the lifecycle consolidation:
passed, package elapsed `74.612s`, wall `90.21s`.
- Final focused command: `GOWORK=off go test -mod=readonly -race -json
./pkg/tests/arrowload -run '^TestArrowLoadStaticPolicyModes$' -count=1`.

This PR does not claim that one local package run proves the entire
70-minute race-UT suite improvement; CI should measure the
constrained-runner effect and memory impact of the four-CN fixture.

This branch was previously deployed

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

Labels

size/S Denotes a PR that changes [10,99] lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants