Conversation
This was referenced Sep 4, 2025
another-rex
pushed a commit
to google/osv-scanner
that referenced
this pull request
Sep 5, 2025
…ages are affected (#2219) Currently when doing local matching we remove withdrawn advisories before any further checks by building a dedicated new slice, which results in huge memory usage - see [this comment](#2217 (comment)) for some profiles, but e.g. scanning our own `go.mod` takes up 1.5gb of memory. I originally implemented it like this back in `osv-detector` as I found it interesting to include withdrawn advisories to review data quality and have their count in the output, but it's not worth this. I have actually since ended up optimizing this out of the detector anyway via G-Rath/osv-detector#216 which switched to using a map for vulnerabilities meaning I calculated the count differently, but for now this just brings over the change for fixing the memory issue. Resolves #2217 --------- Co-authored-by: Xueqin Cui <72771658+cuixq@users.noreply.github.com>
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.
This greatly improves the performance of determining vulnerabilities since now only advisories that actually could match a package are checked, rather than looping through all of them for all packages which scales much better as the number of advisories in a database grows.
You can easily see the difference in speed by just running
make regenerate-e2e-fixtures- before this change it typically takes 30 seconds whereas after it takes only 10.This also means that the detector no longer loads advisories without any affected packages, which really shouldn't change anything but lets us easily stop using the
Vulnerabilitiesfunction reducing the size by a couple of KB - I've kept the function because its still used in tests and doesn't have to be removed so this is less breaking.