Repository navigation
fix(vulnfeeds): prevent OOM in combine-to-osv and optimize memory usage - #6178
Merged
Merged
Conversation
…k size and releasing memory early
michaelkedar
approved these changes
Oct 16, 2026
| logger.Info("Uploading vulnerability record to GCS", slog.String("id", vulnID), slog.String("object", objName)) | ||
|
|
||
| wc := obj.NewWriter(ctx) | ||
| wc.ChunkSize = googleapi.MinUploadChunkSize |
Member
There was a problem hiding this comment.
this might slow things down considerably?
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.
Description
Resolves out-of-memory (OOM) crashes in
combine-to-osvwhen processing large datasets with populated affected packages/commits.Root Causes
cloud.google.com/go/storage'sWriterdefaultsChunkSizeto 16 MiB. With 64 concurrent upload workers continuously writing small JSON records (~2–10 KiB), this produced gigabytes of buffer allocations per second.cve5FilesandnvdFiles(~300k strings each) remained reachable onmain()'s stack for the entire run.workItems(300k items) remained live in memory while processing.validIDsaccumulated 300k strings even when-sync-deletionswas false.isReferencesOnlyonly checked the top-levelfields["source"], missingextracted_eventswithsource: "REFERENCES".Changes
ChunkSize: Setwc.ChunkSize = googleapi.MinUploadChunkSize(256 KiB) ingcs.UploadToGCSandwriter.uploadIfChanged.cve5FilesandnvdFilesimmediately after building the work queue.workItemsmap as they are dispatched and nil out the map after dispatch.validIDsif*syncDeletions && *uploadToGCSis true; use an atomic countervalidCountfor progress and summary logging.isReferencesOnly: Checkextracted_eventsforsource: "REFERENCES"(mirroringisCPERange).main_test.go: Added helpermustParseDBSpecificusingprotojson.Unmarshalto clean up verbose manualstructpb.Structdeclarations.Testing
cd vulnfeeds && go test ./...passed.poetry run tools/lint_and_format.shpassed with 0 findings.