Skip to content

multi: store timeout epoch as whole seconds - #22806

Closed
cmeister2 wants to merge 2 commits into
masterfrom
cm2/multi-timeout-base-seconds
Closed

cmeister2 wants to merge 2 commits into
masterfrom
cm2/multi-timeout-base-seconds

Conversation

@cmeister2

@cmeister2 cmeister2 commented Sep 2, 2026 •

Copy link
Copy Markdown
Contributor

The timeout splay tree stores its keys as offsets from a fixed epoch. Dropping the epoch's microseconds shifts every offset by the same constant, which cancels when calculating timeout deltas.

Writing the reconstructed whole-second epoch as base', the remaining timeout is unchanged:

(deadline - base') - (now - base')
  = deadline - now
  = (deadline - base) - (now - base)

Every deadline offset is also shifted by the same constant, so their ordering is preserved.

Store only the epoch's seconds and reconstruct a zero-microsecond curltime for offset calculations. This reduces Curl_timeouts and Curl_multi by eight bytes on 64-bit builds without changing timeout ordering or durations.

The timeout splay tree stores its keys as offsets from a fixed epoch.
Dropping the epoch's microseconds shifts every offset by the same
constant, which cancels when calculating timeout deltas.

Store only the epoch's seconds and reconstruct a zero-microsecond
curltime for offset calculations. This reduces Curl_timeouts and
Curl_multi by eight bytes on 64-bit builds without changing timeout
ordering or durations.

Closes #22806
@cmeister2
cmeister2 force-pushed the cm2/multi-timeout-base-seconds branch from 258de9c to 34a4713 Compare September 2, 2026 16:51
@cmeister2
cmeister2 requested a balanced review from Copilot September 2, 2026 16:53

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.

🟡 Changes recommended

The whole-second conversion needs focused regression coverage using a nonzero-microsecond epoch.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

Stores timeout epochs at whole-second precision to reduce Curl_multi memory usage without changing timeout ordering or durations.

Changes:

  • Replaces the full curltime epoch with time_t.
  • Reconstructs a zero-microsecond epoch for offset calculations.
File summaries
File Description
lib/splay.h Shrinks the timeout epoch field.
lib/splay.c Stores seconds and reconstructs the epoch.
Review details
  • Files reviewed: 2/2 changed files
  • Comments generated: 1
  • Review effort level: Balanced

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

Comment thread lib/splay.c
Verify that a base with nonzero microseconds shifts deadline and current
time offsets equally and preserves the calculated timeout.
@github-actions github-actions Bot added the tests label Sep 2, 2026
@bagder bagder closed this in 2f89769 Sep 3, 2026
@bagder
bagder deleted the cm2/multi-timeout-base-seconds branch September 3, 2026 09:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Development

Successfully merging this pull request may close these issues.

3 participants