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

Piping diagnostics through BEP #11766

Closed
wants to merge 4 commits into from

Conversation

SocksDevil
Copy link

@SocksDevil SocksDevil commented Jul 14, 2020

Pipes structured diagnostics information through BEP, information being used to develop a bazel extension to support BSP, which can be found here.

Starting the work to generalise to implement diagnostics for the javac wrapper.
Related to the work done in rules_scala, in PR #1068

@SocksDevil SocksDevil requested a review from lberki as a code owner July 14, 2020 12:21
@googlebot
Copy link

All (the pull request submitter and all commit authors) CLAs are signed, but one or more commits were authored or co-authored by someone other than the pull request submitter.

We need to confirm that all authors are ok with their commits being contributed to this project. Please have them confirm that by leaving a comment that contains only @googlebot I consent. in this pull request.

Note to project maintainer: There may be cases where the author cannot leave a comment, or the comment is not properly detected as consent. In those cases, you can manually confirm consent of the commit author(s), and set the cla label to yes (if enabled on your project).

ℹ️ Googlers: Go here for more info.

@illicitonion
Copy link
Contributor

@googlebot I consent.

@googlebot
Copy link

CLAs look good, thanks!

ℹ️ Googlers: Go here for more info.

@jin
Copy link
Member

jin commented Jul 14, 2020

Quick summary of this change: Structured Compiler Diagnostics (design doc) is a way to surface compiler warnings and errors (otherwise known as diagnostics) in a structured manner, eventually leading up to the BEP. This will help the ecosystem create IDE integrations through Build Server Protocol / Language Server Protocol.

cc a few people working in affected areas, who can help to make the calls to approve this feature request:

@ericfelly for changes to Bazel action infrastructure
@alandonovan for changes to Starlark API
@philwo for Bazel OSS IDE integration through build server protocol

(I can only add @philwo as reviewer, but not @ericfelly and @alandonovan, not sure why)

@jin jin added the team-Core Skyframe, bazel query, BEP, options parsing, bazelrc label Jul 14, 2020
@jin jin requested a review from philwo July 14, 2020 14:02
@meisterT
Copy link
Member

cc @ulfjack

Copy link
Author

@SocksDevil SocksDevil left a comment

Choose a reason for hiding this comment

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

I've implemented Diagnostics for the Java compiler as well and would love to hear some feedback regarding these questions and the rest of the code, naturally! 😁

e.printStackTrace();
}
if(fileSystem != null)
this.diagnosticsFile = new Artifact.SourceArtifact(
Copy link
Author

Choose a reason for hiding this comment

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

I'm quite sure this is not the best place to do this, but since I did not find a better place, I'd love to hear your feedback regarding it

@@ -0,0 +1,15 @@
#!/usr/bin/env bash
Copy link
Author

Choose a reason for hiding this comment

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

As of right now this only supports OSX, but this is only temporary, I'm working on a generalized solution

@jin
Copy link
Member

jin commented Jul 24, 2020

Adding @comius, who is working on the Java rules now.

@SocksDevil SocksDevil marked this pull request as ready for review August 3, 2020 12:13
@SocksDevil SocksDevil requested a review from a team as a code owner August 3, 2020 12:13
@jin
Copy link
Member

jin commented Aug 7, 2020

I've noticed that @ericfelly left a comment in the design doc saying that he's added a new action_metadata_logs field to the ActionExecuted message in BEP. https://docs.google.com/document/d/1KCQMvUMNVUBDyDmZJ1DB80tf21MVQdyWYS0Y9D_P0as/edit?disco=AAAAGt1_dc8

Would that be sufficient for logging diagnostics, and using a tool to parse from those logs?

@SocksDevil
Copy link
Author

I've noticed that @ericfelly left a comment in the design doc saying that he's added a new action_metadata_logs field to the ActionExecuted message in BEP. https://docs.google.com/document/d/1KCQMvUMNVUBDyDmZJ1DB80tf21MVQdyWYS0Y9D_P0as/edit?disco=AAAAGt1_dc8

Would that be sufficient for logging diagnostics, and using a tool to parse from those logs?

(Idk if it's best to keep the discussion through the thread or the design doc, please let me know.)

It is mentioned that the field did not exist, but this is already what is being used for outputting the diagnostics. See here

@illicitonion
Copy link
Contributor

I've noticed that @ericfelly left a comment in the design doc saying that he's added a new action_metadata_logs field to the ActionExecuted message in BEP. https://docs.google.com/document/d/1KCQMvUMNVUBDyDmZJ1DB80tf21MVQdyWYS0Y9D_P0as/edit?disco=AAAAGt1_dc8
Would that be sufficient for logging diagnostics, and using a tool to parse from those logs?

(Idk if it's best to keep the discussion through the thread or the design doc, please let me know.)

It is mentioned that the field did not exist, but this is already what is being used for outputting the diagnostics. See here

I think concretely the change being requested is that in src/main/java/com/google/devtools/build/lib/buildeventstream/proto/build_event_stream.proto instead of adding File diagnostic_output = 12;, we append to already existing the list in repeated File action_metadata_logs = 10; - this seesm reasonable and hopefully simple to do :)

@SocksDevil
Copy link
Author

I've noticed that @ericfelly left a comment in the design doc saying that he's added a new action_metadata_logs field to the ActionExecuted message in BEP. https://docs.google.com/document/d/1KCQMvUMNVUBDyDmZJ1DB80tf21MVQdyWYS0Y9D_P0as/edit?disco=AAAAGt1_dc8
Would that be sufficient for logging diagnostics, and using a tool to parse from those logs?

(Idk if it's best to keep the discussion through the thread or the design doc, please let me know.)
It is mentioned that the field did not exist, but this is already what is being used for outputting the diagnostics. See here

I think concretely the change being requested is that in src/main/java/com/google/devtools/build/lib/buildeventstream/proto/build_event_stream.proto instead of adding File diagnostic_output = 12;, we append to already existing the list in repeated File action_metadata_logs = 10; - this seesm reasonable and hopefully simple to do :)

Perhaps I didn't express myself correctly, but the action metadata logs are already being populated and it is the means of getting the information I'm using already for the BSP server. I'll delete the field from the build event protocol

@SocksDevil
Copy link
Author

It has been requested by @philwo that this PR was split, in order to able to create a passing build for the java_tools. That PR can be found here

@jin
Copy link
Member

jin commented Aug 11, 2020

@andrefmrocha @illicitonion Thanks, I missed that. And thank you for working on this PR. Before we can go any further on this change, I'd really like to hear the thoughts from @ericfelly for Blaze Core implications, and @cushon for Java rules implications.

While I think this is a good idea for Bazel in general, I don't have enough visibility into the technical implications like @ericfelly and @cushon for their respective areas, so I'd request for their approvals as well. This PR adds wiring to the SpawnAction and ActionAnalysisMetadata machinery for a specific language ruleset, which are really hot paths and should require careful review. Can we make this feature opt-in and less intrusive?

This PR is also really large, which could make it difficult for reviewers to start from scratch, so I'd recommend reviewers to starting from the design doc. Is there any way you could break this PR down further?

Lastly, please ensure that the new and existing tests are passing on Bazel CI, across all platforms, and run google-java-format to format it according to the Google styleguide.

@SocksDevil
Copy link
Author

SocksDevil commented Aug 11, 2020

@andrefmrocha @illicitonion Thanks, I missed that. And thank you for working on this PR. Before we can go any further on this change, I'd really like to hear the thoughts from @ericfelly for Blaze Core implications, and @cushon for Java rules implications.

While I think this is a good idea for Bazel in general, I don't have enough visibility into the technical implications like @ericfelly and @cushon for their respective areas, so I'd request for their approvals as well. This PR adds wiring to the SpawnAction and ActionAnalysisMetadata machinery for a specific language ruleset, which are really hot paths and should require careful review. Can we make this feature opt-in and less intrusive?

This PR is also really large, which could make it difficult for reviewers to start from scratch, so I'd recommend reviewers to starting from the design doc. Is there any way you could break this PR down further?

Lastly, please ensure that the new and existing tests are passing on Bazel CI, across all platforms, and run google-java-format to format it according to the Google styleguide.

I believe the feature can be opt-in, this was also something discussed and implemented for rules_scala, where a flag was introduced into the scala toolchain. Wdyt of that solution?

The PR can definitely be broken even more: into the introduction of the diagnostics in actions, and then the implementation for java (taking into account the already existing one for java_tools). This would be quite interesting as well since we could parallelise the review of the java_tools and the introductions of the diagnostics. Wdyt?

Regarding the CI, as it is, I cannot make the tests pass, since they break due to the changes introduced to the java_tools that the java actions are expecting

@ericfelly
Copy link
Contributor

ericfelly commented Aug 11, 2020 via email

@SocksDevil
Copy link
Author

The PR is quite invasive indeed. We are paying a large complexity cost treating these diagnostic files as Artifacts. I'm not sure what this achieves. In the design discussion, I brought up the question of whether the diagnostics data was required incrementally. In other words, should a null build still be guaranteed to emit all transitive diagnostic information? Whether this is a requirement has significant implications on the design. If it's not a requirement, I think the implementation can be significantly simpler and extend the existing "action metadata" mechanism. If it is a requirement, I'm not seeing how the current PR achieves that. Eric Fellheimer felly@google.com

On Tue, Aug 11, 2020 at 3:51 AM André Rocha @.***> wrote: @andrefmrocha https://github.com/andrefmrocha @illicitonion https://github.com/illicitonion Thanks, I missed that. And thank you for working on this PR. Before we can go any further on this change, I'd really like to hear the thoughts from @ericfelly https://github.com/ericfelly for Blaze Core implications, and @cushon https://github.com/cushon for Java rules implications. While I think this is a good idea for Bazel in general, I don't have enough visibility into the technical implications like @ericfelly https://github.com/ericfelly and @cushon https://github.com/cushon for their respective areas, so I'd request for their approvals as well. This PR adds wiring to the SpawnAction and ActionAnalysisMetadata machinery for a specific language ruleset, which are really hot paths and should require careful review. Can we make this feature opt-in and less intrusive? This PR is also really large, which could make it difficult for reviewers to start from scratch, so I'd recommend reviewers to starting from the design doc https://docs.google.com/document/d/1KCQMvUMNVUBDyDmZJ1DB80tf21MVQdyWYS0Y9D_P0as/edit#heading=h.5mcn15i0e1ch. Is there any way you could break this PR down further? Lastly, please ensure that the new and existing tests are passing on Bazel CI, across all platforms, and run google-java-format to format it according to the Google styleguide. I believe the feature can be opt-in, this was also something discussed and implemented for rules_scala, where a flag was introduced into the scala toolchain. Wdyt of that solution? The PR can definitely be broken even more into the introduction of the diagnostics in actions, and then the implementation for java (taking into account the already existing one for java_tools). This would be quite interesting as well since we could parallelise the review of the java_tools and the introductions of the diagnostics. Wdyt? Regarding the CI, as it is, I cannot make the tests pass, since they break due to the changes introduced to the java_tools that the java actions are expecting — You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub <#11766 (comment)>, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADALHEXZTVGFJRGC3Q3XD4LSAD2BRANCNFSM4OZO3AQA .

Thanks for the feedback @ericfelly . I took some time to properly understand the use of Artifacts for this and discussed it with @illicitonion as well, so that I could get his insight.
Regarding null builds, the BSP client is expected to cache the diagnostics on its side, so an incremental build is not necessarily required to do so. Moreover, the server can also help by caching them on its side. There can be some issues with this, but both me and @jastice agree that it makes more sense to follow this approach for now. So that is not something we have to worry about being emitted.
Regarding your idea to reuse the action metadata logs, I can understand your point of view and I do agree with it, however maintaining a small concern. In order to be able to obtain diagnostics through a remote execution, the diagnostics file must be one of the outputs of the action, according to @illicitonion . This means that an action will have to be responsible to add this Artifact to the outputs nonetheless. Wdyt? For rules_scala this is already being done, thus this change wouldn't be that significant. However, from what I know right now, for java this would still mean that I would still have to manually instantiate an Artifact. Perhaps there would be a better way to do it, but it's still out of my reach (I even left a comment on where I instatied it, asking for feedback). Other than that, I don't see any problems with using the action metadata to our advantage.

@ericfelly
Copy link
Contributor

ericfelly commented Aug 12, 2020 via email

@SocksDevil
Copy link
Author

Your 1st statement is true, but the 2nd does not follow from the 1st. The diagnostic file needs to be known to the remote execution layer, but this does not mean it needs to be represented as an Artifact. And there are reasons we don't need or want it to be an Artifact. An Artifact implies that it could be used by downstream actions (it doesn't), and that we would need to properly detect external filesystem modifications to the file. In terms of how this translates to code, I think you'll possibly want to change the various Spawn abstractions, but not Actions. Eric Fellheimer felly@google.com

Ah, I was under the expression that outputs had to be artifacts, but I've come to understand that it's in fact ActionInputs so that is not the case, thank you for clarifying it for me.

However I'm not sure if I follow on how it's possible to implement this modifying only the Spawns. The only way to properly inform the wrappers around the compilers, is through the actions themselves, no? In the case of java, I understand that I could handle this on the side of its spawn specific spawn if I wanted to, however, I'm not following how I would get the information for the other rules, which are created through starlark. Are you suggest I obtain it through the context?

@ericfelly
Copy link
Contributor

ericfelly commented Aug 12, 2020 via email

@SocksDevil
Copy link
Author

I think my previous comment may have been a bit too strong. You'll have to
change some Action code. My point was just that you don't need to change
every Action, like the change to AbstractAction.

On Wed, Aug 12, 2020 at 1:07 PM André Rocha notifications@github.com
wrote:

Your 1st statement is true, but the 2nd does not follow from the 1st. The
diagnostic file needs to be known to the remote execution layer, but this
does not mean it needs to be represented as an Artifact. And there are
reasons we don't need or want it to be an Artifact. An Artifact implies
that it could be used by downstream actions (it doesn't), and that we would
need to properly detect external filesystem modifications to the file. In
terms of how this translates to code, I think you'll possibly want to
change the various Spawn abstractions, but not Actions. Eric Fellheimer
felly@google.com

Ah, I was under the expression that outputs had to be artifacts, but I've
come to understand that it's in fact ActionInputs so that is not the
case, thank you for clarifying it for me.

However I'm not sure if I follow on how it's possible to implement this
modifying only the Spawns. The only way to properly inform the wrappers
around the compilers, is through the actions themselves, no? In the case of
java, I understand that I could handle this on the side of its spawn
specific spawn if I wanted to, however, I'm not following how I would get
the information for the other rules, which are created through starlark.
Are you suggest I obtain it through the context?


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
#11766 (comment),
or unsubscribe
https://github.com/notifications/unsubscribe-auth/ADALHEXNDCG3PIRTMVC5CILSALD4HANCNFSM4OZO3AQA
.

Ah alright. Then I believe I should have an idea on how to implement this, at least for the starlark rules, I'll try and work on an implementation tomorrow. I'm just not sure which API should I use to specify the diagnostic file to the outputs of a Java compile action. Do you have a recommendation as to what extension of ActionInput is more fitting for this matter?

@SocksDevil
Copy link
Author

In addition to the question I made above, I'd like to ask if you could explain when can the result of an action be null. I believe this to have been the reason that the action was was also made to have the diagnostics file, so that if a spawn does not return a result, the diagnostics is still passed down to the event. I'm wondering if this is a relevant case though

@meisterT
Copy link
Member

@michaeledgar can you follow up here?

@janakdr
Copy link
Contributor

janakdr commented Jun 20, 2021

@michaeledgar is point for BEP, but @anakanemison is doing a lot of work with IDEs, might also be interested. I'm not sure if this PR is still active, though?

@janakdr janakdr added the P2 We'll consider working on this in future. (Assignee optional) label Jun 21, 2021
@janakdr
Copy link
Contributor

janakdr commented Jun 21, 2021

Assigning a priority to stop some bot nags.

@jastice
Copy link

jastice commented Jun 22, 2021

Please still consider this PR active. We can update it if somebody actually wants to deal with it :)

@ckolli5 ckolli5 added the awaiting-user-response Awaiting a response from the author label Apr 26, 2022
@sgowroji
Copy link
Member

Hello @andrefmrocha , Above PR has been automatically marked as stale because it has not had recent activity. It will be closed in 7 days, if no further activity occurs. Thank you!

@jastice
Copy link

jastice commented Aug 11, 2022

it looks like parsing the compiler output is sufficient, so we don't need this PR for now, even though it would be good to have.

@sgowroji
Copy link
Member

Closing as stale. Please reopen if you'd like to work on this further.

@sgowroji sgowroji closed this Aug 19, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
awaiting-user-response Awaiting a response from the author cla: yes P2 We'll consider working on this in future. (Assignee optional) team-Core Skyframe, bazel query, BEP, options parsing, bazelrc
Projects
None yet
Development

Successfully merging this pull request may close these issues.

10 participants