Skip to content

perf(client): skip health lock without cooldowns - #624

Merged
ketor merged 1 commit into
dingodb:mainfrom
ketor:trn15/hotpath-lean-df500248
Nov 28, 2026
Merged

ketor merged 1 commit into
dingodb:mainfrom
ketor:trn15/hotpath-lean-df500248

Conversation

@ketor

@ketor ketor commented Nov 28, 2026

Copy link
Copy Markdown
Contributor

Scope — bounded healthy-peer hot path (verification in progress)

Draft only; not ready or merge-approved. Raw head e00342bd8b17ffe232950477d1ea5baa7852ec23, tree 13cbadc1bb3daf2740047b6e7ddb43726cf76c66, parent df5002482c45d1e86d99e14aa95f9f4718e54882.

Changes only:

  • src/client/peer_health.h: a Healthy() call may return true immediately when the existing atomic cooldown-count is zero. This is the same result as examining the original empty map, without map access or redundant allocation. Every nonempty/active/expired cooldown still takes the original mutex, including recovery-trial admission; no map entry is removed from the lock. checks_ still increments exactly once per call on both paths.
  • test/client/client_metrics_test.cc: verifies that both the fast empty-map check and an active-cooldown check remain counted.

No environment parsing, default, API/wire schema, RDMA, STO-36 or unrelated application behavior changed. This is not a change to coding policy, timed-deadline bypass, or global getenv caching.

Correctness audit

An independent concurrency/caller review found zero must-fix findings. It audited all cooldown insertion/erasure/LRU/recovery paths and all 17 production KVClient::health_.Healthy call sites. It confirmed that checks counts remain atomic exactly once, single-trial admission remains locked, neutral kResourceExhausted does not poison a peer, and an initial zero observed during first-incident publication serializes the overlapping check before that incident. Existing active/expired cooldowns retain a positive count and therefore cannot take the unlocked path. No uninitialized or non-atomic state was introduced.

Baseline and candidate independently built binaries each passed:

  • peer_health_test: 22/22
  • peer_health_stall_test: 12/12, including concurrent recovery admission and neutral immediate retry
  • client_metrics_test: 26/26, including the new both-path health counter assertion and ResourceExhausted attribution checks

The review did not treat timing alone as concurrency proof, and did not run or claim sanitizer, physical RDMA/full-matrix, maintained-full, CI or rollout approval. Those are separate required gates.

Isolated helper microbenchmark

Exact empty-cooldown PeerHealth::Healthy() calls, same peer string and separately compiled before/after binaries; four alternating pairs per scenario, with process exit 0 and expected admission/metric values.

Scenario Before mean After mean Helper elapsed ratio
1 thread × 40,000,000 calls 391.993 ms (9.800 ns/call) 64.560 ms (1.614 ns/call) 6.07×
4 threads × 8,000,000 calls each (32,000,000 total) 812.438 ms (25.389 ns/call) 241.602 ms (7.550 ns/call) 3.36×

The total benchmark runner took 6.12 seconds. These figures describe this isolated helper only, not RPC latency, distributed throughput, multi-host performance, or production speedup. They do not imply completion of all TRN-15 work.

Remaining gates

Fresh maintained full regression and public CI on this exact raw head, final evidence review, and normal ready/queue checks are still required. Complete-head recovery evidence is preserved before publishing the branch. This draft does not claim merge, rollout, universal ABI change, or completion of TRN-15/M4/M6.

- Reuse the existing atomic cooldown-count gate on the healthy common path.
- Preserve recovery-trial locking and health-check metrics.
@ketor
ketor force-pushed the trn15/hotpath-lean-df500248 branch from e00342b to 4965dfa Compare November 28, 2026 19:34
@ketor

ketor commented Nov 28, 2026

Copy link
Copy Markdown
Contributor Author

Verification for exact head 4965dfac

Verified commit 4965dfac4d9800110b83e7ca820dd231a057c4e9, tree b7220ea762458b02fbcb441709adbb51724f95c9, sole parent d75063a38eae08da74f7111d1b55a3d3df873069. This is the owned candidate rebased after PR #623; range-diff from the earlier raw e00342bd… is 1:1 and both owned files are byte-identical.

Scope: exactly two files: src/client/peer_health.h +5/−1 and test/client/client_metrics_test.cc +1/−0. The zero-cooldown-count fast admission retains exactly one relaxed checks_ increment on either path. Any active or expired nonzero cooldown continues through the original mutex and single recovery-trial protocol; neutral local errors and clock handling are unchanged. Independent source review audited all 17 production admission callers, including publication/erasure ordering and unknown-peer behavior.

Fresh focused validation: 50 PASS / 0 SKIP / 0 FAIL — 22 PeerHealth, 12 PeerHealthStall, 3 ClientMetrics, 5 KvClientHealth, and 8 ConnectionPool.

Fresh maintained full: Release/Ninja/GNU C++, tests/RDMA/io_uring ON, private mount/tmp, sequential maintained selection, six canonical exclusions only:

  • discovery 2111, selected/executed 2105;
  • 2007 PASS / 98 SKIP / 0 FAIL;
  • raw ledger 2001 / 104 / 0, with only six literal name-only Skipped corrections, each independently proved by its own CTest Passed plus JUnit run/zero-skip evidence;
  • all 32 required migration, health, pool, slot/reclaim, RDMA safety/batch, and block/depth geometry cases actually ran and passed;
  • all 98 skips classified into nine physical/opt-in categories with zero unclassified: 53 CUDA, 19 two-active-rail, 12 benchmark, 4 real-NVMe, 3 MDS load, 3 helper entry, 2 timing-only, 1 CRC32C, 1 O_DIRECT;
  • runtime 2026-11-29 03:43:03 → 03:59:52 +08, actual runner rc 0.

Unit dfkv-trn15-hotpath-full-4965dfac.service, MainPID 2599743, invocation 7a9f4f3943464989a02f295c6f634ea6; coordinator completed/0, full-regression claims empty, and no owned full-unit process remained.

Output reconciliation preserved the raw facts: 825 records have the literal CTest output-removal marker (198 RUN/OK absent, 561 RUN visible/OK absent, 66 both visible); five test-name truncat coincidences are actual PASS cases, not truncation.

Public CI: run 46181879364, attempt 1, is 13/13 successful jobs, all on exact 4965dfac….

Independent final integration review: GO / 0 must-fix, SHA-256 6bccdb7dc0fc3fad6a26eb190e653954565f45955adfa9a0f55534743cf4158b.

Full evidence archive SHA-256 5ddc477a71fed7ba70d970e87ef22213d276dba2c5b4044c2a4672573e74a027; complete-history source bundle f19e0180909efc541d45df070eb94eba4c0c91fef8d84d60b7014b7e7ff26e45; 6948 independently checked remote artifact hashes and 7355 verified delivery manifest records.

The preserved isolated helper microbenchmark measured only this empty-map helper; it is not RPC/RTT/throughput/SLA evidence, does not cover all races or distributed behavior, and does not establish production readiness, the rest of TRN-15, or M2/M3/M5/M6. Skipped CUDA/two-rail/NVMe/opt-in paths and any default/new-model/warm behavior are not certified by this result.

@ketor
ketor marked this pull request as ready for review November 28, 2026 20:25
@ketor
ketor added this pull request to the merge queue Nov 28, 2026
Merged via the queue into dingodb:main with commit 1b3b00f Nov 28, 2026
13 checks passed
@ketor
ketor deleted the trn15/hotpath-lean-df500248 branch November 28, 2026 20:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant