-
Notifications
You must be signed in to change notification settings - Fork 0
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
base: master
Are you sure you want to change the base?
Conversation
|
@meisterT PTAL |
|
ping? |
|
@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 |
|
@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, ...) |
|
Is that uploaded to BES like the Bazel profile? |
|
Yes, it is. That's also how we use it internally. |
|
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 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. 📒 Files selected for processing (10)
✨ Finishing Touches
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. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
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)
Other keywords and placeholders
CodeRabbit Configuration File (
|
|
Oh, great! Let me see if that works for what I had in mind |
I assume we need to modify cc: @coeuvre |
There was a problem hiding this 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.protois added, defining theCriticalPathmessage, which includes the total time of the critical path. - BEP Integration: The
CriticalPathmessage is integrated into theBuildEventproto, allowing it to be included in the Build Event Stream. - Event Publishing: The
AggregatedCriticalPathclass now posts aCriticalPathEventto the event bus, which contains the total time of the critical path. This event is then included in the BEP. - Build Tool Changes: The
BuildToolclass is modified to include theCriticalPathEventin 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.
- Added dependency on
- src/main/java/com/google/devtools/build/lib/buildeventstream/proto/build_event_stream.proto
- Imported
src/main/protobuf/critical_path.proto. - Added
critical_pathto theBuildEventIdoneof. - Added
critical_pathfield to theBuildEventmessage.
- Imported
- src/main/java/com/google/devtools/build/lib/buildtool/BuildTool.java
- Imported
com.google.devtools.build.lib.metrics.criticalpath.CriticalPathEvent. - Added
CriticalPathEvent.BEP_IDto the list of events posted instopRequest().
- Imported
- src/main/java/com/google/devtools/build/lib/metrics/criticalpath/AggregatedCriticalPath.java
- Added
postEvent()method to post theCriticalPathEventto the event bus.
- Added
- 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
CriticalPathEventto represent the BEP event for the critical path.
- Created new class
- src/main/java/com/google/devtools/build/lib/runtime/BuildSummaryStatsModule.java
- Called
criticalPath.postEvent(eventBus)to publish the event.
- Called
- src/main/protobuf/BUILD
- Added
critical_path_proto,critical_path_java_proto, andcritical_path_java_proto_srcstargets. - Added
:critical_path_java_proto_srcsto thefilegroup.
- Added
- src/main/protobuf/critical_path.proto
- Created new proto file
critical_path.prototo define theCriticalPathmessage.
- Created new proto file
- src/test/java/com/google/devtools/build/lib/buildtool/util/BuildIntegrationTestCase.java
- Added
BuildSummaryStatsModuleto the runtime builder.
- Added
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
-
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. ↩
There was a problem hiding this 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.
| /**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))); | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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());
}
}|
@coderabbitai full review |
✅ Actions performedFull review triggered. |
|
/refacto-test |
|
Refacto is reviewing this PR. Please wait for the review comments to be posted. |
| import com.google.devtools.build.lib.buildeventstream.GenericBuildEvent; | ||
| import java.time.Duration; | ||
| import java.util.Collection; | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Information Disclosure Consideration: The CriticalPathEvent exposes detailed timing information (down to nanoseconds) about the build's critical path. While this is low severity, consider if this level of detail is necessary for all users or if access controls should limit this information to authorized users only. In security-sensitive environments, this information could potentially aid in reconnaissance by revealing system bottlenecks or optimization targets.
|
/refacto-test |
|
PR already reviewed at the latest commit: bc17e9a. |
|
/refacto-test |
|
/refacto-test |
|
Refacto is reviewing this PR. Please wait for the review comments to be posted. |
Code Review: BEP Integration Enhancement👍 Well Done
📌 Files Processed
📝 Additional Comments
|
| /**Posts the {@code BEP} event for the critical path on the provided {@link EventBus}. */ | ||
| public void postEvent(EventBus eventBus) { | ||
| Preconditions.checkNotNull(eventBus); | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing Event Validation
The eventBus.post() call lacks null checking for totalTimeInMs which could cause runtime exceptions if the field is uninitialized. This could lead to failure when posting critical path events, potentially breaking the build event protocol integration.
Standards
- ISO-IEC-25010-Reliability-Fault-Tolerance
- ISO-IEC-25010-Functional-Correctness-Appropriateness
- DbC-Precondition
| BuildEventIdUtil.buildToolLogs(), | ||
| BuildEventIdUtil.buildMetrics(), | ||
| CriticalPathEvent.BEP_ID))); | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Potential Null Reference
Added CriticalPathEvent.BEP_ID reference without null checking could cause NullPointerException if BEP_ID is not properly initialized. This would break the build completion event posting, potentially causing build failures or incomplete build events.
Standards
- ISO-IEC-25010-Reliability-Fault-Tolerance
- ISO-IEC-25010-Functional-Correctness-Appropriateness
| public void postEvent(EventBus eventBus) { | ||
| Preconditions.checkNotNull(eventBus); | ||
|
|
||
| eventBus.post(new CriticalPathEvent(Duration.ofMillis(totalTimeInMs))); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing Event Registration
The CriticalPathEvent is posted to the eventBus but there's no corresponding registration of the event handler. Without proper registration, the event will be posted but may not be processed by any listeners, causing the critical path information to be lost.
Standards
- Business-Rule-Event-Handling
- Logic-Verification-Event-Flow
- Algorithm-Correctness-Event-Processing
| // Represents the critical path of a build. | ||
| message CriticalPath { | ||
| // Identifier of a BES event of this type. | ||
| message BepId {} | ||
|
|
||
| // The total time of the critical path. | ||
| google.protobuf.Duration total_time = 1; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Incomplete Documentation
The CriticalPath message lacks comprehensive documentation about its purpose and usage. Adding more detailed comments would improve maintainability by clarifying what critical path represents and how it's calculated.
Standards
- Clean-Code-Documentation
- Maintainability-Quality-Documentation
| message CriticalPath { | ||
| // Identifier of a BES event of this type. | ||
| message BepId {} | ||
|
|
||
| // The total time of the critical path. | ||
| google.protobuf.Duration total_time = 1; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Limited Event Data
The CriticalPath message contains only total_time with no additional information about path components or bottlenecks. This limits extensibility and future analysis capabilities. Consider adding fields for critical path components.
Standards
- SOLID-OCP
- Design-Pattern-Extensibility
- Maintainability-Quality-Evolvability
| CriticalPathEvent(Duration totalTime) { | ||
| super(BEP_ID, ImmutableList.of()); | ||
|
|
||
| this.totalTime = Preconditions.checkNotNull(totalTime); | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Limited Constructor Access
CriticalPathEvent constructor has package-private access, limiting reusability from other packages. Consider making it public with appropriate factory methods if this event should be creatable outside its package.
Standards
- Clean-Code-API-Design
- SOLID-OCP
- Maintainability-Quality-Reusability
| public void postEvent(EventBus eventBus) { | ||
| Preconditions.checkNotNull(eventBus); | ||
|
|
||
| eventBus.post(new CriticalPathEvent(Duration.ofMillis(totalTimeInMs))); | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Factory Method Missing
Direct instantiation of CriticalPathEvent couples AggregatedCriticalPath to the concrete implementation. Consider adding a factory method in CriticalPathEvent for creating instances, improving maintainability through better abstraction.
Standards
- Design-Pattern-Factory
- SOLID-DIP
- Maintainability-Quality-Coupling
Additional info will be added in follow-ups.