Skip to content

Commit

Permalink
Remove --experimental_worker_allow_json_protocol
Browse files Browse the repository at this point in the history
  • Loading branch information
keith committed Jun 24, 2021
1 parent f75eb1b commit 0aa7483
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 36 deletions.
4 changes: 1 addition & 3 deletions site/docs/creating-workers.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,7 @@ would benefit from cross-action caching, you may want to implement your own
persistent worker to perform these actions.

The Bazel server communicates with the worker using `stdin`/`stdout`. It
supports the use of protocol buffers or JSON strings. Support for JSON is
experimental and thus subject to change. It is guarded behind the
`--experimental_worker_allow_json_protocol` flag.
supports the use of protocol buffers or JSON strings.

The worker implementation has two parts:

Expand Down
18 changes: 6 additions & 12 deletions site/docs/persistent-workers.md
Original file line number Diff line number Diff line change
Expand Up @@ -137,11 +137,6 @@ flag makes each worker request use a separate sandbox directory for all its
inputs. Setting up the [sandbox](sandboxing.md) takes some extra time,
especially on macOS, but gives a better correctness guarantee.

You can use the `--experimental_worker_allow_json_protocol` flag to allow
workers to communicate with Bazel through JSON instead of protocol buffers
(protobuf). The worker and the rule that consumes it can then be modified to
support JSON.

The
[`--worker_quit_after_build`](command-line-reference.html#flag--worker_quit_after_build)
flag is mainly useful for debugging and profiling. This flag forces all workers
Expand Down Expand Up @@ -195,13 +190,12 @@ inputs: [
```

The worker receives this on `stdin` in JSON format (because
`requires-worker-protocol` is set to JSON, and
`--experimental_worker_allow_json_protocol` is passed to the build to enable
this option). The worker then performs the action, and sends a JSON-formatted
`WorkResponse` to Bazel on its stdout. Bazel then parses this response and
manually converts it to a `WorkResponse` proto. To communicate
with the associated worker using binary-encoded protobuf instead of JSON,
`requires-worker-protocol` would be set to `proto`, like this:
`requires-worker-protocol` is set to JSON). The worker then performs the
action, and sends a JSON-formatted `WorkResponse` to Bazel on its
stdout. Bazel then parses this response and manually converts it to a
`WorkResponse` proto. To communicate with the associated worker using
binary-encoded protobuf instead of JSON, `requires-worker-protocol`
would be set to `proto`, like this:

```
execution_requirements = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,16 +46,6 @@ public class WorkerOptions extends OptionsBase {
})
public Void experimentalPersistentJavac;

@Option(
name = "experimental_worker_allow_json_protocol",
defaultValue = "false",
documentationCategory = OptionDocumentationCategory.UNDOCUMENTED,
effectTags = {OptionEffectTag.BUILD_FILE_SEMANTICS},
help =
"Allows workers to use the JSON worker protocol until it is determined to be"
+ " stable.")
public boolean experimentalJsonWorkerProtocol;

/**
* Defines a resource converter for named values in the form [name=]value, where the value is
* {@link ResourceConverter.FLAG_SYNTAX}. If no name is provided (used when setting a default),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -187,15 +187,6 @@ public SpawnResult exec(Spawn spawn, SpawnExecutionContext context)
execRoot);
SandboxOutputs outputs = helpers.getOutputs(spawn);

WorkerProtocolFormat protocolFormat = Spawns.getWorkerProtocolFormat(spawn);
if (!workerOptions.experimentalJsonWorkerProtocol) {
if (protocolFormat == WorkerProtocolFormat.JSON) {
throw new IOException(
"Persistent worker protocol format must be set to proto unless"
+ " --experimental_worker_allow_json_protocol is used");
}
}

WorkerKey key =
new WorkerKey(
workerArgs,
Expand All @@ -207,7 +198,7 @@ public SpawnResult exec(Spawn spawn, SpawnExecutionContext context)
context.speculating(),
multiplex && Spawns.supportsMultiplexWorkers(spawn),
Spawns.supportsWorkerCancellation(spawn),
protocolFormat);
Spawns.getWorkerProtocolFormat(spawn));

SpawnMetrics.Builder spawnMetrics =
SpawnMetrics.Builder.forWorkerExec()
Expand Down
1 change: 0 additions & 1 deletion src/test/shell/integration/bazel_worker_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ example_worker=$(find $BAZEL_RUNFILES -name ExampleWorker_deploy.jar)

add_to_bazelrc "build -s"
add_to_bazelrc "build --spawn_strategy=worker,standalone"
add_to_bazelrc "build --experimental_worker_allow_json_protocol"
add_to_bazelrc "build --worker_verbose --worker_max_instances=1"
add_to_bazelrc "build --debug_print_action_contexts"
add_to_bazelrc "build --noexperimental_worker_multiplex"
Expand Down

0 comments on commit 0aa7483

Please sign in to comment.