Skip to content

remove two rest api calls to improve rate limit - #2936

Merged
marcoieni merged 1 commit into
mainfrom
remove-two-rest-api-calls-to-improve-rate-limit
Nov 11, 2026
Merged

marcoieni merged 1 commit into
mainfrom
remove-two-rest-api-calls-to-improve-rate-limit

Conversation

@marcoieni

@marcoieni marcoieni commented Nov 10, 2026 •

Copy link
Copy Markdown
Member

AI disclosure

I used Opus 5.5 to generate this change. I reviewed its output and changed it where necessary.

}
}
}
}

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

the info that those rest API calls were getting are now retrieved in this graphql call.

@marcoieni
marcoieni force-pushed the remove-two-rest-api-calls-to-improve-rate-limit branch 3 times, most recently from ea5755c to 28d6224 Compare November 10, 2026 11:23
@github-actions

github-actions Bot commented Nov 10, 2026 •

Copy link
Copy Markdown
Dry-run check results

[WARN  rust_team::sync] sync-team is running in dry mode, no changes will be applied.
[INFO  rust_team::sync] synchronizing crates-io
[INFO  rust_team::sync] synchronizing github
[INFO  rust_team::sync] Rate limits before: REST 15000/15000 remaining, resets at 2026-11-10 16:40:34 UTC, GraphQL 12500/12500 remaining, resets at 2026-11-10 16:40:34 UTC
[INFO  rust_team::sync] Rate limits after: REST 14526/15000 remaining, resets at 2026-11-10 16:40:44 UTC, GraphQL 12411/12500 remaining, resets at 2026-11-10 16:40:39 UTC
[INFO  rust_team::sync] Consumed 474 REST calls and 89 GraphQL calls

@marcoieni
marcoieni force-pushed the remove-two-rest-api-calls-to-improve-rate-limit branch from 28d6224 to 9584944 Compare November 10, 2026 11:30
Comment on lines -736 to -740
// Exclude inherited organization/enterprise rulesets, as we only manage
// repository rulesets.
// Note that parent rulesets can contain parent-only rule types, such as `workflows`,
// so if you enable this, make sure the deserialization of the ruleset can handle all
// organization/enterprise rule types, too.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

this comment is now in the graphql call. Line 432

@marcoieni
marcoieni force-pushed the remove-two-rest-api-calls-to-improve-rate-limit branch 4 times, most recently from 987dc3f to cfe973b Compare November 10, 2026 12:55
@marcoieni
marcoieni force-pushed the remove-two-rest-api-calls-to-improve-rate-limit branch from cfe973b to 58a7cbc Compare November 10, 2026 15:34
@marcoieni
marcoieni marked this pull request as ready for review November 11, 2026 13:36
@marcoieni
marcoieni added this pull request to the merge queue Nov 11, 2026
Merged via the queue into main with commit 2e36338 Nov 11, 2026
5 checks passed
@marcoieni
marcoieni deleted the remove-two-rest-api-calls-to-improve-rate-limit branch November 11, 2026 14:41
@marcoieni

Copy link
Copy Markdown
Member Author

This PR cuts the REST API usage by half. This means we can do 8 deploys per hour instead of 4. Here is AI investigation if you want proof:


sync-team: #2936 halves the REST API calls of each deploy

rust-lang/team#2936 reads each repo's ruleset IDs and environments from the GraphQL query we already run for every repo. Before, we made two extra REST calls per repo for this data: GET /repos/{org}/{repo}/rulesets and GET /repos/{org}/{repo}/environments.

Each deploy now uses 606 REST calls instead of ~1,282 (−676, −53%). GraphQL usage is unchanged.

Deploys (sync apply, which uses a PAT limited to 5,000 REST calls/hour)

Deploy Code REST calls GraphQL points
cron, Nov 10 04:07 UTC before 1,282 112
#2925 before 1,283 128
#2917 before 1,282 130
#2935 before 1,282 128
#2916 before 1,282 137
#2940 before 1,282 129
#2936 after 606 128

(Numbers come from the Consumed N REST calls and M GraphQL calls line of the "Sync changes" step.)

The saving is exactly 2 calls × 338 repos, which is the number of repos/**/*.toml files, archived repos included. Every new repo now costs 2 fewer calls per deploy.

The deploy just before (#2945) and the #2936 deploy ran in the same rate-limit hour, so they can be compared directly. REST remaining went 5,000 → 3,715 after #2945 (old code, 1,285 calls) → 3,109 after #2936 (new code, 606 calls).

Impact on the rate limit

Dry-runs on PRs (rust-lang org app token only)

The dry-runs of #2936 ran the PR's own code. Each used 474 REST calls, compared with 988 for dry-runs of other PRs that ran main on the same day (−514, −52%). GraphQL stayed at 89 points in both cases.

Note: some older deploy logs show impossible values, such as "Consumed 0 REST calls" or "Consumed 98 REST calls" (#2945 is one of them). In those runs the "after" rate-limit reading doesn't match the "before" reading of the next deploy in the same hour; in some cases the remaining count even goes up. Where those runs could be checked against the next deploy's "before" value, they also used ~1,283 calls, so I left them out of the table.

@Kobzol

Kobzol commented Nov 11, 2026 •

Copy link
Copy Markdown
Member

Nice :) I looked at those two before, but it seemed like what we have is already good enough. But apparently if you start tracking too many crates at once, you can still trigger the limit 😆 Let's see if we can hit the ceiling with 8 PRs per hour too 😈

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants