Skip to content

perf: reduce race UT configuration copy and fixture costs - #29561

Merged
XuPeng-SH merged 2 commits into
matrixorigin:mainfrom
XuPeng-SH:codex/ut-race-cost-20261001
Oct 2, 2026
Merged

XuPeng-SH merged 2 commits into
matrixorigin:mainfrom
XuPeng-SH:codex/ut-race-cost-20261001

Conversation

@XuPeng-SH

@XuPeng-SH XuPeng-SH commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor

What type of PR is this?

  • Improvement
  • Test and CI

Which issue(s) this PR fixes:

Related to #29562 — race UT CPU, allocation and fixture-cost optimization.

The issue remains open until the actual CI acceptance target is demonstrated.

What this PR does / why we need it:

HAKeeper health checks repeatedly deep-copy thousands of configuration fields through reflection. Race profiles show this consumes substantial CPU and allocations throughout embedded tests. Implement the existing deepcopy hook for ConfigData, preserving detached maps/items/unknown protobuf bytes and nil/empty values. Keep the surrounding StateQuery ownership and execution path unchanged; add real-dispatch isolation tests and a benchmark populated through actual service configs and heartbeats.

Move the private two-CN view restore/restart test from the upgrade package into the existing multicn package. It now uses normal exclusive fixture admission instead of keeping its two CNs live alongside the upgrade package's shared CN. Preserve its SQL, identity, prepared-plan, restore and restart assertions, including partial-start cleanup ownership.

Reduce sequence-placement source data from 64 to two rows per UNION branch after a public physical-plan probe showed identical normalized scope structure on both coordinators. Preserve repeated per-row advancement, cross-CN continuity, every value/persisted-state assertion, and all separate concurrency/lock/cancellation tests. Correct the AP control comment to describe planning classification, without claiming a remote scan.

Validation and performance

  • Race: full protobuf/logservice and HAKeeper packages; full issues package for the copy change (1,267 terminal test/subtest outcomes identical); full multicn and upgrade packages after the fixture move.
  • Race: sequence family including concurrent sessions, parallel UNION, lock handoff and lock-wait timeout; compiler placement/DOP/noncoordinator rejection and retry-quiescence tests; seven existing fixture cancellation/rollback/cleanup-generation tests.
  • Real StateQuery benchmark, Go 1.26.4 / amd64 v1 / race / 8 CPUs: median 22.73 ms → 0.85 ms, 2,172,160 → 561,640 B/op, 49,213 → 3,892 allocs/op across three repetitions. These are component results.
  • Latest local issues pair: 368.7 → 350.2 seconds, 623.8 → 556.1 CPU-seconds. A brief sibling-core probe affected the control; this is directional evidence, not a precise attributable improvement or a CI extrapolation.
  • Preserve the fulltext stress test's 20 rounds and 240-second deadline. The targeted treatment run passed on HDD; a retained cumulative baseline deadline failure remains unexplained and is not a successful performance baseline.

Acceptance still pending: reduce the actual CI race-UT wall time by at least ten minutes while lowering overall CPU/memory. Local measurements do not prove this target. Keep cache seeding disabled: the bounded local registry import timed out with zero entries published and completed cleanup. This PR adds no cache, scheduler, timeout extension, skipped tests or shortened stress rounds.

Design and independent final implementation review use actual gpt-6.1-sol with xhigh reasoning. Final implementation review: PASS, no blocking findings. Incremental configured vet and golangci-lint v2.6.2 (built with Go 1.26.4): PASS, 0 issues.

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

This branch was previously deployed

1 inactive deployment
ci — 1fc852f8 Deployed Oct 2, 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