Repository navigation
Stop refetching Go, RPM and PyPI metadata that can't change - #598
Merged
Merged
Conversation
A Go module's .mod and .info for a canonical version, and RPM repodata files named after their checksum, never change once published. They went through the metadata TTL, so each cost a revalidation every TTL with cache_metadata on and a full fetch on every request with it off. They are now kept in the metadata cache with or without cache_metadata and served whatever their age. A stored copy is checked against its digest and fetched again if it doesn't match. Go queries, @v/list, @latest and repomd.xml stay on the TTL.
Every PyPI download with cooldown on read the JSON API first, cached files included. Without cache_metadata that was a full /pypi/<name>/json per file. A download that looks up the JSON API now stores the release's newest upload time on its versions row. A cached file is then checked against the stored time without asking upstream. A file that isn't cached is still looked up, since files can be added to a release later, and the stored time is refreshed. A stored time inside the window withholds the release without a lookup.
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.
Some upstream requests the proxy makes are for data that never changes once published.
Go
.modand.info. For a canonical version they are fixed by the module proxy protocol and the checksum database, but they went throughmetadata_ttl.go mod downloadfor a mid-sized service asks for 200-400.modfiles (every module version in the graph, including pruned ones) plus their.info. Withcache_metadataoff that was 200-400 full GETs to proxy.golang.org on every build; with it on, the same number of conditional requests whenever a build ran more than 5 minutes after the last.They are now kept in the metadata cache with or without
cache_metadata, as.zipfiles are kept in the artifact cache, and served whatever their age. That covers releases, pre-releases, pseudo-versions and+incompatibleversions (module.CanonicalVersion(v) == v). Pseudo-versions are included: they name a commit by its hash, and the checksum database pins their content like any other version. A query (@v/main.info,@v/v1.2.info),@v/listand@lateststay on the TTL. The cooldown path reads.infothrough the same cache, so a version's time still comes from the versions row first and its.infosecond; nothing about which versions are withheld changes.RPM repodata. createrepo names
primary,filelists,other,comps,updateinfoand so on after their own checksum (repodata/<sha256>-primary.xml.zst), so a name always has the same content. A fresh CI container runningdnfagainst Fedora fetches 5-10 of these per repository, tens of MB, and each did so from upstream withcache_metadataoff. They now get the same treatment as Go's files.repomd.xmland repositories built with--simple-md-filenamesstay on the TTL. A file overmetadata_max_sizeis streamed from upstream uncached instead of failing with 502.A stored immutable document is never revalidated, so it is checked against the digest recorded for it, as streamed cache hits already are, and fetched again if it doesn't match.
PyPI download cooldown. Every download with cooldown on read the JSON API before looking at the cache, cached files included. Installing 150 cached wheels with
cache_metadataoff made 150 requests for/pypi/<name>/json, which is several MB for packages like boto3. The download path now stores the release's upload time on its versions row, as npm, Go, Maven and Composer do, and checks a cached file against it without asking upstream. The same 150 cached wheels now cost no upstream request.A PyPI release's time is its newest file's upload time, and a file can be added to an old release later. So the stored time only answers for files that are already cached. A file that isn't cached is still looked up, which stores the newer time; from then on the whole release is withheld until it leaves cooldown, as before. A stored time inside the window withholds the release without a lookup. The one difference from before: a file cached before a new file was added to its release keeps being served, since it is the same bytes that already passed. The simple-page filtering is unchanged.
Tested with counting httptest upstreams, each test failing without the change:
TestGoVersionFilesAreNotRevalidated:.mod/.infofor a release and a pseudo-version fetched once over three rounds, with and withoutcache_metadataand cooldown and with an expired TTL;@v/main.info,@v/listand@latestfetched each time.TestRPMContentAddressedRepodataIsNotRevalidated: a checksum-named file fetched once,repomd.xmlandprimary.xml.gzeach time.TestPyPICachedDownloadUsesStoredUploadTime: three downloads of a cached file, one JSON API request.TestPyPIFileAddedToReleaseIsChecked: a wheel added to an old release is looked up and withheld, and the cached sdist of that release is withheld after it without another lookup.Also
TestImmutableMetadataRefetchedWhenCorrupt,TestImmutableMetadataOverSizeLimitIsStreamed, and table tests for which Go versions and repodata names count as immutable.docs/configuration.mddescribes both changes.