Multi-poll backend optimization: configure CURLMOPT_MAXCONNECTS to avoid unnecessary TCP/TLS handshakes - #1034
Open
kingcrimsontianyu wants to merge 3 commits into
Open
Conversation
|
Auto-sync is disabled for draft pull requests in this repository. Workflows must be run manually. Contributors can view more details about this message here. |
kingcrimsontianyu
marked this pull request as ready for review
August 14, 2026 20:49
madsbk
approved these changes
Aug 17, 2026
| { | ||
| if (!max_concurrent_requests.has_value()) { return std::nullopt; } | ||
|
|
||
| // libcurl documents this option as taking a `long`, and the value is internally store as an |
Member
There was a problem hiding this comment.
Suggested change
| // libcurl documents this option as taking a `long`, and the value is internally store as an | |
| // libcurl documents this option as taking a `long`, and the value is internally stored as an |
| std::numeric_limits<std::size_t>::max() / 2, | ||
| static_cast<std::size_t>(limit), | ||
| static_cast<std::size_t>(limit) / 2 + 1}; | ||
| for (const auto ceiling : ceilings) { |
Member
There was a problem hiding this comment.
Suggested change
| for (const auto ceiling : ceilings) { | |
| for (auto const ceiling : ceilings) { |
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.
By default libcurl sets
CURLMOPT_MAXCONNECTSto 4 x the number of easy handles attached to a multi handle. This is recomputed on every transition, and a transient dip in concurrency will cause libcurl to evict warm, reusable connections, and cause unnecessary TCP/TLS handshake. In this PR we pinCURLMOPT_MAXCONNECTSto a fixed size to avoid this problem.Benchmark on cudf-polars TPC-H SF-1K query 5 shows that, on
mainthe TCP connection opened is 618, whereas with this PR, the connection number drops to 496, which is a ~20% saving.