-
Notifications
You must be signed in to change notification settings - Fork 28.6k
[SPARK-15703] [Scheduler][Core][WebUI] Make ListenerBus event queue size configurable #14269
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
Changes from all commits
9c0cb44
76d9af8
09e855e
41dc57c
889fe66
82feec4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,7 +22,8 @@ import java.util.concurrent.atomic.AtomicBoolean | |
|
||
import scala.util.DynamicVariable | ||
|
||
import org.apache.spark.SparkContext | ||
import org.apache.spark.{SparkContext, SparkException} | ||
import org.apache.spark.internal.config._ | ||
import org.apache.spark.util.Utils | ||
|
||
/** | ||
|
@@ -32,18 +33,24 @@ import org.apache.spark.util.Utils | |
* has started will events be actually propagated to all attached listeners. This listener bus | ||
* is stopped when `stop()` is called, and it will drop further events after stopping. | ||
*/ | ||
private[spark] class LiveListenerBus extends SparkListenerBus { | ||
private[spark] class LiveListenerBus(val sparkContext: SparkContext) extends SparkListenerBus { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm modifying LiveListenerBus now and noticed that we're passing in There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I guess we also use this to tear down There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. From what I recall and as you mentioned, a ref to |
||
|
||
self => | ||
|
||
import LiveListenerBus._ | ||
|
||
private var sparkContext: SparkContext = null | ||
|
||
// Cap the capacity of the event queue so we get an explicit error (rather than | ||
// an OOM exception) if it's perpetually being added to more quickly than it's being drained. | ||
private val EVENT_QUEUE_CAPACITY = 10000 | ||
private val eventQueue = new LinkedBlockingQueue[SparkListenerEvent](EVENT_QUEUE_CAPACITY) | ||
private lazy val EVENT_QUEUE_CAPACITY = validateAndGetQueueSize() | ||
private lazy val eventQueue = new LinkedBlockingQueue[SparkListenerEvent](EVENT_QUEUE_CAPACITY) | ||
|
||
private def validateAndGetQueueSize(): Int = { | ||
val queueSize = sparkContext.conf.get(LISTENER_BUS_EVENT_QUEUE_SIZE) | ||
if (queueSize <= 0) { | ||
throw new SparkException("spark.scheduler.listenerbus.eventqueue.size must be > 0!") | ||
} | ||
queueSize | ||
} | ||
|
||
// Indicate if `start()` is called | ||
private val started = new AtomicBoolean(false) | ||
|
@@ -96,11 +103,9 @@ private[spark] class LiveListenerBus extends SparkListenerBus { | |
* listens for any additional events asynchronously while the listener bus is still running. | ||
* This should only be called once. | ||
* | ||
* @param sc Used to stop the SparkContext in case the listener thread dies. | ||
*/ | ||
def start(sc: SparkContext): Unit = { | ||
def start(): Unit = { | ||
if (started.compareAndSet(false, true)) { | ||
sparkContext = sc | ||
listenerThread.start() | ||
} else { | ||
throw new IllegalStateException(s"$name already started!") | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -47,6 +47,7 @@ class ReceivedBlockHandlerSuite | |
extends SparkFunSuite | ||
with BeforeAndAfter | ||
with Matchers | ||
with LocalSparkContext | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The fact that this change was necessary is another weird code smell which suggests to me that putting SparkContext into the constructor was not a good idea. |
||
with Logging { | ||
|
||
import WriteAheadLogBasedBlockHandler._ | ||
|
@@ -77,8 +78,10 @@ class ReceivedBlockHandlerSuite | |
rpcEnv = RpcEnv.create("test", "localhost", 0, conf, securityMgr) | ||
conf.set("spark.driver.port", rpcEnv.address.port.toString) | ||
|
||
sc = new SparkContext("local", "test", conf) | ||
blockManagerMaster = new BlockManagerMaster(rpcEnv.setupEndpoint("blockmanager", | ||
new BlockManagerMasterEndpoint(rpcEnv, true, conf, new LiveListenerBus)), conf, true) | ||
new BlockManagerMasterEndpoint(rpcEnv, true, conf, | ||
new LiveListenerBus(sc))), conf, true) | ||
|
||
storageLevel = StorageLevel.MEMORY_ONLY_SER | ||
blockManager = createBlockManager(blockManagerSize, conf) | ||
|
Uh oh!
There was an error while loading. Please reload this page.
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.
Another post-hoc review/complaint: I think that
size
might be misleading in this context where we're talking about a queue, since the size of a queue refers to the number of elements currently in the queue while its capacity refers to the maximum size that the queue can reach. This configuration name caused confusion in https://github.com/apache/spark/pull/18083/files/378206efb9f5c9628a678ba7defb536252f5cbcb#r118413115Instead, it might have been better to call it
capacity
.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 agree. Capacity would have been a better choice.