Skip to content

Add critical path to BEP #25

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

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
Open

Conversation

arvi18
Copy link

@arvi18 arvi18 commented Apr 28, 2025

Additional info will be added in follow-ups.

@arvi18
Copy link
Author

arvi18 commented Apr 28, 2025

@meisterT PTAL

@arvi18
Copy link
Author

arvi18 commented Apr 28, 2025

ping?

@arvi18
Copy link
Author

arvi18 commented Apr 28, 2025

@Yannic I am sorry that I didn't get to this one earlier.

What other metrics do you plan to include here in the future? If it is just the total time, adding it here might be better? https://cs.opensource.google/bazel/bazel/+/master:src/main/java/com/google/devtools/build/lib/buildeventstream/proto/build_event_stream.proto;l=955;drc=58eeea17db80cc85d685d9319655f2dc398f063d

@arvi18
Copy link
Author

arvi18 commented Apr 28, 2025

@meisterT I'd like to include the actions on the critical path and metrics about them (executed locally vs remotely vs in a worker, how long input upload or output download took, ...)

@arvi18
Copy link
Author

arvi18 commented Apr 28, 2025

Is that uploaded to BES like the Bazel profile?

@arvi18
Copy link
Author

arvi18 commented Apr 28, 2025

Yes, it is. That's also how we use it internally.

Copy link

coderabbitai bot commented Apr 28, 2025

Warning

Rate limit exceeded

@visz11 has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 21 minutes and 47 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📥 Commits

Reviewing files that changed from the base of the PR and between c0c98a2 and bc17e9a.

📒 Files selected for processing (10)
  • src/main/java/com/google/devtools/build/lib/buildeventstream/proto/BUILD (1 hunks)
  • src/main/java/com/google/devtools/build/lib/buildeventstream/proto/build_event_stream.proto (5 hunks)
  • src/main/java/com/google/devtools/build/lib/buildtool/BuildTool.java (2 hunks)
  • src/main/java/com/google/devtools/build/lib/metrics/criticalpath/AggregatedCriticalPath.java (2 hunks)
  • src/main/java/com/google/devtools/build/lib/metrics/criticalpath/BUILD (1 hunks)
  • src/main/java/com/google/devtools/build/lib/metrics/criticalpath/CriticalPathEvent.java (1 hunks)
  • src/main/java/com/google/devtools/build/lib/runtime/BuildSummaryStatsModule.java (1 hunks)
  • src/main/protobuf/BUILD (2 hunks)
  • src/main/protobuf/critical_path.proto (1 hunks)
  • src/test/java/com/google/devtools/build/lib/buildtool/util/BuildIntegrationTestCase.java (2 hunks)
✨ Finishing Touches
  • 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@arvi18
Copy link
Author

arvi18 commented Apr 28, 2025

Oh, great! Let me see if that works for what I had in mind

@arvi18
Copy link
Author

arvi18 commented Apr 28, 2025

Yes, it is. That's also how we use it internally.

I assume we need to modify --remote_build_event_upload=minimal to upload this as well, as that only uploads logs and the profile currently:

https://github.com/bazelbuild/bazel/blob/c9c28a9b4324f1eebbbe2e23f471e0880fabd559/src/main/java/com/google/devtools/build/lib/remote/ByteStreamBuildEventArtifactUploader.java#L222-L236

cc: @coeuvre

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Hello @arvi18, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

Summary of Changes

This pull request introduces the critical path to the Build Event Protocol (BEP). It adds a new protobuf definition for CriticalPath, includes it in the BuildEvent message, and publishes a CriticalPathEvent to the event bus. This allows clients to receive information about the total time of the critical path of a build via the BEP.

Highlights

  • Critical Path Proto Definition: A new proto file critical_path.proto is added, defining the CriticalPath message, which includes the total time of the critical path.
  • BEP Integration: The CriticalPath message is integrated into the BuildEvent proto, allowing it to be included in the Build Event Stream.
  • Event Publishing: The AggregatedCriticalPath class now posts a CriticalPathEvent to the event bus, which contains the total time of the critical path. This event is then included in the BEP.
  • Build Tool Changes: The BuildTool class is modified to include the CriticalPathEvent in the list of events posted at the end of a build.

Changelog

Click here to see the changelog
  • src/main/java/com/google/devtools/build/lib/buildeventstream/proto/BUILD
    • Added dependency on //src/main/protobuf:critical_path_proto.
  • src/main/java/com/google/devtools/build/lib/buildeventstream/proto/build_event_stream.proto
    • Imported src/main/protobuf/critical_path.proto.
    • Added critical_path to the BuildEventId oneof.
    • Added critical_path field to the BuildEvent message.
  • src/main/java/com/google/devtools/build/lib/buildtool/BuildTool.java
    • Imported com.google.devtools.build.lib.metrics.criticalpath.CriticalPathEvent.
    • Added CriticalPathEvent.BEP_ID to the list of events posted in stopRequest().
  • src/main/java/com/google/devtools/build/lib/metrics/criticalpath/AggregatedCriticalPath.java
    • Added postEvent() method to post the CriticalPathEvent to the event bus.
  • src/main/java/com/google/devtools/build/lib/metrics/criticalpath/BUILD
    • Added dependencies for BEP integration and protobuf.
  • src/main/java/com/google/devtools/build/lib/metrics/criticalpath/CriticalPathEvent.java
    • Created new class CriticalPathEvent to represent the BEP event for the critical path.
  • src/main/java/com/google/devtools/build/lib/runtime/BuildSummaryStatsModule.java
    • Called criticalPath.postEvent(eventBus) to publish the event.
  • src/main/protobuf/BUILD
    • Added critical_path_proto, critical_path_java_proto, and critical_path_java_proto_srcs targets.
    • Added :critical_path_java_proto_srcs to the filegroup.
  • src/main/protobuf/critical_path.proto
    • Created new proto file critical_path.proto to define the CriticalPath message.
  • src/test/java/com/google/devtools/build/lib/buildtool/util/BuildIntegrationTestCase.java
    • Added BuildSummaryStatsModule to the runtime builder.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in issue comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist is currently in preview and may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments to provide feedback.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.


A path so critical,
Its time we must chronicle,
In BEP it shall reside,
With duration as its guide,
A build's tale, now typical.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

The pull request introduces the critical path to the Build Event Protocol (BEP). This is a valuable addition for understanding build performance. The changes involve adding a new protobuf definition for critical path data, integrating it into the build process, and exposing it through the BEP. Overall, the changes seem well-structured, but some areas could benefit from further clarification and potential improvements.

Summary of Findings

  • Missing Documentation: The pull request description is minimal. More information about the purpose of the changes, how to use the new feature, and any potential impact on existing functionality would be beneficial.
  • Clarity of 'Next id' Comments: The comments indicating 'Next id' in the protobuf definitions could be more descriptive. It's not immediately clear what these IDs refer to or why they are important.
  • Error Handling: While the code adds functionality for critical path analysis, it's not clear how errors during critical path computation or BEP event posting are handled. Robust error handling is crucial for production systems.

Merge Readiness

The pull request introduces important functionality, but it's not quite ready for merging. The missing documentation and lack of clarity in certain comments should be addressed. Additionally, the error handling aspects need to be carefully reviewed. I am unable to directly approve this pull request, and recommend that it not be merged until these issues are addressed, and that others review and approve this code before merging.

Comment on lines +109 to +114
/**Posts the {@code BEP} event for the critical path on the provided {@link EventBus}. */
public void postEvent(EventBus eventBus) {
Preconditions.checkNotNull(eventBus);

eventBus.post(new CriticalPathEvent(Duration.ofMillis(totalTimeInMs)));
}

Choose a reason for hiding this comment

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

medium

Consider adding a try-catch block around the eventBus.post call to handle potential exceptions during event posting. This could prevent the entire build from failing if there's an issue with the event bus.

  /**Posts the {@code BEP} event for the critical path on the provided {@link EventBus}. */
  public void postEvent(EventBus eventBus) {
    Preconditions.checkNotNull(eventBus);
    try {
      eventBus.post(new CriticalPathEvent(Duration.ofMillis(totalTimeInMs)));
    } catch (Exception e) {
      // Log the exception or handle it appropriately.
      System.err.println("Error posting CriticalPathEvent: " + e.getMessage());
    }
  }

@visz11
Copy link
Collaborator

visz11 commented Apr 28, 2025

@coderabbitai full review

Copy link

coderabbitai bot commented Apr 28, 2025

✅ Actions performed

Full review triggered.

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.

3 participants