Skip to content

Commit 5f072a7

Browse files
committed
add comments to explain Stack usage.
1 parent 8742dbb commit 5f072a7

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

core/src/main/scala/org/apache/spark/scheduler/DAGScheduler.scala

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -275,6 +275,7 @@ class DAGScheduler(
275275
private def getParentStages(rdd: RDD[_], jobId: Int): List[Stage] = {
276276
val parents = new HashSet[Stage]
277277
val visited = new HashSet[RDD[_]]
278+
// We are manually maintaining a stack here to prevent StackOverflowError caused by recursively visiting
278279
val waitingForVisit = new Stack[RDD[_]]
279280
def visit(r: RDD[_]) {
280281
if (!visited(r)) {
@@ -301,6 +302,7 @@ class DAGScheduler(
301302
private def getParentShuffleDependencies(rdd: RDD[_]): Stack[ShuffleDependency[_, _, _]] = {
302303
val parents = new Stack[ShuffleDependency[_, _, _]]
303304
val visited = new HashSet[RDD[_]]
305+
// We are manually maintaining a stack here to prevent StackOverflowError caused by recursively visiting
304306
val waitingForVisit = new Stack[RDD[_]]
305307
def visit(r: RDD[_]) {
306308
if (!visited(r)) {
@@ -330,6 +332,7 @@ class DAGScheduler(
330332
private def getMissingParentStages(stage: Stage): List[Stage] = {
331333
val missing = new HashSet[Stage]
332334
val visited = new HashSet[RDD[_]]
335+
// We are manually maintaining a stack here to prevent StackOverflowError caused by recursively visiting
333336
val waitingForVisit = new Stack[RDD[_]]
334337
def visit(rdd: RDD[_]) {
335338
if (!visited(rdd)) {
@@ -1146,6 +1149,7 @@ class DAGScheduler(
11461149
}
11471150
val visitedRdds = new HashSet[RDD[_]]
11481151
val visitedStages = new HashSet[Stage]
1152+
// We are manually maintaining a stack here to prevent StackOverflowError caused by recursively visiting
11491153
val waitingForVisit = new Stack[RDD[_]]
11501154
def visit(rdd: RDD[_]) {
11511155
if (!visitedRdds(rdd)) {

0 commit comments

Comments
 (0)