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
Improve performance of Java package parser by making it a Bazel worker #3686
Improve performance of Java package parser by making it a Bazel worker #3686
Conversation
@@ -704,6 +712,10 @@ def build_java_package_manifest(ctx, target, source_files, suffix): | |||
arguments = [args], | |||
mnemonic = "JavaPackageManifest", | |||
progress_message = "Parsing java package strings for " + str(target.label), | |||
execution_requirements = { |
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.
I think it would be great to also support multiplexed workers here.
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.
@keithl-stripe is this something that makes sense from your perspective?
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.
Sure, but for now that's a "nice to have" - I believe it would simply improve overall performance, but should not be a blocker for this PR.
@mai93 can you take a look at this? |
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.
LGTM. Any problems you see @mai93 ?
Comments from @keithl-stripe in chat:
AFAIK generally workers have some risks:
- could add to memory footprint of a build, e.g accidental state or uncollected garbage, or simply the fact that bazel keeps workers running between builds
- bugs could be hard to track down when they are the result of built up state
1️⃣ doesn’t seem likely, as this worker doesn't do much, but it might be worth experimenting with Xmx values
2️⃣ this worker doesn't carry any meaningful state beyond just the JVM’s own state
@@ -704,6 +712,10 @@ def build_java_package_manifest(ctx, target, source_files, suffix): | |||
arguments = [args], | |||
mnemonic = "JavaPackageManifest", | |||
progress_message = "Parsing java package strings for " + str(target.label), | |||
execution_requirements = { |
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.
@keithl-stripe is this something that makes sense from your perspective?
parsePackagesAndWriteManifest(parser, workRequestOptions); | ||
|
||
builder.build().writeDelimitedTo(System.out); | ||
} catch (Exception e) { |
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.
I'm wondering whether we should catch all exceptions this way here. In case an exception is thrown, the loop will still run. Maybe we should allow continuation of the loop only when "parsePackagesAndWriteManifest" throws a parsing-specific exception, and for other errors break the loop. The BazelJavaBuilder is doing so
But I'm not sure, otherwise LGTM 👍
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.
I wanted to reduce the risk that we crash hard for an issue that only affects the current action. I honestly don't know what is best here. If you'd like me to be more conservative that's fine - will update the PR.
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.
Personally I would prefer to follow the same way as BazelJavaBuilder
. For recoverable exceptions we can continue, but for unexpected ones System.exit would be more transparent. We could also print a message telling the user it is possible to run it without persistent workers.
@keithl-stripe There are a few other actions in this repo like |
@estebandlc I would like to get your feedback on this PR. |
Hello @keithl-stripe, Could you please resolve the above code conflicts and help us in submitting it. Thanks! |
Sorry, we are moving away from using this plugin here at Stripe, so we are investing our effort in our homegrown IntelliJ plugin. Someone else will have to pick up this PR and get it landed if people think it would be useful. (It sped up our sync builds substantially!) |
Okay, then let's keep this open as a work item for maintainers or other contributors. Thank you for the effort so far! |
If there are no other objections let's merge it now |
I'm ok with that, can you fix the conflict then merge it? It is already approved. |
97762b3
to
f9c7cbf
Compare
Checklist
Please note that the maintainers will not be reviewing this change until all checkboxes are ticked. See
the Contributions section in the README for more
details.
Discussion thread for this change
Issue number: #3685
Description of this change
Makes the package parser tool (a Java CLI application) able to be run as a Bazel worker. Also modify the Starlark to enable worker mode.