Repository navigation
[SignalR] Reduce hub invocation activity overhead - #69557
martincostello wants to merge 8 commits into
Conversation
- Pass hub activity tags to `ActivitySource` in a reusable thread-static list to avoid boxing. - Cache the activity display name per hub method. - Cache the link to the connection's original activity per connection. - Avoid performance regression when using `TagList`.
|
Thanks for your PR, @martincostello. Someone from the team will get assigned to your PR shortly and we'll get it reviewed. |
There was a problem hiding this comment.
Copilot review overview
🔵 Needs a closer look
Low-level thread-static reuse and concurrent telemetry caching warrant final human review.
Review effort: Balanced
Findings: None
What changed in this PR
Optimizes SignalR hub invocation telemetry to reduce traced-request allocations and execution time.
Changes:
- Reuses tag collections and cached activity links/display names.
- Generalizes endpoint tagging for
TagListand list-backed collections. - Adds activity behavior tests and a telemetry benchmark.
| File | Description |
|---|---|
HubConnectionHandlerTests.Activity.cs |
Tests resolved activity method names. |
HubMethodDescriptor.cs |
Caches activity display names. |
DefaultHubDispatcher.cs |
Reuses tags and cached telemetry metadata. |
HubConnectionContext.cs |
Caches the original activity link. |
DefaultHubDispatcherTelemetryBenchmark.cs |
Benchmarks invocation telemetry overhead. |
ConnectionEndpointTags.cs |
Supports generic tag collections without boxing. |
💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.
|
Looks like this PR hasn't been active for some time and the codebase could have been changed in the meantime. |
|
Looks like this PR hasn't been active for some time and the codebase could have been changed in the meantime. |
|
Looks like this PR hasn't been active for some time and the codebase could have been changed in the meantime. |
Reduce hub invocation activity overhead
Reduce the overhead of activity for SignalR hub invocations.
Description
ActivitySourcein a reusable thread-static list to avoid boxing.TagList.Benchmarks
DefaultHubDispatcherTelemetryBenchmark.InvocationTraced invocations on
mainalso pay a JIT AVX to SSE transition penalty that the branch avoids (dotnet/runtime#133784). WithDOTNET_EnableAVX=0, a traced invocation takes 539.9 ns onmainand 492.2 ns on the branch.Detailed results
main
PR