Cache positive OSV hits#19038
Merged
Merged
Conversation
Signed-off-by: William Woodruff <william@astral.sh>
Signed-off-by: William Woodruff <william@astral.sh>
Signed-off-by: William Woodruff <william@astral.sh>
Signed-off-by: William Woodruff <william@astral.sh>
Signed-off-by: William Woodruff <william@astral.sh>
woodruffw
commented
Apr 17, 2026
Signed-off-by: William Woodruff <william@astral.sh>
konstin
reviewed
Apr 20, 2026
Signed-off-by: William Woodruff <william@astral.sh>
Signed-off-by: William Woodruff <william@astral.sh>
Signed-off-by: William Woodruff <william@astral.sh>
konstin
approved these changes
Apr 20, 2026
| .map_err(|e| Error::Url(self.base_url.clone(), e))?; | ||
| let batch_response: QueryBatchResponse = self | ||
| .client | ||
| .uncached() |
Member
There was a problem hiding this comment.
Can you add a comment on the uncached here?
| /// Fetch a full vulnerability record by ID from OSV. | ||
| /// | ||
| /// Caching is handled transparently by the [`CachedClient`] middleware using | ||
| /// a synthetic `Cache-Control: max-age=3600` header, since OSV itself does |
Signed-off-by: William Woodruff <william@astral.sh>
woodruffw
added a commit
that referenced
this pull request
Apr 20, 2026
## Summary ~~WIP.~~ Atop #18936. See also #18781 and #18506. The basic idea here is to add a layer of ~~(manual)~~ caching to our OSV interactions, but only for "positive" hits -- it's OK for us to cache actual successful lookups of `(name, version)` pairs to identifiers, but failed lookups should never be cached to prevent us from presenting false negatives to users. ## Test Plan The functionality itself here is referentially transparent, so the existing tests confirm that it works. Separately, in terms of benchmarking, I did a profiling build and ran with: ```bash hyperfine -i --warmup 3 './target/profiling/uv audit --project /path/to/project' './target/profiling/uv audit --no-cache --project /path/to/project' ``` ...on a project with 198 dependencies and 4 found vulnerabilities. On a local machine I get about a 35% speedup with the warm caching pathway, for a total runtime of ~750ms on average. The remaining runtime is almost entirely dominated by the single (minimally cacheable) POST we perform against OSV. --------- Signed-off-by: William Woodruff <william@astral.sh>
This was referenced Apr 20, 2026
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.
Summary
WIP.Atop #18936. See also #18781 and #18506.The basic idea here is to add a layer of
(manual)caching to our OSV interactions, but only for "positive" hits -- it's OK for us to cache actual successful lookups of(name, version)pairs to identifiers, but failed lookups should never be cached to prevent us from presenting false negatives to users.Test Plan
The functionality itself here is referentially transparent, so the existing tests confirm that it works.
Separately, in terms of benchmarking, I did a profiling build and ran with:
...on a project with 198 dependencies and 4 found vulnerabilities.
On a local machine I get about a 35% speedup with the warm caching pathway, for a total runtime of ~750ms on average. The remaining runtime is almost entirely dominated by the single (minimally cacheable) POST we perform against OSV.