Skip to content

perf: non-cancellable SendPump channel waits (issue 157) - #203

Merged
SunSi12138 merged 3 commits into
devfrom
feature/issue-157-sendpump-wait
Aug 14, 2026
Merged

perf: non-cancellable SendPump channel waits (issue 157)#203
SunSi12138 merged 3 commits into
devfrom
feature/issue-157-sendpump-wait

Conversation

@SunSi12138

Copy link
Copy Markdown
Owner

Summary

Issue #157 的 investigation + validation 完成,"允许实施的条件"全部满足,落地最小改动:

  1. perfRpcSession.SendPump.WaitToReadAsync() 的正常 idle 等待由 WaitToReadAsync(_sessionCancellation) 改为 WaitToReadAsync(CancellationToken.None)。所有 terminal 路径均已证明最终会 TryComplete channel(Fault/DisposeAsync/BeginShutdown → pump.Stop();泵内故障 → ReportFaultOnce),TimedBatch pending read(WaitForMoreUntilDeadlineAsync)与 transport flush 的 cancellation 语义不变。
  2. fix(验证期间发现的既有缺口):pending.Add(frame) 提前到 WriteFrame 之前——transport output 在写出前故障时,已出队帧改由 terminal ReleaseBatch 统一归还/完成,flush completion 不再永久挂起(此前调用方会无限等待)。
  3. test:新增 8 个 bounded-completion idle-shutdown 测试(Dispose / Stop / remote-disconnect fault / output fault / flush-pending / TimedBatch deadline park / concurrent producers)。
  4. bench:新增 SendPumpIdleWakeBenchmarks(4 场景 idle→wake 周期)与 SendPumpTimedBatchDeadlineBenchmarks

Validation

环境:192.168.31.242(32 核,SDK 10.0.110 / runtime 10.0.10),基准 taskset -c 2,3 固定 CPU,baseline(修复帧泄漏后) vs prototype(再加 wait 改动) 同机对比。

  • 单测:939 例,两树失败集合完全一致(9 例均为既有 flake,见 Notes);本 PR 新增 8 例两树全过。
  • raw probe(net10.0.10, 20 万周期/模式):可取消 token 每次 wait 注册分配 96 B、Gen0 1/200k;CancellationToken.None 0 B、0 Gen0 —— 确认命中 runtime UnboundedChannelReader.WaitToReadAsync_waiterSingleton.TryOwnAndReset() reusable-waiter 路径(per-channel,无跨 channel 共享)。
  • idle→wake 周期(LowLatency/Balanced/Throughput/CustomTimedBatch):Allocated 592 B → 496 B(-96 B / -16.2%),Gen0 0.0343 → 0.0286 /1000op;Mean/P50/P95/P99/Op/s 持平。
  • SendPumpFlushBenchmarks 24 组:全部 -96 B;p50/p95/p99 无回退,Op/s 持平或略升。
  • TimedBatch deadline 周期仍有 547 B(AsTask + Task.WhenAny 主导)→ 按 issue 指引作为 follow-up 另行开 issue 研究。

Notes

  • 两树单测各有 9 例失败(CompressionFrameTestsRuntimeSnapshotShouldFreezeAProvidersValidatedWireProfile):系 ManifestSourceIsolationTests 毒化 manifest 注册窗口与并行 Build() 的既有竞态(32 核放大;[NotInParallel] 只约束同组测试)。与本 PR 无关,两树失败集合一致。

Closes #157

@SunSi12138

Copy link
Copy Markdown
Owner Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Chef's kiss.

Reviewed commit: 61fcdad17b

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

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