Skip to content

perf(streaming): unify http curlm request engine - #238

Merged
MisterVVP merged 1 commit into
dev-optimize-streaming-response-latenciesfrom
dev-unify-http-curlm-request-engine
Sep 3, 2026
Merged

MisterVVP merged 1 commit into
dev-optimize-streaming-response-latenciesfrom
dev-unify-http-curlm-request-engine

Conversation

@MisterVVP

@MisterVVP MisterVVP commented Sep 3, 2026 •

Copy link
Copy Markdown
Owner

Summary

Follow-up to #223.

This PR unifies the default libcurl unary and streaming HTTP request paths onto the same bounded process-wide CURLM reactor pool.

Previously, streaming requests used the shared CURLM reactors while unary requests used reusable easy handles with curl_easy_perform(). As a result, a common unary → stream sequence could cross two independent libcurl connection caches and lose an otherwise reusable HTTP connection.

The new implementation preserves the synchronous SendRequest() API while executing its network transfer through the same event-driven request engine used by streaming.

What changed

Unified CURLM request engine

Unary RequestSlots now retain a reactor assignment in addition to their reusable easy handle.

Client::SendRequest() configures the request as before, submits the easy handle to its assigned CURLM reactor, and synchronously waits for that transfer to complete.

No public HTTP or A2A client API changes are required.

Unary → streaming connection-cache affinity

Each client establishes a primary reactor affinity for its first unary and streaming handles.

This allows the common sequence:

unary request -> streaming request

to use the same CURLM connection cache and reuse an existing HTTP connection when the server and protocol allow it.

Additional concurrent unary and streaming handles continue to be distributed across the bounded reactor pool rather than concentrating all work on one reactor.

Bounded global resource usage

Both unary and streaming requests now use the existing process-wide pool of at most four CURLM reactors.

Reusable easy-handle slots retain their reactor assignments, preserving connection-cache locality while keeping reactor/thread growth bounded as more SDK clients are created.

Regression coverage

A dedicated loopback test performs a unary request followed by a streaming request through the same a2a::http::Client and verifies that both operations use a single accepted TCP connection.

Existing concurrent unary-request coverage continues to verify that moving unary requests onto CURLM does not serialize independent requests behind one shared easy handle.

Performance documentation has been updated to describe the unified request topology.

@MisterVVP
MisterVVP changed the base branch from main to dev-optimize-streaming-response-latencies September 3, 2026 14:10
@MisterVVP MisterVVP self-assigned this Sep 3, 2026
@MisterVVP MisterVVP added AI agent AI agent contribution performance Performance improvement related tasks based on benchmark results. Performance tests changes. labels Sep 3, 2026
@MisterVVP
MisterVVP merged commit d696509 into dev-optimize-streaming-response-latencies Sep 3, 2026
19 checks passed
@MisterVVP
MisterVVP deleted the dev-unify-http-curlm-request-engine branch September 3, 2026 19:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

AI agent AI agent contribution performance Performance improvement related tasks based on benchmark results. Performance tests changes.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant