Skip to content

expire timeouts: use index list - #22473

Closed
icing wants to merge 13 commits into
curl:masterfrom
icing:expire_timeouts
Closed

icing wants to merge 13 commits into
curl:masterfrom
icing:expire_timeouts

Conversation

@icing

@icing icing commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

Replace the timeoutlist and time nodes for expire timers with struct expire_timers that keeps a time and next array.

There is only ever one timeout per timer id and a fully dynamic list is not needed. Do the sorting by keeping an array of 'next' indiced and a 'first' starting point.

Added tracking of splay tree status.

Fixed missing splay removal when last timeout was removed via Curl_expire_done().

Some more bytes saved for the DRAM crisis.

Comment thread lib/multi.c Fixed
@icing
icing requested a review from bagder August 3, 2026 15:06
Comment thread lib/multi.c

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.

Pull request overview

This PR refactors easy-handle expire timer management by replacing the per-handle linked-list of timeout nodes with a fixed-size struct expire_timers (indexed by expire_id) plus a sorted “next index” chain, while also tracking whether the handle’s timer node is currently registered in the multi’s splay tree.

Changes:

  • Replaces timeoutlist/time_node state with struct expire_timers (time array + next array + first index + registered flag).
  • Updates multi timer scheduling to reinsert handles into the splay tree using the new indexed structure.
  • Updates verbose tracing/logging to iterate timers via the new expire_timers chain.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

File Description
lib/urldata.h Introduces struct expire_timers and replaces old per-handle timeout list state.
lib/multiif.h Renames the Curl_expire_ex parameter to match the new naming (eid).
lib/multi.c Implements the new timer list mechanics and integrates them with the multi splay-tree scheduling.
lib/curl_trc.c Updates timer tracing to iterate via expire_timers instead of a linked list.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread lib/multi.c Outdated
Comment thread lib/multi.c
vszakats pushed a commit to vszakats/curl that referenced this pull request Aug 4, 2026
Replace the `timeoutlist` and time nodes for expire timers with `struct expire_timers` that keeps a time and next array.

There is only ever one timeout per timer id and a fully dynamic list is not needed. Do the sorting by keeping an array of 'next' indiced and a 'first' starting point.

Added tracking of splay tree status.

Fixed missing splay removal when last timeout was removed via Curl_expire_done().

Some more bytes saved for the DRAM crisis.

Closes curl#22473
@icing
icing requested a review from bagder August 4, 2026 16:17
@bagder

bagder commented Aug 9, 2026

Copy link
Copy Markdown
Member

Just waiting for #22513 to merge first!

icing added 12 commits August 10, 2026 18:27
Replace the `timeoutlist` and time nodes for expire timers with
`struct expire_timers` that keeps a time and next array.

There is only ever one timeout per timer id and a fully dynamic
list is not needed. Do the sorting by keeping an array of 'next'
indiced and a 'first' starting point.

Added tracking of splay tree status.

Fixed missing splay removal when last timeout was removed
via Curl_expire_done().
@bagder bagder closed this in 874a54d Aug 10, 2026
@bagder

bagder commented Aug 10, 2026

Copy link
Copy Markdown
Member

This PR trimmed off 1728 bytes from the "maximum allocated" in the "download 512K HTTP" test.

  • Before: 132622 bytes
  • Now: 130894 bytes

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.

4 participants