refactor registry-api, switch to using sparse index for fetching release data - #3489
Merged
Conversation
This comment has been minimized.
This comment has been minimized.
syphar
force-pushed
the
sparse-index-registry
branch
from
September 3, 2026 00:09
d6e01b3 to
c707589
Compare
syphar
marked this pull request as ready for review
September 3, 2026 00:10
Member
Author
Member
Author
GuillaumeGomez
approved these changes
Sep 3, 2026
Co-authored-by: Guillaume Gomez <contact@guillaume-gomez.fr>
7 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

We currently have three use-cases where the crates.io API is used:
1) and 2) run when we build the crate, 3) when the user requests it in the UI.
Since a couple of weeks ago, we're running into crates.io rate limits every couple of days, for a couple of yours each time. This leads to the release-data (yanked, release-time) being outdated or filled with dummy values, and owners not being up-to-date after the build.
Likely this is because we now run more builders (6), and the rate limiting for crates.io moved to the fastly NgWaf instead of the heroku servers.
Thing is: since we removed the
downloadsfield, which wasn't used any more, and the sparse & git index gotpubtimeas new field, we can replace one of the requests with a request to the sparse index. The sparse index is mostly cached (in the CDN & locally), and doesn't have a rate limit (apart from some DDOS protection).Generally I believe we probably will do more and more with the sparse index and start live-fetching stuff instead of syncing things.
So I invested some time into a bigger refactor of the
registry_apicrate.So:
SparseIndexsupport I added thecrates_indexcrate to our registry api.pubtimesupport tocrates-indexconfig.jsonfrom the index to figure out the API & download server, as cargo does too.get_release_data, we use the sparse index. So it's quite unlikely that we'll run into a rate limit on these while we're building.TestEnvironmentnow got a workingTestRegistrywith which other crates in the workspace can test interaction with the registry api & sparse index, without having to mock HTTP calls directly. We could even think about makingFakeReleasealso fill the sparse index at some point, or the new fake I'll build.TestEnvironment::builder.releases.release_timewhen we havepubtimein the indexWhat I didn't do yet is changing the dummy data thing, I only made it explicit. In the future I would like to only insert data we're getting from the index, and otherwise leave the fields empty, even in error cases. Or perhaps have additional fields with the original data, and then generated fields with fake or real data. But that I'll do in another PR. Another thought could be to even fail the build when the sparse index fails, our re-attempts will retry the build soon.
What is also not covered: we're still fetching owners via API, and also doing the search API calls. But IMO both are much less important than the yank-state or release-time.
What I'll also add in the future (depenending on the design discussions) is: