Repository navigation
Optimize REST query parsing and reorganize transport implementations - #202
Merged
MisterVVP merged 5 commits intoAug 10, 2026
Merged
Conversation
Closed
14 tasks
MisterVVP
marked this pull request as draft
August 10, 2026 11:26
MisterVVP
commented
Aug 10, 2026
MisterVVP
marked this pull request as ready for review
August 10, 2026 19:39
Owner
Author
|
@codex review this PR |
15 tasks
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 635ec5837b
ℹ️ 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".
MisterVVP
deleted the
dev-optimize-rest-and-json-rpc-transport-performance
branch
August 10, 2026 20:40
MisterVVP
added a commit
that referenced
this pull request
Aug 11, 2026
…and diagnostics (#204) Closes #203 ## Summary This PR removes the per-request HTTP connection churn that was limiting HTTP+JSON and JSON-RPC wire scalability. It keeps the existing HTTP/1.1 transport model, but adds persistent connection support so ordinary unary requests can reuse the same TCP connection instead of paying a new accept/close cycle for every operation. The implementation also adds connection-scoped buffering, deterministic persistence coverage, connection-reuse diagnostics, Windows-safe shutdown behavior, and request-framing hardening discovered during review. ## Why HTTP/1.1 keep-alive Issue #203 allowed HTTP/1.1 persistence, HTTP/2, or another reusable transport strategy. HTTP/1.1 keep-alive was selected because it directly addresses the measured structural bottleneck without: - adding a large new HTTP/2 dependency; - changing public client/server APIs; - changing A2A transport semantics; - implementing HTTP/2 framing in-house; - expanding the scope beyond the connection-lifecycle bottleneck. The server can now serve multiple sequential unary requests on one connection while preserving existing SSE/streaming behavior. ## What changed ### Persistent HTTP connections - Stop unconditionally forcing `Connection: close` for reusable unary responses. - Honor explicit `Connection: close`. - Keep streaming responses connection-closing under the current HTTP/1.1 model. - Allow multiple requests to be processed sequentially on one accepted socket. - Preserve the existing two-argument `HttpAdapter::WriteResponse(...)` API while adding explicit connection-close control. ### Connection-scoped request buffering `HttpConnectionState` now retains bytes that were read beyond the current request boundary. This allows the adapter to correctly handle: - multiple requests arriving in one read; - back-to-back body-bearing requests; - fragmented requests spanning multiple reads; - pipelined buffered carry-over; - explicit connection closure; - malformed request termination. ### Request-framing hardening The adapter explicitly rejects `Transfer-Encoding`. The current raw HTTP adapter frames request bodies using `Content-Length`; accepting transfer-encoded requests could otherwise leave encoded bytes in the connection buffer and desynchronize subsequent request parsing. Rejecting unsupported transfer encoding preserves deterministic framing and prevents ambiguous request-stream interpretation. ### Server lifecycle and portability - Reuse one worker for multiple requests on an active connection instead of effectively creating a new socket/thread lifecycle for every unary operation. - Keep the signal-owned shutdown flag out of persistent worker-thread control flow. - Shut active sockets down during SUT termination so blocked workers exit cleanly. - Make Windows listener sockets genuinely nonblocking using Winsock `FIONBIO`. - Handle `WSAEWOULDBLOCK` / `WSAEINTR` in the Windows accept loop. - Use a Windows process group plus `CTRL_BREAK_EVENT` for graceful performance-SUT shutdown so shutdown-time diagnostics are emitted consistently. ### Performance diagnostics The performance runner now records: - `http_coordinate_accepted_connections`; - `http_coordinate_completed_unary_operations`; - `http_coordinate_operations_per_connection`. The denominator counts only connections that actually carried unary work, so readiness probes and streaming-only sockets do not distort unary connection-reuse measurements. Diagnostics are available in both JSON and CSV reports. The parser also accepts scientific-notation values emitted by C++ stream formatting. ### Focused performance execution The performance runner supports focused scenario selection, including the case where the selected scenarios contain no wire-capable workload. This makes targeted transport validation easier without requiring the entire performance matrix. ## Connection reuse evidence Latest in-memory HTTP wire diagnostics: | Concurrency | Unary operations | Unary-carrying connections | Operations / connection | | ---: | ---: | ---: | ---: | | 1 | 27,048 | 1,015 | 26.65 | | 4 | 27,048 | 1,054 | 25.66 | | 16 | 27,048 | 1,210 | 22.35 | | 64 | 27,048 | 1,834 | 14.75 | The important result is structural: ordinary unary operations no longer require one accepted TCP connection per operation. At c64, 27,048 unary operations were completed using 1,834 unary-carrying connections. ## Performance comparison Representative in-memory wire throughput at c64 compared with the final PR #202 CI artifact: | Scenario | HTTP+JSON #202 | HTTP+JSON this PR | Δ | JSON-RPC #202 | JSON-RPC this PR | Δ | | --- | ---: | ---: | ---: | ---: | ---: | ---: | | `GetTask_ExistingTask` | 5,135 ops/s | 7,515 ops/s | **+46.3%** | 2,682 ops/s | 3,314 ops/s | **+23.6%** | | `ListTasks_WithPagination` | 1,107 ops/s | 1,188 ops/s | **+7.3%** | 977 ops/s | 1,032 ops/s | **+5.7%** | | `ListTasks_NoPagination` | 596 ops/s | 626 ops/s | **+5.0%** | 529 ops/s | 546 ops/s | **+3.2%** | | `SendMessage_CreateTask` | 4,383 ops/s | 5,860 ops/s | **+33.7%** | 2,386 ops/s | 2,785 ops/s | **+16.7%** | These values come from separate GitHub-hosted CI executions, so the exact percentages should be treated as directional rather than precise same-machine benchmark deltas. As an additional control, normalizing HTTP throughput against gRPC within each corresponding run still improves the relative c64 throughput for all four representative scenarios, supporting that the improvement is transport-specific rather than simply a faster runner. Tail latency is noisier across unrelated hosted-runner executions, so this PR does not claim precise p95/p99 improvements from those cross-run values. The latest performance matrix completed **512 result rows with zero operation errors**. --------- Co-authored-by: Vladimir Pavlov <[email protected]>
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.
Motivation
client/transportandserver/transportdirectories to clarify boundaries and make future transport-focused optimizations easier.Description
src/client/transportandsrc/server/transportand updatesrc/CMakeLists.txt, test CMake targets, and internal#includereferences to useserver/transport/*where applicable.DecodeUrlComponent(skip per-char decoding when input contains no+or%) and reservingunordered_mapcapacity inParseQueryStringImplbefore insertions to reduce allocations and rehashing.RestQueryParserTest) intests/unit/rest_server_transport_test.cpp.docs/transport-performance.mdwith guidance and observed parser improvement numbers from the local microbenchmark runs.