-
Notifications
You must be signed in to change notification settings - Fork 29.3k
[SPARK-28574][CORE] Allow to config different sizes for event queues #25307
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 2 commits
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 |
|---|---|---|
|
|
@@ -46,8 +46,13 @@ private class AsyncEventQueue( | |
|
|
||
| // Cap the capacity of the 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 eventQueue = new LinkedBlockingQueue[SparkListenerEvent]( | ||
| conf.get(LISTENER_BUS_EVENT_QUEUE_CAPACITY)) | ||
| // The capacity can be configured by spark.scheduler.listenerbus.eventqueue.${name}.capacity, | ||
| // if no such conf is specified, use the value specified in | ||
| // LISTENER_BUS_EVENT_QUEUE_CAPACITY | ||
| protected def capacity: Int = conf.getInt( | ||
| s"spark.scheduler.listenerbus.eventqueue.${name}.capacity", | ||
|
Contributor
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. We shall assert the capacity is > 0, and add test to cover the case.
Contributor
Author
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. add assertion |
||
| conf.get(LISTENER_BUS_EVENT_QUEUE_CAPACITY)) | ||
| private val eventQueue = new LinkedBlockingQueue[SparkListenerEvent](capacity) | ||
|
|
||
| // Keep the event count separately, so that waitUntilEmpty() can be implemented properly; | ||
| // this allows that method to return only when the events in the queue have been fully | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -236,6 +236,13 @@ private[spark] class LiveListenerBus(conf: SparkConf) { | |
| queues.asScala.map(_.name).toSet | ||
| } | ||
|
|
||
| // For testing only. | ||
| private[scheduler] def getQueueCapacity(name: String): Int = { | ||
|
Member
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. nit: could you change the return type to
Contributor
Author
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. changed |
||
| queues.asScala.find(_.name == name) match { | ||
|
Contributor
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. maybe
Contributor
Author
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. changed |
||
| case Some(queue) => queue.capacity | ||
| case None => -1 | ||
| } | ||
| } | ||
| } | ||
|
|
||
| private[spark] object LiveListenerBus { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -532,6 +532,28 @@ class SparkListenerSuite extends SparkFunSuite with LocalSparkContext with Match | |
| } | ||
| } | ||
|
|
||
| test("event queue size can be configued through spark conf") { | ||
| val conf = new SparkConf(false) | ||
| .set(LISTENER_BUS_EVENT_QUEUE_CAPACITY, 5) | ||
| .set("spark.scheduler.listenerbus.eventqueue.shared.capacity", "1") | ||
|
Contributor
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. nit: I would use s
Contributor
Author
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. fixed |
||
| .set("spark.scheduler.listenerbus.eventqueue.eventLog.capacity", "2") | ||
|
Contributor
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. similarly, I would use s
Contributor
Author
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. fixed |
||
|
|
||
| val bus = new LiveListenerBus(conf) | ||
|
Member
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. nit:
Contributor
Author
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 bus is actually never started, so no need to stop. |
||
| val counter1 = new BasicJobCounter() | ||
| val counter2 = new BasicJobCounter() | ||
| val counter3 = new BasicJobCounter() | ||
|
|
||
| bus.addToSharedQueue(counter1) | ||
|
Contributor
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. Maybe add comment to explain this is just to trigger add a new Queue.
Contributor
Author
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. added comments |
||
| bus.addToStatusQueue(counter2) | ||
| bus.addToEventLogQueue(counter3) | ||
|
|
||
| assert(bus.activeQueues() === Set(SHARED_QUEUE, APP_STATUS_QUEUE, EVENT_LOG_QUEUE)) | ||
| // check the size of each queue | ||
| assert(bus.getQueueCapacity(SHARED_QUEUE) == 1) | ||
| assert(bus.getQueueCapacity(APP_STATUS_QUEUE) == 5) | ||
| assert(bus.getQueueCapacity(EVENT_LOG_QUEUE) == 2) | ||
| } | ||
|
|
||
| /** | ||
| * Assert that the given list of numbers has an average that is greater than zero. | ||
| */ | ||
|
|
||
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.
We need to update the conf description of LISTENER_BUS_EVENT_QUEUE_CAPACITY.