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

Add real multiplex support #481

Merged
merged 11 commits into from
Feb 18, 2021
Merged

Add real multiplex support #481

merged 11 commits into from
Feb 18, 2021

Conversation

restingbull
Copy link
Collaborator

@restingbull restingbull commented Feb 16, 2021

Replace worker strategy with a more general one relying on coroutines for multiplexing.

Fixes #453 as well.

Corbin Smith added 9 commits February 15, 2021 17:48
Add new command structure to used multiplxing properly.
Fix tests to work using bootstrap.
Add kt_bootstrap_binary
Make sure PersistentWorker reports captured output
Add exporting a PrintStream to WorkerContext.Logging to integrate with KotlinBuilder
Split mergejdeps and build into separate binaries.
Remove BazelWorker and thank it for it's service.
Run buildifier
Copy link
Contributor

@jongerrish jongerrish left a comment

Choose a reason for hiding this comment

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

Worth including a link to multiplexed workers in the PR description: https://docs.bazel.build/versions/master/multiplex-worker.html

Also, should we have an option to disable/enable them? I think this can be done simply my making "supports_multiplexed_worker" attribute conditional (on some flag in the tool chain?).... I know they had some attempts at fixing https://docs.bazel.build/versions/master/multiplex-worker.html#warning-about-rare-bug not sure if its still a thing or not but caution maybe?

Copy link
Collaborator

@cgruber cgruber left a comment

Choose a reason for hiding this comment

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

Some nits and comments, but I like this structure.

@@ -28,6 +28,7 @@ java_library(
"//src/main/protobuf:deps_java_proto",
"//src/main/protobuf:kotlin_model_java_proto",
"//src/main/protobuf:worker_protocol_java_proto",
"//src/main/kotlin/io/bazel/worker",
Copy link
Collaborator

Choose a reason for hiding this comment

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

Weird indent.

import java.io.InputStream
import java.io.PrintStream

class IO(
Copy link
Collaborator

Choose a reason for hiding this comment

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

This is what I should have called PrintStreams in that other PR. Doh.


@ExperimentalCoroutinesApi
override fun start(execute: Work) = WorkerContext.run {
captureIO().use { io ->
Copy link
Collaborator

Choose a reason for hiding this comment

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

Ok, I really like this flow.

class WorkerContext private constructor(
private val name: String = Companion::class.java.canonicalName,
private val verbose: Granularity = INFO
) : Closeable, ScopeLogging by ContextLogger(name, verbose.level, null) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Are you doing an anonymous delegate? That's... huh. I didn't realize you could do that. I'm used to delegating to a constructor parameter or property object, but not an anonymous instance like this.

}

override fun close() {
Files.walk(dir).sorted(Comparator.reverseOrder()).forEach(Files::delete)
Copy link
Collaborator

Choose a reason for hiding this comment

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

I presume you're just going to accept if it fails here? Best effort?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Pretty much -- it's not really actionable. In many respects, this shouldn't be done during in the invocation.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Ah, nm. Catch and log.

src/test/kotlin/io/bazel/worker/IOTest.kt Outdated Show resolved Hide resolved
src/test/kotlin/io/bazel/worker/PersistentWorkerTest.kt Outdated Show resolved Hide resolved
@restingbull
Copy link
Collaborator Author

https://docs.bazel.build/versions/master/multiplex-worker.html

Multiplex is controlled on the command line, so enabling it means you know what you are doing.

@restingbull restingbull merged commit 09b6f5d into master Feb 18, 2021
@restingbull restingbull deleted the restingbull/multiplex branch February 18, 2021 16:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Do not issue "worker" warning when compiling with a Remote Build Environment
3 participants