Skip to content

transfer: DID handling - #22763

Closed
icing wants to merge 3 commits into
curl:masterfrom
icing:transfer-did-fairness
Closed

icing wants to merge 3 commits into
curl:masterfrom
icing:transfer-did-fairness

Conversation

@icing

@icing icing commented Aug 31, 2026

Copy link
Copy Markdown
Contributor

When a transfer leaves its DID state and goes to PERFORM, it should not hog the multi processing when there are other transfers alive. Make multistate_did() return CURLM_OK then which triggers the processing of the next easy handle.

This gives more fairness among easy handles:

  • on a fast server, responses may arrive very quickly and processing a response is costly. All this time is then lost to other transfers that have not even sent their request
  • on a slow server, directly trying to receive the response will not work and is an unnecessary network call.

Local scorecard tests with h1 requests showed that the former handling was only using 10 connections for 40 parallel requests after an initial peak of 40 connections. The change makes libcurl use all 40 connections continuously.

This also explains the h1-requests memory use development. When we closed connections more aggressively, the 40 initial connections shrank and released their memory. But the parallelism was not good.

icing added 2 commits August 31, 2026 13:46
When a transfer leaves its DID state and goes to PERFORM, it should
not hog the multi processing when there are other transfers alive.
Make multistate_did() return CURLM_OK then which triggers the
processing of the next easy handle.

This gives more fairness among easy handles:
- on a fast server, responses may arrive very quickly and processing
  a response is costly. All this time is then lost to other transfers
  that have not even sent their request
- on a slow server, directly trying to receive the response will not
  work and is an unnecessary network call.

Local scorecard tests with h1 requests showed that the former handling
was only using 10 connections for 40 parallel requests after an
initial peak of 40 connections. The change makes libcurl use all 40
connections continuously.

This also explains the h1-requests memory use development. When we
closed connections more aggressively, the 40 initial connections
shrank and released their memory. But the parallelism was not good.
@bagder
bagder requested a lite review from Copilot August 31, 2026 12:32
@icing
icing requested a review from bagder August 31, 2026 12:32

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

Pull request overview

Adjusts libcurl’s multi state machine so transfers transitioning from MSTATE_DID to MSTATE_PERFORMING don’t monopolize immediate re-processing when multiple transfers are active, improving fairness and sustained parallelism (notably for HTTP/1.x workloads).

Changes:

  • Update multistate_did() to sometimes return CURLM_OK (instead of CURLM_CALL_MULTI_PERFORM) after entering MSTATE_PERFORMING, allowing other easy handles to progress.
  • Restrict the fairness behavior to HTTP-family protocols and only when more than one transfer is alive.
File summaries
File Description
lib/multi.c Changes multistate_did() return behavior to improve scheduling fairness across concurrent transfers.
Review details
  • Files reviewed: 1/1 changed files
  • Comments generated: 1
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread lib/multi.c
@bagder bagder closed this in 9b2caf3 Aug 31, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants