Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add profiling for Bzlmod operations #19291

Closed
wants to merge 1 commit into from

Conversation

fmeum
Copy link
Collaborator

@fmeum fmeum commented Aug 21, 2023

The resolution of Bazel modules and evaluation of module extensions is now represented in the profile.

Profile from a run of bazel build //src:bazel-dev --enable_bzlmod --nobuild:
Bzlmod profile

@github-actions github-actions bot added awaiting-review PR is awaiting review from an assigned reviewer team-ExternalDeps External dependency handling, remote repositiories, WORKSPACE file. team-Performance Issues for Performance teams labels Aug 21, 2023
@fmeum
Copy link
Collaborator Author

fmeum commented Aug 21, 2023

The profile shows that module resolution is much slower than it could be due to serial downloads. Maybe we can get a quick win here with a thread pool and then adopt Loom later on?

The resolution of Bazel modules and evaluation of module extensions is
now represented in the profile.
@meteorcloudy
Copy link
Member

@meisterT Can anyone from the build productivity team also take a look?

Copy link
Member

@meteorcloudy meteorcloudy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome, thanks!

@meteorcloudy meteorcloudy added awaiting-PR-merge PR has been approved by a reviewer and is ready to be merge internally and removed awaiting-review PR is awaiting review from an assigned reviewer labels Aug 21, 2023
Copy link
Member

@Wyverald Wyverald left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thank you!

@Wyverald
Copy link
Member

Could you share your profile result here? I'd love to take a look too (too many '...'s in that screenshot :))

@fmeum
Copy link
Collaborator Author

fmeum commented Aug 21, 2023

Could you share your profile result here? I'd love to take a look too (too many '...'s in that screenshot :))

command.profile.gz

@fmeum
Copy link
Collaborator Author

fmeum commented Aug 21, 2023

It's interesting to see how the cyclic dependency between rules_go and gazelle contributes to the critical path.

@Wyverald
Copy link
Member

It's interesting to see how the cyclic dependency between rules_go and gazelle contributes to the critical path.

Yeah that's essentially a really long dependency chain. We could be smarter there -- don't bother with deps at lower versions if we know there's no multiple-version override, for example. It would make the discovery code a bit more gnarly, but anyway.

@Wyverald
Copy link
Member

Wyverald commented Aug 21, 2023

It's interesting to see how the cyclic dependency between rules_go and gazelle contributes to the critical path.

Yeah that's essentially a really long dependency chain. We could be smarter there -- don't bother with deps at lower versions if we know there's no multiple-version override, for example. It would make the discovery code a bit more gnarly, but anyway.

But do note that this needs to be done very carefully, or version resolution might become nondeterministic-- if the lower version itself has higher-version deps, we need to make sure we have a deterministic way to decide which "lower version" to drop. The end result is still some set of minimal versions, but is not the original MVS. This is related to the original idea by @meteorcloudy

@fmeum fmeum requested a review from Wyverald August 23, 2023 12:58
@fmeum
Copy link
Collaborator Author

fmeum commented Aug 23, 2023

(didn't mean to rerequest a review, I didn't make any changes)

@github-actions github-actions bot removed the awaiting-PR-merge PR has been approved by a reviewer and is ready to be merge internally label Aug 23, 2023
@fmeum fmeum deleted the bzlmod-profile branch August 23, 2023 19:31
@fmeum
Copy link
Collaborator Author

fmeum commented Aug 23, 2023

@bazel-io flag

@bazel-io bazel-io added the potential release blocker Flagged by community members using "@bazel-io flag". Should be added to a release blocker milestone label Aug 23, 2023
@iancha1992
Copy link
Member

@bazel-io fork 6.4.0

@bazel-io bazel-io removed the potential release blocker Flagged by community members using "@bazel-io flag". Should be added to a release blocker milestone label Aug 23, 2023
iancha1992 pushed a commit to iancha1992/bazel that referenced this pull request Aug 23, 2023
The resolution of Bazel modules and evaluation of module extensions is now represented in the profile.

Profile from a run of `bazel build //src:bazel-dev --enable_bzlmod --nobuild`:
![Bzlmod profile](https://github.com/bazelbuild/bazel/assets/4312191/22e03604-f832-4f64-be0e-a3281b94da3e)

Closes bazelbuild#19291.

PiperOrigin-RevId: 559466489
Change-Id: If0989a4a6728f8dbf659197a7acbd3a0fcef9471
@iancha1992
Copy link
Member

@fmeum @meisterT @Wyverald @meteorcloudy I think we may need another commit before we cherry-pick this one to 6.4.0 because in src/main/java/com/google/devtools/build/lib/runtime/BlazeCommandDispatcher.java line 622, we have earlyExitCode = optionHandler.parseStarlarkOptions(env, reporter); in the release-6.4.0 branch. But it really should be earlyExitCode = optionHandler.parseStarlarkOptions(env); before the change.

cc: https://github.com/orgs/bazelbuild/teams/triage

meteorcloudy pushed a commit that referenced this pull request Aug 24, 2023
The resolution of Bazel modules and evaluation of module extensions is
now represented in the profile.

Profile from a run of `bazel build //src:bazel-dev --enable_bzlmod
--nobuild`: ![Bzlmod
profile](https://github.com/bazelbuild/bazel/assets/4312191/22e03604-f832-4f64-be0e-a3281b94da3e)

Closes #19291.

Commit
e7cfd2e#diff-602cd193eba2ecc3a616c8a5cb84e93d27ef4ee613d650139ff7bfa21bcee1f2

PiperOrigin-RevId: 559466489
Change-Id: If0989a4a6728f8dbf659197a7acbd3a0fcef9471

---------

Co-authored-by: Fabian Meumertzheim <fabian@meumertzhe.im>
@iancha1992
Copy link
Member

The changes in this PR have been included in Bazel 6.4.0 RC1. Please test out the release candidate and report any issues as soon as possible. If you're using Bazelisk, you can point to the latest RC by setting USE_BAZEL_VERSION=last_rc.
Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
team-ExternalDeps External dependency handling, remote repositiories, WORKSPACE file. team-Performance Issues for Performance teams
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants