Feat/Add Mediator support to benchmark suites and update documentation#350
Conversation
- 新增 StreamStartupBenchmarks 的 Mediator 初始化与 cold-start benchmark。 - 更新 stream request 与 handler 契约以接入 NuGet Mediator source-generated concrete path。
- 更新 StreamingBenchmarks 的 XML 返回值注释并收口 README 中的 stream startup/gap 描述。 - 补充 cqrs-rewrite tracking 与 trace,记录 PR #349 合并后的新基线、startup parity 进展与下一恢复点。
- 补充 RequestInvokerBenchmarks 公开 benchmark 方法缺失的 XML returns 契约 - 补充 RequestLifetimeBenchmarks 公开 benchmark 方法缺失的 XML returns 契约
- 补充 RequestBenchmarks 公开 benchmark 方法的 XML returns 契约 - 补充 RequestPipelineBenchmarks 公开 benchmark 方法的 XML returns 契约
- 补充 stream 与 notification benchmark 公开方法缺失的 XML returns 契约 - 更新 request startup benchmark 的返回值文档说明 - 同步 cqrs-rewrite 的批处理恢复点与停点决策
- 更新 README 中 stream/request/notification startup benchmark 的覆盖矩阵与适用边界 - 补充 cqrs-rewrite public tracking 与 trace,记录本轮误报剔除、docs-only 收尾与停止判断
- 新增 RequestLifetimeBenchmarks 的 Mediator lifetime parity,并按编译期常量分支生成 Singleton、Scoped、Transient 宿主 - 更新 benchmark README 的 request lifetime coverage 与当前缺口说明,使其反映最新对照矩阵 - 修复 RequestBenchmarks 与 NotificationBenchmarks 的 XML 文档漂移,并同步 ai-plan 恢复点与验证结论
|
| Filename | Overview |
|---|---|
| GFramework.Cqrs.Benchmarks/Messaging/BenchmarkHostFactory.cs | Updated CreateMediatorServiceProvider to explicitly set ServiceLifetime.Singleton and expanded the doc comment explaining why the lifetime is fixed to match the source-generator constraint. |
| GFramework.Cqrs.Benchmarks/Messaging/StreamStartupBenchmarks.cs | Added Mediator support: new _mediatorServiceProvider/_mediator fields, Initialization_Mediator and ColdStart_Mediator benchmarks, and a tri-contract BenchmarkStreamHandler with explicit interface implementations for GFramework, Mediator, and MediatR. |
| GFramework.Cqrs.Benchmarks/Messaging/RequestBenchmarks.cs | Added SendRequest_Mediator benchmark and the corresponding _mediatorServiceProvider/_mediator fields; _mediatorServiceProvider is correctly disposed in Cleanup. |
| GFramework.Cqrs.Benchmarks/Messaging/NotificationBenchmarks.cs | Added PublishNotification_Mediator benchmark; description updated to mention Mediator as a third comparison target; disposal is correctly included. |
| GFramework.Cqrs.Benchmarks/Messaging/RequestStartupBenchmarks.cs | Added Initialization_Mediator and ColdStart_Mediator benchmarks and the supporting _mediatorServiceProvider/_mediator fields; _mediatorServiceProvider is correctly disposed. |
| GFramework.Cqrs.Benchmarks/Messaging/RequestLifetimeBenchmarks.cs | Updated class remarks to explicitly document why Mediator is excluded from the lifetime matrix (compile-time fixed lifetime); no functional changes. |
Flowchart
%%{init: {'theme': 'neutral'}}%%
flowchart TD
subgraph Steady-State Benchmarks
RB[RequestBenchmarks] --> RB_M[SendRequest_Mediator]
NB[NotificationBenchmarks] --> NB_M[PublishNotification_Mediator]
NFO[NotificationFanOutBenchmarks] --> NFO_M[PublishNotification_Mediator]
SB[StreamingBenchmarks] --> SB_M[Stream_Mediator]
end
subgraph Startup Benchmarks
RSB[RequestStartupBenchmarks] --> RSB_I[Initialization_Mediator]
RSB --> RSB_C[ColdStart_Mediator]
SSB[StreamStartupBenchmarks] --> SSB_I[Initialization_Mediator]
SSB --> SSB_C[ColdStart_Mediator]
end
subgraph Factory
BHF[BenchmarkHostFactory.CreateMediatorServiceProvider]
BHF --> ADD[services.AddMediator - ServiceLifetime.Singleton]
end
RB_M --> BHF
NB_M --> BHF
NFO_M --> BHF
SB_M --> BHF
RSB_I --> BHF
RSB_C --> BHF
SSB_I --> BHF
SSB_C --> BHF
Reviews (2): Last reviewed commit: "fix(cqrs-benchmarks): 修正Mediator基准运行时配置" | Re-trigger Greptile
Summary
Test ResultsDetails
Insights
Fail Rate
build-and-test: Run #1111
🎉 All tests passed!Slowest Tests
± Comparison with run #1110 at 3a47abe | 🍂 No flaky tests detected across all runs. | ⏱️ Measured over 53 runs. Github Test Reporter by CTRF 💚 |
✅
|
| Descriptor | Linter | Files | Fixed | Errors | Warnings | Elapsed time |
|---|---|---|---|---|---|---|
| dotnet-format | yes | 1 | no | 5.75s | ||
| ✅ REPOSITORY | gitleaks | yes | no | no | 9.23s | |
| ✅ REPOSITORY | trufflehog | yes | no | no | 6.24s |
Detailed Issues
⚠️ CSHARP / dotnet-format - 1 error
Welcome to .NET 9.0!
---------------------
SDK Version: 9.0.114
----------------
Installed an ASP.NET Core HTTPS development certificate.
To trust the certificate, run 'dotnet dev-certs https --trust'
Learn about HTTPS: https://aka.ms/dotnet-https
----------------
Write your first app: https://aka.ms/dotnet-hello-world
Find out what's new: https://aka.ms/dotnet-whats-new
Explore documentation: https://aka.ms/dotnet-docs
Report issues and find source on GitHub: https://github.com/dotnet/core
Use 'dotnet --help' to see available commands or visit: https://aka.ms/dotnet-cli
--------------------------------------------------------------------------------------
Unhandled exception: System.Exception: Restore operation failed.
at Microsoft.CodeAnalysis.Tools.CodeFormatter.OpenMSBuildWorkspaceAsync(String solutionOrProjectPath, WorkspaceType workspaceType, Boolean noRestore, Boolean requiresSemantics, String binaryLogPath, Boolean logWorkspaceWarnings, ILogger logger, CancellationToken cancellationToken)
at Microsoft.CodeAnalysis.Tools.CodeFormatter.FormatWorkspaceAsync(FormatOptions formatOptions, ILogger logger, CancellationToken cancellationToken, String binaryLogPath)
at Microsoft.CodeAnalysis.Tools.FormatCommandCommon.FormatAsync(FormatOptions formatOptions, ILogger`1 logger, CancellationToken cancellationToken)
at Microsoft.CodeAnalysis.Tools.Commands.RootFormatCommand.FormatCommandDefaultHandler.InvokeAsync(ParseResult parseResult, CancellationToken cancellationToken)
at System.CommandLine.Invocation.InvocationPipeline.InvokeAsync(ParseResult parseResult, CancellationToken cancellationToken)
See detailed reports in MegaLinter artifacts
Set VALIDATE_ALL_CODEBASE: true in mega-linter.yml to validate all sources, not only the diff

Show us your support by starring ⭐ the repository
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (5)
✅ Files skipped from review due to trivial changes (2)
📜 Recent review details⏰ Context from checks skipped due to timeout of 900000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
🧰 Additional context used📓 Path-based instructions (5)**/*.cs📄 CodeRabbit inference engine (CLAUDE.md)
Files:
ai-plan/public/**📄 CodeRabbit inference engine (AGENTS.md)
Files:
ai-plan/**📄 CodeRabbit inference engine (AGENTS.md)
Files:
ai-plan/public/**/todos/**📄 CodeRabbit inference engine (AGENTS.md)
Files:
ai-plan/public/**/traces/**📄 CodeRabbit inference engine (AGENTS.md)
Files:
🧠 Learnings (2)📚 Learning: 2026-04-06T12:45:43.921ZApplied to files:
📚 Learning: 2026-05-11T06:15:15.057ZApplied to files:
🪛 LanguageToolai-plan/public/cqrs-rewrite/traces/cqrs-rewrite-migration-trace.md[uncategorized] ~58-~58: 您的意思是“"不"齐”? (BU) [uncategorized] ~60-~60: 您的意思是“"不"齐”? (BU) [uncategorized] ~74-~74: 动词的修饰一般为‘形容词(副词)+地+动词’。您的意思是否是:新"地"实现 (wb4) [uncategorized] ~78-~78: 您的意思是“"不"跑”? (BU) [uncategorized] ~147-~147: 单纯方位词与名词结合不加“的”,您的意思是否是:"契约下 或 契约以下 或 契约的下"边 (wa2) [uncategorized] ~157-~157: 您的意思是“"不"公开”? (BU) [uncategorized] ~160-~160: 您的意思是“"不"公开”? (BU) [uncategorized] ~163-~163: 您的意思是“"不"公开”? (BU) 🔇 Additional comments (10)
📝 WalkthroughWalkthrough本 PR 为请求和流基准添加 NuGet 源生成 Generated Mediator 路径、为请求/流记录与处理器实现 Mediator 契约、增加对应基准方法,并在多处基准方法上补齐 变更Mediator 奇偶校验和文档收口
Sequence Diagram(s)sequenceDiagram
participant GlobalSetup
participant MediatorHost as Mediator ServiceProvider
participant GeneratedMediator
participant SendRequest as SendRequest_Mediator()
participant Handler as BenchmarkRequestHandler
GlobalSetup->>MediatorHost: Create/resolve GeneratedMediator per lifetime
SendRequest->>MediatorHost: (if Scoped) Create scope and resolve GeneratedMediator
SendRequest->>GeneratedMediator: GeneratedMediator.Send(BenchmarkRequest)
GeneratedMediator->>Handler: Invoke IRequestHandler.Handle
Handler-->>GeneratedMediator: Return BenchmarkResponse
GeneratedMediator-->>SendRequest: Return ValueTask<BenchmarkResponse>
sequenceDiagram
participant GlobalSetup
participant Factory as CreateMediatorServiceProvider()
participant MediatorHost as ServiceProvider
participant GeneratedMediator
participant Initialization as Initialization_Mediator()
participant ColdStart as ColdStart_Mediator()
GlobalSetup->>Factory: Build minimal Mediator host
Factory-->>MediatorHost: Return configured ServiceProvider
Initialization->>MediatorHost: Resolve GeneratedMediator
Initialization-->>Initialization: Return GeneratedMediator instance
ColdStart->>GeneratedMediator: CreateStream(BenchmarkStreamRequest)
GeneratedMediator->>ColdStart: Return IAsyncEnumerable and yield first item
ColdStart-->>ColdStart: Consume first element and complete
评审工作量评估🎯 3 (中等) | ⏱️ ~25 分钟 可能相关的 PR
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
@coderabbitai full review |
✅ Actions performedFull review triggered. |
- 修正 BenchmarkHostFactory 的 Mediator 宿主接线,统一使用 Singleton 编译期 lifetime - 更新 RequestLifetimeBenchmarks 与 README,撤回当前不可运行的 Mediator 生命周期矩阵并同步覆盖边界 - 补充 cqrs-rewrite 跟踪,记录 PR #350 评审真值、故障根因与 smoke run 验证结果
Summary
Test ResultsDetails
Insights
Fail Rate
build-and-test: Run #1112
🎉 All tests passed!Slowest Tests
± Comparison with run #1111 at 61d23ea | 🍂 No flaky tests detected across all runs. | ⏱️ Measured over 54 runs. Github Test Reporter by CTRF 💚 |
Summary by CodeRabbit
新功能
文档
修复 / 维护