Skip to content

perf(runtime): reduce timed RPC emission overhead and restore batching - #677

Merged
SunSi12138 merged 37 commits into
devfrom
fix/release-unary-emission-overhead
Sep 12, 2026
Merged

SunSi12138 merged 37 commits into
devfrom
fix/release-unary-emission-overhead

Conversation

@SunSi12138

@SunSi12138 SunSi12138 commented Sep 12, 2026

Copy link
Copy Markdown
Owner

Timed Unary requests currently create and supervise a send-completion task for every request. They also force a transport flush per timed frame, even when more requests are already queued. The release ABA against published 1.1.1 exposed higher client allocation and lower high-concurrency throughput on main b3078000d80a7400373ea5ae67a1e3ffd8e5dbcc.

The existing send pump now reports queued request failures directly to the pending-call table. It captures the request ID before returning the buffer and invokes the failure owner outside the admission lock. Successful Unary calls still complete only on their response; a request that expires at emission still completes with DeadlineExceeded without requiring a timer callback. Pooled frames retain the observer in their existing completion-state reference.

Ready timed requests can also share one bounded publication batch. The pump acquires one output span, copies the complete retained suffix, then samples the monotonic clock once. It removes expired requests, compacts surviving frames in order, stamps their remaining budgets, and starts FlushAsync before expired-request callbacks or telemetry. A timed batch never waits for new arrivals or the configured batch timer; existing size thresholds, LowLatency flushes, and the 64-frame progress interleave remain enforced.

Validation:

  • Full non-incremental Release build: zero warnings/errors.
  • Unit: Passed 1825, Failed 0, Skipped 0. Integration: Passed 451, Failed 0, Skipped 0.
  • Final focused emission tests: Passed 9, Failed 0, Skipped 0. This includes mixed timed/untimed batches and expiration at the first, middle, last, or every timed request, checking wire order, exact remaining budgets, callback timing, and returned owners/reservations.
  • TimedUnaryShouldObserveEmissionWithinTheSendPumpLifetime fails on unchanged b307800 production code and passes with the correction. TimedUnaryDroppedAtEmissionShouldCompleteWithoutDeadlineTimerCallback remains passing.
  • Negative control for QueuedTimedRequestsShouldSharePublicationAndDropExpiredFrames: all five original cases fail against pre-batching 6a22b42 production code; all pass with batching restored. The final cases additionally retain an untimed frame inside the compacted suffix.
  • The first correction alone (6a22b42), measured with BenchmarkDotNet 0.15.8 on Apple M4, .NET 10.0.11, Server GC, processor count 8, reduces timed loopback Add allocation from 1534 to 936 B/op and completed work items from approximately 8 to 7. Untimed allocation stays 768 B/op. This is allocation evidence for that first correction; measured time differences overlap variation and are not claimed as throughput improvements.

Final BenchmarkDotNet comparison of b307800 versus 0141a85: 64 concurrent Add RPCs per burst, reported per RPC; 8192 bursts per iteration, six warmups, 12 measured iterations, outliers retained, DOTNET_PROCESSOR_COUNT=8, the same Apple M4/.NET 10.0.11/Server GC environment. Timed mean is 5.723 ± 0.1113 us before versus 1.860 ± 0.0364 us after (99.9% confidence half-widths); allocation is 1118 versus 452 B/RPC, completed work items 3.5644 versus 1.3167. Untimed control is 1.729 ± 0.0355 versus 1.726 ± 0.0228 us, with 284 B/RPC in both. Measured lock-contention counters round to zero in all four cases.

The separate four-core server + VM/Mac diagnostic compares 6a22b42 to 0141a85, with a fresh server per case/phase. High-concurrency Add: A1 231974, B 285698, A2 218950 completed/s; B server CPU 2.48 cores versus A approximately 3.66. High Echo(256): 148190 / 164251 / 152175 completed/s, with B p99 2095 us versus A 2347/2353 us. Add p99 was higher (2895 versus 1179/998 us) and A drift was 5.6%; final-main validation must review those explicitly.

These results validate the two focused corrections. Release publication remains blocked on final-main validation and the separate low-concurrency OneWay/upload investigation against published 1.1.1. The release tag has not been created. Final performance validation will use the resulting exact main commit and its gated packages.

dependabot Bot and others added 30 commits August 9, 2026 18:13
Bumps TUnit from 1.63.0 to 1.64.6

---
updated-dependencies:
- dependency-name: TUnit
  dependency-version: 1.64.6
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: testing
...

Signed-off-by: dependabot[bot] <support@github.com>
…bf2f9

Bump the testing group with 1 update
Bumps [github/codeql-action/init](https://github.com/github/codeql-action) from 4.37.4 to 4.37.6.
- [Release notes](https://github.com/github/codeql-action/releases)
- [Changelog](https://github.com/github/codeql-action/blob/main/CHANGELOG.md)
- [Commits](github/codeql-action@f205ea1...5595cca)

---
updated-dependencies:
- dependency-name: github/codeql-action/init
  dependency-version: 4.37.6
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
…ub/codeql-action/init-4.37.6

Bump github/codeql-action from 4.37.4 to 4.37.6
Bumps Microsoft.Extensions.DependencyInjection from 10.0.10 to 10.0.11
Bumps Microsoft.Extensions.DependencyInjection.Abstractions from 10.0.10 to 10.0.11
Bumps Microsoft.Extensions.Diagnostics.HealthChecks from 10.0.10 to 10.0.11
Bumps Microsoft.Extensions.Hosting from 10.0.10 to 10.0.11
Bumps Microsoft.Extensions.Logging to 10.0.11
Bumps Microsoft.Extensions.Logging.Abstractions from 10.0.10 to 10.0.11
Bumps Microsoft.Extensions.Logging.Console from 10.0.10 to 10.0.11

---
updated-dependencies:
- dependency-name: Microsoft.Extensions.DependencyInjection
  dependency-version: 10.0.11
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: microsoft-extensions
- dependency-name: Microsoft.Extensions.DependencyInjection.Abstractions
  dependency-version: 10.0.11
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: microsoft-extensions
- dependency-name: Microsoft.Extensions.Diagnostics.HealthChecks
  dependency-version: 10.0.11
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: microsoft-extensions
- dependency-name: Microsoft.Extensions.Hosting
  dependency-version: 10.0.11
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: microsoft-extensions
- dependency-name: Microsoft.Extensions.Logging
  dependency-version: 10.0.11
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: microsoft-extensions
- dependency-name: Microsoft.Extensions.Logging
  dependency-version: 10.0.11
  dependency-type: direct:production
  update-type: version-update:semver-major
  dependency-group: microsoft-extensions
- dependency-name: Microsoft.Extensions.Logging.Abstractions
  dependency-version: 10.0.11
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: microsoft-extensions
- dependency-name: Microsoft.Extensions.Logging.Console
  dependency-version: 10.0.11
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: microsoft-extensions
...

Signed-off-by: dependabot[bot] <support@github.com>
…e/microsoft-extensions-9b6f1c2dce

Bump Microsoft.Extensions.DependencyInjection and 6 others
Bumps TUnit from 1.64.6 to 1.65.68

---
updated-dependencies:
- dependency-name: TUnit
  dependency-version: 1.65.68
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: testing
...

Signed-off-by: dependabot[bot] <support@github.com>
…cc221a

Bump the testing group with 1 update
Bumps [github/codeql-action/analyze](https://github.com/github/codeql-action) from 4.37.6 to 4.37.9.
- [Release notes](https://github.com/github/codeql-action/releases)
- [Changelog](https://github.com/github/codeql-action/blob/main/CHANGELOG.md)
- [Commits](github/codeql-action@5595cca...cdf488f)

---
updated-dependencies:
- dependency-name: github/codeql-action/analyze
  dependency-version: 4.37.9
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
…hub/codeql-action/analyze-4.37.9

chore(deps): bump github/codeql-action/analyze from 4.37.6 to 4.37.9
Bumps [github/codeql-action/init](https://github.com/github/codeql-action) from 4.37.6 to 4.37.9.
- [Release notes](https://github.com/github/codeql-action/releases)
- [Changelog](https://github.com/github/codeql-action/blob/main/CHANGELOG.md)
- [Commits](github/codeql-action@5595cca...cdf488f)

---
updated-dependencies:
- dependency-name: github/codeql-action/init
  dependency-version: 4.37.9
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
…hub/codeql-action/init-4.37.9

chore(deps): bump github/codeql-action/init from 4.37.6 to 4.37.9
…febc3

Bump Microsoft.CodeAnalysis.CSharp from 5.6.0 to 5.9.0
Bumps Microsoft.CodeAnalysis.Analyzers from 5.6.0 to 5.9.0
Bumps Microsoft.CodeAnalysis.CSharp from 5.0.0 to 5.9.0

---
updated-dependencies:
- dependency-name: Microsoft.CodeAnalysis.Analyzers
  dependency-version: 5.9.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: roslyn
- dependency-name: Microsoft.CodeAnalysis.CSharp
  dependency-version: 5.9.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: roslyn
...

Signed-off-by: dependabot[bot] <support@github.com>
Bumps TUnit from 1.65.68 to 1.66.16

---
updated-dependencies:
- dependency-name: TUnit
  dependency-version: 1.66.16
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: testing
...

Signed-off-by: dependabot[bot] <support@github.com>
Introduce independent local lifecycle, readiness, and cluster state domains for single- and multi-cluster clients. Start hosted clients without blocking on remote availability, supervise initial connectivity recovery, preserve legacy explicit connection semantics, keep runtime Add/Replace candidates in the new child lifecycle, and prevent compatibility connection failures from tearing down an already-running coordinator.

Fixes #644
…adiness

Decouple client lifecycle from remote readiness
Replace public RunAsync with explicit StartAsync, WaitForShutdownAsync, and StopAsync ownership. Move accept/runtime supervision into SharpLinkServer, keep per-connection cleanup failures local including heartbeat-timeout cleanup, simplify Generic Host lifetime bridging, migrate repository callers, and document terminal failure semantics.

Fixes #646
…cycle"

This reverts commit 8183ac2, restoring the first-parent tree at 9ba50b9.
…cycle-readiness"

This reverts commit 9ba50b9, restoring the pre-accident main tree at 21ed74f.
…26-09-10

Revert accidental main merges from 2026-09-10
…e3670

Bump the roslyn group with 2 updates
…165df4

Bump the testing group with 1 update
@SunSi12138 SunSi12138 changed the title perf(client): remove per-request emission task overhead perf(runtime): reduce timed RPC emission overhead and restore batching Sep 12, 2026
@SunSi12138
SunSi12138 marked this pull request as ready for review September 12, 2026 23:12
@SunSi12138
SunSi12138 merged commit 4bd5686 into dev Sep 12, 2026
33 checks passed
@SunSi12138
SunSi12138 deleted the fix/release-unary-emission-overhead branch September 12, 2026 23:20
SunSi12138 added a commit that referenced this pull request Sep 13, 2026
Merge the reviewed 2.0.0 performance corrections from dev into main.

The release branch tree is identical to the verified dev commit bae9e50; this merge adds main history only, with no source changes beyond the two reviewed performance corrections (#677, #678).
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