-
Notifications
You must be signed in to change notification settings - Fork 280
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
clean up workers #1005
clean up workers #1005
Conversation
99a08a3
to
2cc952c
Compare
I’ll take a look, can you share a bit more info on what you changed in the design and why it’s easier? |
Yep! I'll update the original message. |
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 feel it's simpler to merge GenericWorker
and Processor
, but I will defer to Andy for more explanation.
Just came to my mind. If we are refactoring (if it counts) worker, do we consider to rewrite it in Scala?
src/java/io/bazel/rulesscala/coverage/instrumenter/JacocoInstrumenter.java
Outdated
Show resolved
Hide resolved
…[\]|String[] args|'
You'd need a way to bootstrap a Scala compiler to compile the worker base itself. In higherkindness/rules_scala there was a bootstrap compiler backend that shelled out to scalac directly. We don't have that here-- and I'm not convinced that it's worth it-- so there has to be a worker base in Java. |
It makes sense and thanks for the explanation. |
Thanks Andy for the detailed description! |
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.
Thanks.
I added some comments and questions.
I hope I didn't miss any nuances in the move between the GenericWorker and the Worker because I found some changes and maybe missed others.
In tests we trust ;)
ByteArrayOutputStream outStream = new ByteArrayOutputStream(); | ||
PrintStream out = new PrintStream(outStream); | ||
|
||
System.setIn(new ByteArrayInputStream(new byte[0])); |
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.
Why is this needed?
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.
And also how does it work with you not calling System.in
later on to get this input stream?
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'll add a comment, but basically: there is no stdin. So we attach stdin to an empty buffer and call it a day.
If I ever get around to finishing the standalone worker tests it would make this more obvious.
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.
Comment added.
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.
The idea is that Worker.Interface implementations shouldn't access stdin because that's the transport layer of the persistent worker itself? And so you "null it out" so they won't mess things up?
If so I'd love for the comment to reflect that because I didn't understand what "can't support" means
Hi I am wondering what's the status of this PR? I am interested in moving forward on the discussion of #959. |
I‘ve been somewhat occupied and had a few offline discussions with Andy
where he said this work isn’t really blocking and can wait a bit.
If this is blocking you I’ll push it up (I’ll try this weekend)
On Thu, 5 Mar 2020 at 21:48 Bor Kae Hwang ***@***.***> wrote:
Hi I am wondering what's the status of this PR? I am interested in moving
forward on the discussion of #959
<#959>.
—
You are receiving this because your review was requested.
Reply to this email directly, view it on GitHub
<#1005?email_source=notifications&email_token=AAKQQF6RVGAT2WB24CZRSQDRF76YDA5CNFSM4KYCEV7KYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEN6UXCY#issuecomment-595413899>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAKQQF5JQR6FQR4XQ2V3S4LRF76YDANCNFSM4KYCEV7A>
.
--
*Ittai Zeidman*
40 Hanamal street, Tel Aviv, Israel
<http://www.wix.com>
|
Lucid is still on the way to migrate to bazelbuild/rules_scala, the major blocker now is the scala_test framework since we use specs2. #959 should fix it then we can start the migration process step by step. I would say this PR is not blocking us but #959 is. But I suppose #959 is blocked by this PR. |
Just to make sure- you’re not using specs2 junit runner, right? |
I don't think so. |
ByteArrayOutputStream outStream = new ByteArrayOutputStream(); | ||
PrintStream out = new PrintStream(outStream); | ||
|
||
System.setIn(new ByteArrayInputStream(new byte[0])); |
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.
The idea is that Worker.Interface implementations shouldn't access stdin because that's the transport layer of the persistent worker itself? And so you "null it out" so they won't mess things up?
If so I'd love for the comment to reflect that because I didn't understand what "can't support" means
out.flush(); | ||
outStream.reset(); |
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 feel like I'm jerking your chain a bit but I was actually talking only about the gc line as that is what the old implementation did.
doing flush and reset in a finally block feels a bit adventurous :)
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 actually think this is reasonable! This way we guarantee each new work request doesn't get any leftover output if a previous work request caused a crash.
@andyscott Friendly ping here, do you get a chance to take another look? |
@andyscott Friendly ping here again (sorry for bothering). We would like to see this moving forward, we are also happy to help if you are busy. Thanks. |
I was also thinking of picking this us given the remainders are small.
LMK
On Tue, 14 Apr 2020 at 0:01 Bor Kae Hwang ***@***.***> wrote:
@andyscott <https://github.com/andyscott> Friendly ping here again (sorry
for bothering). We would like to see this moving forward, we are also happy
to help if you are busy. Thanks.
—
You are receiving this because your review was requested.
Reply to this email directly, view it on GitHub
<#1005 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAKQQF6Y65EO476G42NTPF3RMN4TLANCNFSM4KYCEV7A>
.
--
*Ittai Zeidman*
40 Hanamal street, Tel Aviv, Israel
<http://www.wix.com>
|
I've merged master and addressed all recent (😆) feedback. Hopefully I didn't miss anything! |
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.
👍 merging
* clean up workers * whoops! * git grep --name-only 'String args\[\]' | xargs sed -i 's|String args\[\]|String[] args|' * subclass ByteArrayOutputStream to allow shrinking of internal buffer * gc after each work request * split workerMain implementation into two private methods for readability * add comment about stdin * add a test for the buffer * improve tests * wrap gc and friends in the finally clause * comments * make the worker public * cleanup * comments * add stdin test * clean up test
Description
Simplifies and cleans up the workers and the shared worker infrastructure.
First of all, I believe the diff makes the changes look complicated when it's mostly just refactoring and some signature changes.
A hopefully exhaustive list of changes:
Updates to the worker base:
GenericWorker
andProcessor
are collapsed into a singleWorker
base.Worker
baseappendToString
andmerge
methods were only used by the Scalac worker implementation, so they were moved out of the worker base.java.util.List<String>
to a String array to make Scala and Java both feel like first class citizens when writing worker implementations.Updates to worker implementations:
ScalacProcessor
andScalaCInvoker
are collapsed intoScalacWorker
. Scalac worker specific methods were moved out of the shared worker base and into the Scalac worker.ScalafmtWorker
andScalaformatRunner
are collapsed intoScalafmtWorker
. Exception handling is now managed by the worker base.ScroogeWorker
andScroogeGenerator
are collapsed intoScroogeWorker
. Exception handling is now managed by the worker base.ScalaPBWorker
andScalaPGBenerator
are collapsed intoScalaPBWorker
. Exception handling and stdout/stderr setup are now managed by the worker base.JacocoInstrumenter
was mostly unchanged as the worker implementation already aligned well with the simplified worker base.Motivation
This isn't critical or necessary work, but it does provide a few niceties:
I know I said I would hold off on any cleanup. This is perhaps my only exception, as it's code split out from the existing PR #959 and leverages some learnings from when I implemented the Jacoco worker.