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

json persistent workers GA / --experimental_worker_allow_json_protocol removal #13599

Closed
keith opened this issue Jun 23, 2021 · 24 comments
Closed
Assignees
Labels
P2 We'll consider working on this in future. (Assignee optional) team-Performance Issues for Performance teams type: support / not a bug (process)

Comments

@keith
Copy link
Member

keith commented Jun 23, 2021

JSON support for persistent workers launched a few months ago https://blog.bazel.build/2020/11/11/json-workers.html I'm curious what the criteria are for --experimental_worker_allow_json_protocol to no longer be required so we can use this in rules without having to force that flag on users?

@keith keith changed the title json workers GA? json persistent workers GA / --experimental_worker_allow_json_protocol removal Jun 23, 2021
@aiuto aiuto added team-Performance Issues for Performance teams untriaged labels Jun 24, 2021
@aiuto
Copy link
Contributor

aiuto commented Jun 24, 2021

/cc: @susinmotion

@susinmotion
Copy link
Contributor

cc: @larsrc-google
There are some changes to the worker protocol in progress, and we wanted to wait for those to be in place before flipping, then removing, the flag. Since we're not currently enforcing that JSON workers be tolerant of unknown fields in the work request, we were afraid we'd break JSON workers by changing the protocol.

Other things we considered were adding an arbitrary field to the work request to enforce resilience to unknown fields, then flipping the flag. We can still do this if there's good reason.

@meisterT
Copy link
Member

I assume the JSON protocol is basically just push a dict over the wire. Unknown keys in the dict should not hurt any worker implementation, unless they specifically check for it.

@meisterT meisterT added type: support / not a bug (process) P2 We'll consider working on this in future. (Assignee optional) and removed untriaged labels Jun 24, 2021
@susinmotion
Copy link
Contributor

Our own test workers weren't resilient to extra fields! :P

I'm comfortable flipping the flag but I defer to Lars's sense of risk.

@larsrc-google
Copy link
Contributor

Our own workers aren't actually quite resilient yet, AFAICT.

@keith
Copy link
Member Author

keith commented Jun 24, 2021

Is the thought that at the time of flipping this flag we would never again add fields though? based on the docs I believe that workers should be resilient to this and therefore that doesn't particularly have to affect this flip

@larsrc-google
Copy link
Contributor

Oh, there will be more fields. Sandboxing for multiplex workers will require another field. And who knows what the future will bring? I definitely don't want to tie us to a frozen protocol.

@aiuto
Copy link
Contributor

aiuto commented Jun 24, 2021 via email

@larsrc-google
Copy link
Contributor

Yes, we should be specific about that in the worker docs. We aren't quite.

@keith
Copy link
Member Author

keith commented Jun 24, 2021

#13606

@keith
Copy link
Member Author

keith commented Jun 24, 2021

I submitted #13607 in case we decide we're ready for this

@wolfd
Copy link
Contributor

wolfd commented Jun 24, 2021

One thing I would love to change about the current JSON workers (before they're considered stable) is the lack of a newline between work requests. I found it fairly cumbersome to write a python worker without this. Since the JSON is not pretty-printed the only newlines in the stream should just be between work requests, which would allow looping and using .readline() on the file to get a complete request.

Right now this was the way I got a JSON worker working in Python:
https://github.com/wolfd/json_worker_example/blob/8238b21e623eea2b73174e927ab6601d5504cf57/concat.py#L8-L31

I decided not to change from Proto to JSON for a worker I have due to this problem. The Proto workers have the varint length of the request at the beginning of every request which makes it easier to delimit them.

@keith
Copy link
Member Author

keith commented Jun 24, 2021

@larsrc-google
Copy link
Contributor

Hand-writing a JSON parser in C++ for this seems like a recipe for subtle errors. And I could imagine some line reading implementations that have limits on the line length shorter than we may end up needing.

@keith
Copy link
Member Author

keith commented Jun 24, 2021

This isn't hand writing the parser, just the logic for reading the input from stdin

@aiuto
Copy link
Contributor

aiuto commented Jun 25, 2021 via email

@meisterT
Copy link
Member

I thought we would use NDJSON to write those messages out. If not, my opinion is that we should in the future do so and describe it in the docs.

@aiuto
Copy link
Contributor

aiuto commented Jun 25, 2021 via email

@larsrc-google
Copy link
Contributor

Newline Delimited JSON. A very small standard:)

@meisterT
Copy link
Member

See http://ndjson.org/

keith added a commit to keith/bazel that referenced this issue Jul 26, 2021
@ittaiz
Copy link
Member

ittaiz commented Oct 11, 2021

Hi,
I have a related question- I'm considering using json for a new persistent worker I need to write and was a bit concerned by the need to turn on experimental workers. There was a time in bazel (still?) that the statement was "your prod builds shouldn't have experimental flags turned on".
After reading this thread it sounds like the experimental is not about "if" json will stay or not but rather the "how" of the worker might still change and as a breaking change to me (a worker implementor).
Is that right? Thanks in advance!

@larsrc-google
Copy link
Contributor

Yes, that is correct.

@keith
Copy link
Member Author

keith commented Nov 2, 2021

#14219 should solve one of the major concerns about the format here

@keith
Copy link
Member Author

keith commented Jan 31, 2022

I submitted #14679 for the flag cleanup now that it has been flipped elsewhere.

keith added a commit to keith/bazel that referenced this issue Apr 5, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
P2 We'll consider working on this in future. (Assignee optional) team-Performance Issues for Performance teams type: support / not a bug (process)
Projects
None yet
7 participants