[8.8.0] Redo logic for bfs of VendorCommand.java (https://github.com/bazelbuild/bazel/pull/30088)#30151
Open
bazel-io wants to merge 1 commit into
Open
[8.8.0] Redo logic for bfs of VendorCommand.java (https://github.com/bazelbuild/bazel/pull/30088)#30151bazel-io wants to merge 1 commit into
bazel-io wants to merge 1 commit into
Conversation
meisterT
approved these changes
Jul 7, 2026
Wyverald
approved these changes
Jul 7, 2026
Redo logic for bfs of VendorCommand.java ### Description Adding the nodes of the graph into visited when we're dequeing while checking if they exist while enqueing means that we might accidentally add the same nodes multiple time, leading to OOM on big production graphs. Example: ``` target keys = [A, B] nodes = [A, B] A -> C B -> C ``` We visit A, then add C to nodes. Then we visit B, also adding C to nodes under the old logic (duplicated). This patch changes the logic so that we add a node to visited whenever we enqueue so this doesn't happen. See https://en.wikipedia.org/wiki/Breadth-first_search#Pseudocode for pseudocode. ### Motivation Fix oom bug ### Build API Changes No ### Checklist - [NA] I have added tests for the new use cases (if any). - [NA] I have updated the documentation (if applicable). ### Release Notes RELNOTES: None Closes bazelbuild#30088. PiperOrigin-RevId: 943722164 Change-Id: I153afd4281a3c138fe401a145b0d6465fa198e50
484bdd6 to
e1654ec
Compare
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.
Redo logic for bfs of VendorCommand.java
Description
Adding the nodes of the graph into visited when we're dequeing while checking if they exist while enqueing means that we might accidentally add the same nodes multiple time, leading to OOM on big production graphs.
Example:
We visit A, then add C to nodes.
Then we visit B, also adding C to nodes under the old logic (duplicated).
This patch changes the logic so that we add a node to visited whenever we enqueue so this doesn't happen. See
https://en.wikipedia.org/wiki/Breadth-first_search#Pseudocode for pseudocode.
Motivation
Fix oom bug
Build API Changes
No
Checklist
Release Notes
RELNOTES: None
Closes #30088.
PiperOrigin-RevId: 943722164
Change-Id: I153afd4281a3c138fe401a145b0d6465fa198e50
Commit 01407e4