Repository navigation
remove two rest api calls to improve rate limit - #2936
Conversation
| } | ||
| } | ||
| } | ||
| } |
There was a problem hiding this comment.
the info that those rest API calls were getting are now retrieved in this graphql call.
ea5755c to
28d6224
Compare
Dry-run check results |
28d6224 to
9584944
Compare
| // 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. |
There was a problem hiding this comment.
this comment is now in the graphql call. Line 432
987dc3f to
cfe973b
Compare
cfe973b to
58a7cbc
Compare
|
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 deployrust-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: Each deploy now uses 606 REST calls instead of ~1,282 (−676, −53%). GraphQL usage is unchanged. Deploys (
|
| 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
- Before: one deploy used ~26% of the hourly REST budget, so a 4th deploy in the same hour would have run out (4 × 1,282 = 5,128 > 5,000). This nearly happened on Nov 10: Track the expect-test crate #2925, Track the deprecated net2 crate #2917 and Track the obsolete cargo-fix crate #2935 merged between 10:01 and 10:46 UTC and left only 1,152 calls.
- After: one deploy uses ~12% of the budget, so about 8 deploys fit in one hour.
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.
- #2936 dry-run: 474 REST / 89 GraphQL
- Dry-run of another PR on
main: 988 REST / 89 GraphQL
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.
|
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 😈 |
AI disclosure
I used Opus 5.5 to generate this change. I reviewed its output and changed it where necessary.