Skip to content

[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
bazelbuild:release-8.8.0from
bazel-io:cp30088-8.8.0-073726
Open

[8.8.0] Redo logic for bfs of VendorCommand.java (https://github.com/bazelbuild/bazel/pull/30088)#30151
bazel-io wants to merge 1 commit into
bazelbuild:release-8.8.0from
bazel-io:cp30088-8.8.0-073726

Conversation

@bazel-io

@bazel-io bazel-io commented Jul 7, 2026

Copy link
Copy Markdown
Member

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 #30088.

PiperOrigin-RevId: 943722164
Change-Id: I153afd4281a3c138fe401a145b0d6465fa198e50

Commit 01407e4

@bazel-io bazel-io added team-ExternalDeps External dependency handling, remote repositiories, WORKSPACE file. awaiting-review PR is awaiting review from an assigned reviewer labels Jul 7, 2026
@bazel-io bazel-io requested a review from a team as a code owner July 7, 2026 07:37
@bazel-io bazel-io added the team-ExternalDeps External dependency handling, remote repositiories, WORKSPACE file. label Jul 7, 2026
@bazel-io bazel-io requested a review from fmeum July 7, 2026 07:37
@bazel-io bazel-io added the awaiting-review PR is awaiting review from an assigned reviewer label Jul 7, 2026
@bazel-io bazel-io requested review from SalmaSamy and meisterT July 7, 2026 07:37
@Wyverald Wyverald enabled auto-merge July 7, 2026 18:04
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
@iancha1992 iancha1992 force-pushed the cp30088-8.8.0-073726 branch from 484bdd6 to e1654ec Compare July 7, 2026 18:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

awaiting-review PR is awaiting review from an assigned reviewer team-ExternalDeps External dependency handling, remote repositiories, WORKSPACE file.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants