Repository navigation
Reduce race UT CPU cost and bootstrap polling waits - #29575
Conversation
Qodo reviews are paused for this user.Troubleshooting steps vary by plan Learn more → On a Teams plan? Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center? |
XuPeng-SH
left a comment
There was a problem hiding this comment.
Code-review conclusion: APPROVE recommendation, zero blocking findings at 90c71d3bd891550a7b7f343b8bb94fae93b64d8a, against base/merge-base 9078a8bd87af49ea06f52e09d64e7740122aea61. Reviewed every hunk in all eleven files, #29562, prior comments, and the affected producers, consumers, reset/restart and shutdown paths. No subagents.
The design is proportional to the performance problem. Expression traversal is optimized at its existing owner; heartbeat hints originate at the RSM owner after accepted state changes and feed the existing serial checker; CN startup consumes its existing admission notification and refreshes authoritative inventory. There is no second readiness state machine, execution worker, cache, persistent field, wire-format change or configuration switch. Production is +121/-19 (net +102), tests +457/-1 (net +456 across six files), documentation unchanged.
- Expression traversal: scalar fields/elements cannot contain expression roots. Exported containers, interfaces, map values, aliases, pointer-cycle handling, repeated Expr visits and visitor errors keep their existing semantics. Map keys and named pointers retain their prior behavior. Checked validation after decode, remote-expression feature detection, bound string-domain traversal and planner visitors. Existing/new validation tests remain useful independently of the performance result.
- HAKeeper hints: compared accepted CN state, including one-time de-admission by a rejected obsolete heartbeat. Stable Tick/load/configuration/address/term/ordinary receipt changes do not generate checker hints.
Result.Dataremains the existing CommandBatch; the resolved Dragonboat NoOP-session path does not cache the new result hint in persisted client-session state. Lost responses, follower/no-worker stores, and same-count replica replacements retain periodic convergence. Extra checks preserve the configured periodic schedule and absolute bootstrap deadline. - CN startup: a notification only advances the next refresh. Fresh inventory still needs the current UUID/address/commit/generation and appropriate query membership. Revocation and bootstrap error/cancellation are checked before and after refresh; failed refresh cannot authorize startup. The raw registration, admission/ingress handoff, authoritative query inventory and public frontend order remain intact.
| Unhappy-path invariant | Closure |
|---|---|
| Q1: one effective owner | The store owns a capacity-one channel for its lifetime; tickerStopper joins the existing checker/task workers before NodeHost close. CN owns and retires each retry timer. |
| Q2: waits terminate | Notification sends are nonblocking, including nil/disabled and shutdown cases. Existing checker RPC deadlines, stopper cancellation and CN refresh contexts remain effective. |
| Q3: growth is bounded | At most one empty notification waits per store. No retained callback/state cache is added; expression traversal keeps its existing per-call seen set. A queued old hint carries no stale state across local replica restart. |
Independent reviewer validation used Go 1.26.4 on darwin/arm64 with a complete native generation built from this head by make -j8 cgo:
- The new plan-container and RSM accepted-readiness/barrier tests passed in normal mode. Focused race checks passed for checker cadence, bootstrap deadline and failure, acknowledged-command lost response, CN cancellation/refresh failure and admission notifications.
- Each of
TestHAKeeperCheckWakeupCoalescesAfterShutdown,TestHAKeeperCheckWakeupRechecksDuringActiveCheckandTestClusterSelfReadinessUsesAdmissionNotificationpassed 100 race repetitions in a single process, run individually. JSON measurement was 0/0.14/0 seconds, selecting the 100-repeat cap under the 30-second stress budget. Every command reached terminal exit 0. - A reviewer-only Go-overlay test exercised the added notification branch, then returned matching inventory during the second refresh together with upgrade error, owner cancellation, generation revocation or refresh failure. All four rejection cases and the success control passed under race. Repository source/tests were not edited.
- Formatting, diff checks and the isolated checkout were clean.
Reused current-head CI after verifying SHA, Go 1.26.4 linux/amd64, race invocation, owning-package selection and terminal results in downloaded logs/checkpoints. All four owning packages were selected; embed, isolated issues, SQL integration, multi-CN and upgrade execution stages returned status 0. Existing replica restart/voting-role, recovery and command assertions were preserved. Linux/arm64 SCA, build, coverage and PROXY/pessimistic BVT also succeeded. Compile-only/skipped stages are not counted as execution evidence. The PR's broad normal-package results remain author-reported evidence.
The expression optimization has a separate matched component check: the delivered six-shape benchmark ran sequentially with GOMAXPROCS=1, three 150ms samples, identical native artifacts and fixtures, using only the base production file through a Go overlay for the control. Median ordinary owner traversal was 151.7 → 34.7 μs, wide owner 1.450 → 0.335 ms, and direct Expr 10.46 → 10.45 ns; allocations did not increase in any shape. The same new container tests passed against both implementations. The fixtures/benchmarks cover distinct container, validation and size contracts without weakening existing assertions or introducing another cluster fixture.
Performance acceptance is limited to the demonstrated component improvements. The PR's paired isolated-race 222.90 → 167.63 seconds result is attributed to the author. The completed current CI Unit Testing step took 62m56s; it is not a matched causal comparison and does not establish a ten-minute reduction. Keep #29562 open until its actual CI/CPU/memory target is measured. The projected 2–4 minute saving is not treated as an observed result.
There are no earlier actionable review findings or unresolved threads. The authenticated account is also the PR author (XuPeng-SH), so GitHub permits this submitted COMMENT but not a formal self-APPROVE. This records the completed code-review recommendation and its evidence.
Embedded race tests repeatedly pay the normal HAKeeper check interval after bootstrap, registration, and admission evidence has already committed. Wake the existing checker on those state changes, and let CN startup reuse its existing admission notification before refreshing authoritative inventory. Stable heartbeats, the periodic fallback, bootstrap deadline, command delivery, and readiness requirements retain their existing contracts.
The earlier expression-owner traversal optimization remains in this PR: skip scalar payloads while preserving traversal of exported expression-bearing fields. Neither optimization removes test scenarios or weakens existing assertions.
Design and cost
Measured result
Paired complete
pkg/tests/issues/isolatedrace runs on the same eight pinned CPUs with runtime data on NVMe. The baseline is phase3 commitac340a83on main5a09e1ff; the comparison adds this startup change, so subsequent upstream vector improvements are not attributed to this patch.All 45 test/subtest PASS identities are identical in both runs. The CN-notification-only experiment did not improve wall time; the complete committed-state chain is necessary for the measured result.
The latest completed racing job spent 62m46s in UT and reported 41 service starts totaling 10.64 minutes. These measurements suggest approximately 2–4 minutes of CI savings, not an observed CI result or proof that the CI target has been achieved. Keep #29562 open until comparable CI evidence confirms the result.
Validation and review
make err-checkpass.