Skip to content

Switch to batched OSV queries for uv audit#18394

Merged
woodruffw merged 4 commits intomainfrom
ww/uv-audit-osv-bulk
Mar 11, 2026
Merged

Switch to batched OSV queries for uv audit#18394
woodruffw merged 4 commits intomainfrom
ww/uv-audit-osv-bulk

Conversation

@woodruffw
Copy link
Copy Markdown
Member

@woodruffw woodruffw commented Mar 10, 2026

Summary

This switches us to OSV's batch query API for vulnerability ID lookups, which can then be used to concurrently fetch the actual full finding responses.

In my local testing, this yields significant speedups: from 23s on main (before this PR) with a small project (~70 deps) to 950ms with this PR.

WIP, I want to think through this approach a little more.

See #18119

Test Plan

Added new unit tests.

Signed-off-by: William Woodruff <william@astral.sh>
@woodruffw woodruffw self-assigned this Mar 10, 2026
@woodruffw woodruffw added performance Potential performance improvement preview Experimental behavior labels Mar 10, 2026
@woodruffw woodruffw mentioned this pull request Mar 10, 2026
10 tasks
let vuln = self.fetch_vuln(&id).await?;
Ok::<(String, Vulnerability), Error>((id, vuln))
})
.buffer_unordered(usize::MAX);
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.

Flagging: I wasn't sure if it makes sense to plumb Concurrency::downloads as a limit here.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Yes, that limit should apply in all locations where we do network requests.

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.

Done! I need to separately plumb the concurrency from the CLI, I'll do that in a follow-up.

@woodruffw woodruffw requested a review from konstin March 10, 2026 16:23
@woodruffw woodruffw marked this pull request as ready for review March 10, 2026 16:23
Copy link
Copy Markdown
Member

@konstin konstin left a comment

Choose a reason for hiding this comment

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

We need the cocnurrency limit, otherwise it's good to go!

let vuln = self.fetch_vuln(&id).await?;
Ok::<(String, Vulnerability), Error>((id, vuln))
})
.buffer_unordered(usize::MAX);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Yes, that limit should apply in all locations where we do network requests.

//!
//! [OSV]: https://osv.dev/

use std::collections::{HashMap, HashSet};
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think we generally prefer using rustc_hash::{FxHashMap, FxHashSet} in uv.

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.

Yep, I'll replace. It probably makes sense to slowly replace any pre-existing callsites for these and eventually ban their use via clippy?

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 woodruffw merged commit 761c746 into main Mar 11, 2026
110 checks passed
@woodruffw woodruffw deleted the ww/uv-audit-osv-bulk branch March 11, 2026 11:25
woodruffw added a commit that referenced this pull request Mar 11, 2026
## Summary

Follows #18394. This plumbs the actual concurrency settings (rather than
their default) and removes the default impl for `Osv`.

## Test Plan

NFC.

Signed-off-by: William Woodruff <william@astral.sh>
@woodruffw woodruffw mentioned this pull request Mar 16, 2026
21 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

performance Potential performance improvement preview Experimental behavior

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants