Skip to content

multi: add dirty bitset#17662

Closed
icing wants to merge 3 commits intocurl:masterfrom
icing:multi-dirty
Closed

multi: add dirty bitset#17662
icing wants to merge 3 commits intocurl:masterfrom
icing:multi-dirty

Conversation

@icing
Copy link
Copy Markdown
Contributor

@icing icing commented Jun 18, 2025

Add a bitset dirty to the multi handle. The presence of a transfer in the "dirty" set means: this transfer has something to do ASAP.

"dirty" is set by multiplexing protocols like HTTP/2 and 3 when encountering response data for another transfer than the current one. "dirty" is set by protocols that want to be called.

Implementation:

  • just an additional uint_bset in the multi handle
  • Curl_multi_mark_dirty() to add a transfer to the dirty set.
  • multi_runsingle() clears the dirty bit of the transfer at start. Without new dirty marks, this empties the set after all dirty transfers have been run.
  • multi_timeout() immediately gives the current time and timeout_ms == 0 when dirty transfers are present.
  • multi_event: marks all transfers tracked for a socket as dirty. Then marks all expired transfers as dirty. Then it runs
    all dirty transfers.

With this mechanism:

  • Most uses of EXPIRE_RUN_NOW are replaced by Curl_multi_mark_dirty()
  • Curl_multi_mark_dirty() is cheaper than querying if a transfer is already dirty or set for timeout. There is no need to check, just do it.
  • data->state.select_bits is eliminated. We need no longer to simulate a poll event to make a transfer run.

based on #17650

@icing icing marked this pull request as ready for review June 18, 2025 11:35
@icing icing requested a review from bagder June 18, 2025 11:35
Copy link
Copy Markdown
Member

@bagder bagder left a comment

Choose a reason for hiding this comment

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

Me like!

@bagder
Copy link
Copy Markdown
Member

bagder commented Jun 20, 2025

has conflicts that must be resolved

icing added 3 commits June 21, 2025 12:10
Add a bitset `dirty` to the multi handle. The presence of a transfer
int he "dirty" set means: this transfer has something to do ASAP.

"dirty" is set by multiplexing protocols like HTTP/2 and 3 when
encountering response data for another transfer than the current
one. "dirty" is set by protocols that want to be called.

Implementation:

* just an additional `uint_bset` in the multi handle
* `Curl_multi_mark_dirty()` to add a transfer to the dirty set.
* `multi_runsingle()` clears the dirty bit of the transfer at
   start. Without new dirty marks, this empties the set after
   al dirty transfers have been run.
* `multi_timeout()` immediately gives the current time and
   timeout_ms == 0 when dirty transfers are present.
* multi_event: marks all transfers tracked for a socket as dirty.
  Then marks all expired transfers as dirty. Then it runs
  all dirty transfers.

With this mechanism:

* Most uses of `EXPIRE_RUN_NOW` are replaced by `Curl_multi_mark_dirty()`
* `Curl_multi_mark_dirty()` is cheaper than querying if a transfer is
  already dirty or set for timeout. There is no need to check, just do it.
* `data->state.select_bits` is eliminated. We need no longer to
  simulate a poll event to make a transfer run.
@icing
Copy link
Copy Markdown
Contributor Author

icing commented Jun 21, 2025

has conflicts that must be resolved

Done.

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