Skip to content

Commit

Permalink
Warn large broadcasts.
Browse files Browse the repository at this point in the history
  • Loading branch information
rxin committed Jul 18, 2014
1 parent ade6eac commit 762e0be
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions core/src/main/scala/org/apache/spark/rdd/RDD.scala
Original file line number Diff line number Diff line change
Expand Up @@ -1215,10 +1215,14 @@ abstract class RDD[T: ClassTag](
* where the JobConf/Configuration object is not thread-safe.
*/
@transient private[spark] lazy val broadcasted: Broadcast[Array[Byte]] = {
// TODO: Warn users about very large RDDs.
val ser = SparkEnv.get.closureSerializer.newInstance()
val bytes = ser.serialize(this).array()
logDebug(s"Broadcasting RDD $id using ${bytes.length} bytes")
val size = Utils.bytesToString(bytes.length)
if (bytes.length > (1L << 20)) {
logWarning(s"Broadcasting RDD $id ($size), which contains large objects")
} else {
logDebug(s"Broadcasting RDD $id ($size)")
}
sc.broadcast(bytes)
}

Expand Down

0 comments on commit 762e0be

Please sign in to comment.