Skip to content

perf: optimize memory usage during Debian CVE conversion#5291

Merged
jess-lowe merged 2 commits intogoogle:masterfrom
jess-lowe:perf-fix-debian-cve-memory-1462681954862797174
Apr 30, 2026
Merged

perf: optimize memory usage during Debian CVE conversion#5291
jess-lowe merged 2 commits intogoogle:masterfrom
jess-lowe:perf-fix-debian-cve-memory-1462681954862797174

Conversation

@jess-lowe
Copy link
Copy Markdown
Contributor

@jess-lowe jess-lowe commented Apr 30, 2026

I noticed that the Debian CVE converter was OOMing occasionally recently, and it was likely due to the following:

The vulns.LoadAllCVEs function previously loaded the entire NVD CVE dataset into memory by reading hundreds of thousands of CVE JSON files concurrently. This caused massive memory spikes and high garbage collection overhead during the Debian CVE conversion process.

This commit introduces a target-based filtering approach:

  • Added LoadTargetCVEs which accepts a map of required CVE IDs.
  • Modified the JSON parsing loop to only emit vulnerabilities that are present in the target list.
  • Refactored cmd/converters/debian/main.go to extract the needed CVEs from the Debian Security Tracker data and pass them into LoadTargetCVEs.
  • Preserved the existing LoadAllCVEs interface for backward compatibility. (Alpine still uses it, I believe - I should probably fix this too)

The `vulns.LoadAllCVEs` function previously loaded the entire NVD CVE dataset into memory by reading hundreds of thousands of CVE JSON files concurrently. This caused massive memory spikes and high garbage collection overhead during the Debian CVE conversion process.

This commit introduces a target-based filtering approach:
- Added `LoadTargetCVEs` which accepts a map of required CVE IDs.
- Modified the JSON parsing loop to only emit vulnerabilities that are present in the target list.
- Refactored `cmd/converters/debian/main.go` to extract the needed CVEs from the Debian Security Tracker data and pass them into `LoadTargetCVEs`.
- Preserved the existing `LoadAllCVEs` interface for backward compatibility.

Co-authored-by: jess-lowe <86962800+jess-lowe@users.noreply.github.com>
@jess-lowe jess-lowe requested review from a team and tobyhawker April 30, 2026 00:59
Ly-Joey
Ly-Joey previously approved these changes Apr 30, 2026
michaelkedar
michaelkedar previously approved these changes Apr 30, 2026
The `vulns.LoadAllCVEs` function previously loaded the entire NVD CVE dataset into memory by reading hundreds of thousands of CVE JSON files concurrently. This caused massive memory spikes and high garbage collection overhead during the Debian and Alpine CVE conversion process.

This commit introduces a target-based filtering approach:
- Added `LoadTargetCVEs` which accepts a map of required CVE IDs.
- Modified the JSON parsing loop to only emit vulnerabilities that are present in the target list.
- Refactored `cmd/converters/debian/main.go` and `cmd/converters/alpine/main.go` to extract the needed CVEs from the respective security tracker data and pass them into `LoadTargetCVEs`.
- Preserved the existing `LoadAllCVEs` interface for backward compatibility.

Co-authored-by: jess-lowe <86962800+jess-lowe@users.noreply.github.com>
@jess-lowe jess-lowe dismissed stale reviews from michaelkedar and Ly-Joey via 15302f9 April 30, 2026 01:45
@jess-lowe jess-lowe merged commit 448826d into google:master Apr 30, 2026
21 checks passed
@jess-lowe jess-lowe deleted the perf-fix-debian-cve-memory-1462681954862797174 branch May 1, 2026 00:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants