-
Notifications
You must be signed in to change notification settings - Fork 28.9k
[SPARK-3694] RDD and Task serialization debugging output #3518
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
25 commits
Select commit
Hold shift + click to select a range
6c99762
Created class to traverse dependency graph of RDD
47ccc22
Started walker code
a8d5332
RDD WAlker updates
a63652f
Added debug output to task serialization. Added debug output to RDD s…
05f2cc0
Rebase
cbb1d77
Style errors
1831000
Merge remote-tracking branch 'upstream/master'
916a31c
Manual merge of updates
bfb723d
Added helper files
e0a8153
Fixed whitespace errors
cb6ebb1
Updated documentation to add debug parameter for rdd serialization
95fa69b
Incorporated feedback from PR. Cleaned up code and refactored interfa…
d2abbb5
Fixed incorrect boolean in test script
ef3dd39
Minor comment fixes
aff02e9
Added ObjectWalker class to traverse the references of a generic obje…
47b027a
Started on updating SerializationHelper to add generic ObjectWalker
8ac35dc
Merge remote-tracking branch 'upstream/master' into SPARK-3694B
25d5780
Code needs work, need to properly store references
7a19547
Updated SerializationHelper to be agnostic to the data type being tra…
bb5f700
Updated DAGScheduler and TaskSetManager classes to add debug printout…
07142ce
Moved code out of DAGScheduler into SerializationHelper class to mini…
8e5f710
Got rid of unecessary EdgeRef class
a32f0ac
Fixed merge issues from SPARK-4737
1d2d563
Updated to use scala queues insteadof google queues
5b93dc1
Fixed style issue
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
111 changes: 111 additions & 0 deletions
111
core/src/main/scala/org/apache/spark/util/ObjectWalker.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,111 @@ | ||
| /* | ||
| * 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.util | ||
|
|
||
| import java.lang.reflect.{Modifier, Field} | ||
|
|
||
| import scala.collection.mutable | ||
|
|
||
|
|
||
| /** | ||
| * This class permits traversing a generic Object's reference graph. This is useful for debugging | ||
| * serialization errors. See SPARK-3694. | ||
| * | ||
| * This code is based on code written by Josh Rosen found here: | ||
| * https://gist.github.com/JoshRosen/d6a8972c99992e97d040 | ||
| */ | ||
| private[spark] object ObjectWalker { | ||
| def isTransient(field: Field): Boolean = Modifier.isTransient(field.getModifiers) | ||
| def isStatic(field: Field): Boolean = Modifier.isStatic(field.getModifiers) | ||
| def isPrimitive(field: Field): Boolean = field.getType.isPrimitive | ||
|
|
||
| /** | ||
| * Traverse the graph representing all references between the provided root object, its | ||
| * members, and their references in turn. | ||
| * | ||
| * What we want to be able to do is readily identify un-serializable components AND the path | ||
| * to those components. To do this, store the traversal of the graph as a 2-tuple - the actual | ||
| * reference visited and its parent. Then, to get the path to the un-serializable reference | ||
| * we can simply follow the parent links. | ||
| * | ||
| * @param rootObj - The root object for which to generate the reference graph | ||
| * @return a new Set containing the 2-tuple of references from the traversal of the | ||
| * reference graph along with their parent references. (self, parent) | ||
| */ | ||
| def buildRefGraph(rootObj: AnyRef): mutable.LinkedList[AnyRef] = { | ||
| val visitedRefs = mutable.Set[AnyRef]() | ||
| val toVisit = new mutable.Queue[AnyRef]() | ||
| var results = mutable.LinkedList[AnyRef]() | ||
|
|
||
| toVisit += rootObj | ||
|
|
||
| while (toVisit.nonEmpty) { | ||
| val obj : AnyRef = toVisit.dequeue() | ||
| // Store the last parent reference to enable quick retrieval of the path to a broken node | ||
|
|
||
| if (!visitedRefs.contains(obj)) { | ||
| results = mutable.LinkedList(obj).append(results) | ||
| visitedRefs.add(obj) | ||
|
|
||
| // Extract all the fields from the object that would be serialized. Transient and | ||
| // static references are not serialized and primitive variables will always be serializable | ||
| // and will not contain further references. | ||
| for (field <- getFieldsToTest(obj)) { | ||
| // Extract the field object and pass to the visitor | ||
| val originalAccessibility = field.isAccessible | ||
| field.setAccessible(true) | ||
| val fieldObj = field.get(obj) | ||
| field.setAccessible(originalAccessibility) | ||
|
|
||
| if (fieldObj != null) { | ||
| toVisit += fieldObj | ||
| } | ||
| } | ||
| } | ||
| } | ||
| results | ||
| } | ||
|
|
||
| /** | ||
| * Get the serialiazble fields from an object reference | ||
| * @param obj - Reference to the object fo rwhich to generate a serialization trace | ||
| * @return a new Set containing the serializable fields of the object | ||
| */ | ||
| def getFieldsToTest(obj: AnyRef): mutable.Set[Field] = { | ||
| getAllFields(obj.getClass) | ||
| .filterNot(isStatic) | ||
| .filterNot(isTransient) | ||
| .filterNot(isPrimitive) | ||
| } | ||
|
|
||
| /** | ||
| * Get all fields (including private ones) from this class and its superclasses. | ||
| * @param cls - The class from which to retrieve fields | ||
| * @return a new mutable.Set representing the fields of the reference | ||
| */ | ||
| private def getAllFields(cls: Class[_]): mutable.Set[Field] = { | ||
| val fields = mutable.Set[Field]() | ||
| var _cls: Class[_] = cls | ||
| while (_cls != null) { | ||
| fields ++= _cls.getDeclaredFields | ||
| fields ++= _cls.getFields | ||
| _cls = _cls.getSuperclass | ||
| } | ||
|
|
||
| fields | ||
| } | ||
| } |
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,61 @@ | ||
| /* | ||
| * 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.util | ||
|
|
||
| import scala.collection.mutable | ||
| import scala.collection.mutable.ArrayBuffer | ||
| import scala.language.existentials | ||
|
|
||
| import org.apache.spark.rdd.RDD | ||
|
|
||
| /** | ||
| * This class permits traversing the RDD's dependency graph. This is | ||
| * accomplished by walking the object graph linking these RDDs. This is useful for debugging | ||
| * internal RDD references. See SPARK-3694. | ||
| */ | ||
| private[spark] object RDDWalker { | ||
| /** | ||
| * Traverse the dependencies of the RDD and store them within an Array along with their depths. | ||
| * Return this data structure and subsequently process it. | ||
| * | ||
| * @param rddToWalk - The RDD to traverse along with its dependencies | ||
| * @return Array[(RDD[_], depth : Int] - An array of results generated by the traversal function | ||
| */ | ||
| def walk(rddToWalk : RDD[_]): Array[(RDD[_], Int)] = { | ||
|
|
||
| val walkQueue = new mutable.Queue[(RDD[_], Int)]() | ||
| val visited = mutable.Set[RDD[_]]() | ||
|
|
||
| // Keep track of both the RDD and its depth in the traversal graph. | ||
| val results = new ArrayBuffer[(RDD[_], Int)]() | ||
| // Implement as a queue to perform a BFS | ||
| walkQueue += ((rddToWalk,0)) | ||
|
|
||
| while (!walkQueue.isEmpty) { | ||
| // Pop from the queue | ||
| val (rddToProcess : RDD[_], depth:Int) = walkQueue.dequeue() | ||
| if (!visited.contains(rddToProcess)) { | ||
| visited.add(rddToProcess) | ||
| rddToProcess.dependencies.foreach(s => walkQueue += ((s.rdd, depth + 1))) | ||
| results.append((rddToProcess, depth)) | ||
| } | ||
| } | ||
|
|
||
| results.toArray | ||
| } | ||
| } |
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.
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 should make sure this catches any exceptions thrown by the serialization utility itself and in that case just say that we couldn't produce debugging output.