Repository navigation
perf(http): reduce async completion and timer overhead - #335
Merged
Merged
Conversation
MisterVVP
marked this pull request as ready for review
November 15, 2026 16:34
This was referenced Nov 15, 2026
MisterVVP
added a commit
that referenced
this pull request
Nov 19, 2026
## Summary - Add callback-driven `SendMessage_CreateTask` alongside the synchronous API. Both require a task ID, and each async lane keeps one call in flight. - Start each client/server comparison on a fresh in-memory SUT. Warm each measured client with one task, wait for completion, and reuse its connection for measurement. - Add a fixed-count CI step to the existing performance artifact and label wire streams and subscriptions `observer` in JSON, CSV, and Markdown. ## Local task-creation results The hosted performance job passed the 24-wire-row check and uploaded the report. [CI performance artifact](https://github.com/MisterVVP/a2a-cpp/actions/runs/44519412513/artifacts/14529500461) The local Release run also produced **24 wire rows**, **2,000 measured requests per row**, and **zero errors**. All 12 fixed-client server comparisons were valid. Each cell lists ops/s · p50/p99 in ms from a single pass on a shared host while local analysis was running. | Transport | Concurrency | Sync client / sync server | Sync client / async server | Async client / sync server | Async client / async server | | --- | ---: | ---: | ---: | ---: | ---: | | grpc | 1 | 4,614 · 0.214/0.316 | 3,856 · 0.242/0.669 | 3,978 · 0.227/1.004 | 3,632 · 0.263/0.565 | | grpc | 64 | 13,367 · 4.129/9.097 | 11,960 · 4.775/12.000 | 11,568 · 4.893/11.364 | 14,074 · 4.403/7.754 | | jsonrpc | 1 | 2,026 · 0.470/1.034 | 1,598 · 0.545/2.924 | 2,188 · 0.457/0.545 | 1,542 · 0.543/2.765 | | jsonrpc | 64 | 15,751 · 2.737/26.392 | 9,514 · 5.509/26.867 | 18,420 · 3.093/9.034 | 10,583 · 5.623/12.290 | | http_json | 1 | 2,817 · 0.349/0.657 | 2,335 · 0.410/0.906 | 2,579 · 0.349/1.425 | 1,997 · 0.423/2.617 | | http_json | 64 | 20,397 · 2.142/19.636 | 13,050 · 3.628/33.597 | 17,848 · 2.683/10.170 | 14,231 · 3.826/13.989 | ## HTTP/JSON server follow-up In the earlier concurrency-one HTTP/JSON `GetTask` run, holding the async client fixed, p50 rose from **179 µs** on the sync server to **231 µs** on the async server, a gap of **52 µs (29%)**. [Earlier GetTask comparison](#335) Start the server investigation with the network-to-application, application-to-dispatcher, and response-to-network handoffs in the HTTP unary path. ## Validation - `./scripts/verify_changes.sh` and `./scripts/run_clang_tidy.sh build` both exited successfully. The clean Asio Debug build and CTest completed with zero failures across 1,135 registered tests. Three tests were skipped by CTest. - CI-equivalent clang-format, changed-file Clang 19 analysis, actionlint, mdBook, and the 54-row performance smoke passed. - Ubuntu's installed-package security check found no pending security updates. OSV returned no matches for the Boost.Asio and simdjson releases used in final verification. Local TCK was skipped at the maintainer's request, and hosted TCK passed. Full local clang-tidy finished after the authorized push. ## AI authorship An AI agent generated the submitted code, tests, workflow, and documentation from the maintainer-approved plan.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Stacked on #334 (
perf/grpc-client-streaming,df97c3c). Keep this draft until CI's sync/async measurements have been reviewed.HTTP unary responses currently queue an SDK completion after decoding on an SDK completion worker. Allow those internal HTTP JSON/JSON-RPC adapters to finish on the current completion worker, removing that second queue hop. Public initiation still defers callbacks, including nested calls started from callbacks; reactor threads never run application completions.
Shared-executor experiment
Also tested sharing the HTTP application and native dispatcher executor and resuming pending mailbox continuations without an extra post. A two-worker shared pool reduced the existing four-worker application budget and hurt concurrent unary throughput. Matching the four-worker budget restored throughput to roughly baseline, without a consistent benefit. Leave that executor API, ownership/drain plumbing and SUT wiring out of this patch.
No PostgreSQL, dependency, benchmark-runner or CI workflow changes. No benchmark artifacts are committed.
Local measurements
Exact parent binaries versus this branch, Release/in-memory, 250 ms warmup and three seconds per case, concurrency 1 and 64, one pass per distinct configuration. The local host has a two-CPU quota, with one CPU assigned to each process; CI has two CPUs per process. These are local experiment results, not new CI results or statistical proof. Controls also fluctuate.
All throughput columns below are at c64. Unary async columns use both async client and server; streams use the same observer client and compare server modes. The sync column uses this branch's synchronous mode.
C1 full-async GetTask p50: HTTP JSON 230 → 231 µs, JSON-RPC 331 → 328 µs. ListTasks: 305 → 295 µs and 352 → 428 µs. Finite streams: 279 → 276 µs and 283 → 290 µs. Subscription and idle-cancellation cases are included in the 56-row comparison, with zero errors in both revisions.
Holding the synchronous server constant isolates the client comparison: c1 async-client GetTask p50 is 192 → 179 µs for HTTP JSON and 274 → 268 µs for JSON-RPC. Its measured gap relative to the synchronous client narrows 14 → 7 µs and 10 → 4 µs, respectively. Async-client ListTasks p50 is 253 → 246 µs and 296 → 283 µs. This is consistent with lower client overhead; the larger remaining c1 penalty appears when switching the server to async.
The additional eight-row gRPC GetTask check also has zero errors: c64 full-async throughput 32,944 → 33,341 ops/s (1.01×) and p99 4.066 → 4.705 ms.
A separate syscall trace isolates the reduced machinery: for 500 successful async HTTP JSON GetTask calls per driver, using the same new server, the client's deadline thread made 507 → 1 timed futex-wait calls. Completion-worker condition-variable futex-wait calls fell 1,004 → 504, consistent with removing the extra delivery hop. Traced timings are excluded from the throughput table.
This does not resolve the c1 or HTTP streaming performance gap. The trace confirms less scheduling work, but there is no broad measured throughput win: HTTP concurrent unary improves slightly, JSON-RPC concurrent unary declines in this pass, and streams remain near baseline. Unmodified fully synchronous c64 controls also range from 0.87–1.01× their earlier results, so these single-pass differences cannot establish causation. CI results should determine whether each fast path is worth retaining. Further work needs profiling of the HTTP application/dispatcher and stream handoffs; both synchronous and asynchronous HTTP clients already share the libcurl-multi reactor.
Validation
./scripts/verify_changes.sh: passed (exit 0); full build, 1,199 CTest cases with zero failures and three expected skips, and all 190 source/test/example lint checks passed.pytest -m must, all three transports, upstream checkout unchanged): 215 passed, 14 skipped, 34 deselected, zero failed MUST checks. The upstream catalogue still lists unimplemented/manual checks; this is not a claim of 100% catalogue coverage. The separate existing MUST/SHOULD Content-Type contradiction in [Feature]: [Release v0.6.0] Finalize SDK packaging, versions, and documentation #328 is unchanged.mdbook build bookpass.Authorship and AI usage
Checklist
./scripts/verify_changes.shpassed locally