-
Notifications
You must be signed in to change notification settings - Fork 29.2k
[SPARK-56412] Implement DirectWorkerDispatcher that spawns UDF workers as local callable. #55406
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
Closed
Closed
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
2c20d57
add direct worker
haiyangsun-db 30ffef7
drop direct log4j dep.
haiyangsun-db 0f103c8
improvements
haiyangsun-db be7f65f
cleanup hook - currently per session, but open to idle pooling in fut…
haiyangsun-db 8733a59
address PR review feedback
haiyangsun-db 8384d0c
address comments. 1. use one connection for now. 2. apply a max cap f…
haiyangsun-db 4d2ad82
trimmed documentation as some code self-explains
haiyangsun-db 9f5e3ee
address more comments.
haiyangsun-db c393de7
improved connection abstraction - move connection protocol out from b…
haiyangsun-db File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
49 changes: 49 additions & 0 deletions
49
udf/worker/core/src/main/scala/org/apache/spark/udf/worker/core/WorkerConnection.scala
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,49 @@ | ||
| /* | ||
| * Licensed to the Apache Software Foundation (ASF) under one or more | ||
| * contributor license agreements. See the NOTICE file distributed with | ||
| * this work for additional information regarding copyright ownership. | ||
| * The ASF licenses this file to You under the Apache License, Version 2.0 | ||
| * (the "License"); you may not use this file except in compliance with | ||
| * the License. You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
| package org.apache.spark.udf.worker.core | ||
|
|
||
| import org.apache.spark.annotation.Experimental | ||
|
|
||
| /** | ||
| * :: Experimental :: | ||
| * A transport-level connection to a running UDF worker process. | ||
| * | ||
| * A [[WorkerConnection]] represents the communication channel between the | ||
| * Spark engine and a single worker process (e.g., a gRPC channel over a | ||
| * Unix domain socket, or a raw TCP socket). It is owned by a worker | ||
| * process wrapper (e.g., [[direct.DirectWorkerProcess]]) and shared | ||
| * across all [[WorkerSession]]s that use that process. | ||
| * | ||
| * One connection, many sessions: the worker exposes a single server-side | ||
| * endpoint that all sessions share. For gRPC, per-session work lives on | ||
| * multiplexed streams over this channel. | ||
| * | ||
| * Implementations expose only lifecycle. Data transmission happens at | ||
| * the [[WorkerSession]] level -- this class is solely about whether the | ||
| * channel is open. | ||
| * | ||
| * '''Relationship to other classes (direct creation mode):''' | ||
| * {{{ | ||
| * DirectWorkerProcess 1 --- 1 WorkerConnection (transport over UDS) | ||
| * DirectWorkerProcess 1 --- * WorkerSession (UDF executions) | ||
| * }}} | ||
| */ | ||
| @Experimental | ||
| abstract class WorkerConnection extends AutoCloseable { | ||
| /** Returns true if the underlying transport channel is still usable. */ | ||
| def isActive: Boolean | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 51 additions & 0 deletions
51
udf/worker/core/src/main/scala/org/apache/spark/udf/worker/core/WorkerLogger.scala
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,51 @@ | ||
| /* | ||
| * Licensed to the Apache Software Foundation (ASF) under one or more | ||
| * contributor license agreements. See the NOTICE file distributed with | ||
| * this work for additional information regarding copyright ownership. | ||
| * The ASF licenses this file to You under the Apache License, Version 2.0 | ||
| * (the "License"); you may not use this file except in compliance with | ||
| * the License. You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
| package org.apache.spark.udf.worker.core | ||
|
|
||
| import org.apache.spark.annotation.Experimental | ||
|
|
||
| /** | ||
| * :: Experimental :: | ||
| * Minimal logging surface used by the udf/worker framework. | ||
| * | ||
| * The framework deliberately does not depend on SLF4J (or any other | ||
| * concrete logging backend) so callers can embed it without dragging a | ||
| * specific logger onto the classpath. Embedders should supply an | ||
| * adapter that forwards to their preferred backend (Spark's `Logging` | ||
| * trait, SLF4J, java.util.logging, etc.). | ||
| * | ||
| * Only the methods actually used by the framework are exposed. | ||
| * Messages are passed by-name so the formatting cost is avoided when | ||
| * the backend decides to drop the event. | ||
| */ | ||
| @Experimental | ||
| trait WorkerLogger { | ||
| def warn(msg: => String): Unit | ||
| def warn(msg: => String, t: Throwable): Unit | ||
| def debug(msg: => String): Unit | ||
| def debug(msg: => String, t: Throwable): Unit | ||
| } | ||
|
|
||
| object WorkerLogger { | ||
| /** Discards all messages. Default for callers that don't wire up logging. */ | ||
| val NoOp: WorkerLogger = new WorkerLogger { | ||
| override def warn(msg: => String): Unit = () | ||
| override def warn(msg: => String, t: Throwable): Unit = () | ||
| override def debug(msg: => String): Unit = () | ||
| override def debug(msg: => String, t: Throwable): Unit = () | ||
| } | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.