Skip to content

ratelimit timestamps - #22292

Closed
icing wants to merge 4 commits into
curl:masterfrom
icing:ratelimit-timestamps
Closed

ratelimit timestamps#22292
icing wants to merge 4 commits into
curl:masterfrom
icing:ratelimit-timestamps

Conversation

@icing

@icing icing commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

Make timestamp passed for ratelimit checks optional arguments. Let the limit calculation obtain a timestamp when it needs it and none was passed. Most transfers run without active ratelimits and getting a fresh timestamp is unnecessary.

Remove the timestamp passed for ratelimit checks. Let the limit
calculation obtain a timestamp when it needs it. Most transfers
run without active ratelimits and getting a fresh timestamp is
unnecessary.
@github-actions github-actions Bot added the tests label Jul 10, 2026
@icing
icing requested a review from vszakats July 10, 2026 10:29

@vszakats vszakats left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Perhaps delete the #if 0 branch in Curl_pgrs_now(), or add a comment
why we want to keep it?

@icing

icing commented Jul 10, 2026

Copy link
Copy Markdown
Contributor Author

Perhaps delete the #if 0 branch in Curl_pgrs_now(), or add a comment why we want to keep it?

Flüchtigkeitsfehler...😌

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 makes timestamps optional for rate-limit (token bucket) checks/drains by letting the ratelimit code sample the current time internally when needed, reducing timestamp reads on transfers where rate limiting is inactive. It also updates various call sites accordingly and extends an HTTP test scorecard formatter to display GB/s.

Changes:

  • Allow Curl_rlimit_avail() / Curl_rlimit_drain() to accept a NULL timestamp and sample time internally only when rate limiting is active.
  • Update multiple protocol/transfer paths to pass NULL timestamps into ratelimit functions.
  • Adjust progress timestamp handling and add GB/s formatting support in tests/http/scorecard.py.

Reviewed changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
tests/http/scorecard.py Adds GB/s formatting to the scorecard throughput formatter.
lib/vquic/cf-ngtcp2.c Switches QUIC RX window updates to call ratelimit availability without a caller-supplied timestamp.
lib/vquic/cf-ngtcp2-proxy.c Same ratelimit timestamp change for the HTTP/3 proxy QUIC path.
lib/transfer.c Updates download path ratelimit availability check to omit timestamp.
lib/sendf.c Updates upload path ratelimit availability check to omit timestamp.
lib/ratelimit.h Minor signature formatting change for Curl_rlimit_drain() declaration.
lib/ratelimit.c Implements optional timestamp sampling in Curl_rlimit_avail() and Curl_rlimit_drain().
lib/progress.c Simplifies Curl_pgrs_now() storage and switches ratelimit drain calls to omit timestamp.
lib/multi.c Updates pollset adjustment logic to call ratelimit availability without an explicit timestamp.
lib/http2.c Updates HTTP/2 desired window computation to call ratelimit availability without an explicit timestamp.

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

Comment thread tests/http/scorecard.py Outdated
Comment thread lib/ratelimit.h
Comment thread lib/multi.c
@bagder bagder closed this in 34bc5b6 Jul 13, 2026
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.

4 participants