-
Notifications
You must be signed in to change notification settings - Fork 29k
[SPARK-1103] [WIP] Automatic garbage collection of RDD, shuffle and broadcast data #126
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 5 commits
1e752f1
80dd977
e427a9e
8512612
a24fefc
cb0a5a6
ae9da88
e61daa0
a7260d3
892b952
e1fba5f
f2881fd
620eca3
a007307
d2f8b97
6c9dcf6
c7ccef1
ba52e00
d0edef3
544ac86
e95479c
f201a8d
c92e4d9
0d17060
34f436f
fbfeec8
88904a3
e442246
8557c12
7edbc98
634a097
7ed72fb
5016375
f0aabb1
762a4d8
a6460d4
c5b1d98
a2cc8bc
ada45f0
cd72d19
b27f8e8
a430f06
104a89a
6222697
41c9ece
2b95b5e
4d05314
cff023c
d25a86e
f489fdc
61b8d6e
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 |
|---|---|---|
|
|
@@ -71,13 +71,18 @@ private[spark] class MapOutputTrackerMasterActor(tracker: MapOutputTrackerMaster | |
| * (driver and worker) use different HashMap to store its metadata. | ||
| */ | ||
| private[spark] abstract class MapOutputTracker(conf: SparkConf) extends Logging { | ||
|
|
||
| private val timeout = AkkaUtils.askTimeout(conf) | ||
|
|
||
| /** Set to the MapOutputTrackerActor living on the driver */ | ||
| /** Set to the MapOutputTrackerActor living on the driver. */ | ||
| var trackerActor: ActorRef = _ | ||
|
|
||
| /** This HashMap needs to have different storage behavior for driver and worker */ | ||
| /** | ||
| * This HashMap has different behavior for the master and the workers. | ||
| * | ||
| * On the master, it serves as the source of map outputs recorded from ShuffleMapTasks. | ||
| * On the workers, it simply serves as a cache, in which a miss triggers a fetch from the | ||
| * master's corresponding HashMap. | ||
| */ | ||
| protected val mapStatuses: Map[Int, Array[MapStatus]] | ||
|
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. This comment is a bit vague - could you elaborate on what is different? |
||
|
|
||
| /** | ||
|
|
@@ -87,7 +92,7 @@ private[spark] abstract class MapOutputTracker(conf: SparkConf) extends Logging | |
| protected var epoch: Long = 0 | ||
| protected val epochLock = new AnyRef | ||
|
|
||
| /** Remembers which map output locations are currently being fetched on a worker */ | ||
| /** Remembers which map output locations are currently being fetched on a worker. */ | ||
| private val fetching = new HashSet[Int] | ||
|
|
||
| /** | ||
|
|
@@ -173,7 +178,7 @@ private[spark] abstract class MapOutputTracker(conf: SparkConf) extends Logging | |
| } | ||
| } | ||
|
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. Not exactly related to your patch, but does the MOTMaster ever call
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. Makes sense. Will do.
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. I played around with this and actually realized that the these are used in the local mode. So they kind of have to be in the MapOutputTracker as both MapOutputTrackerWorker and MapOutputTrackerMaster (in local mode), needs them. |
||
|
|
||
| /** Called to get current epoch number */ | ||
| /** Called to get current epoch number. */ | ||
| def getEpoch: Long = { | ||
| epochLock.synchronized { | ||
| return epoch | ||
|
|
@@ -195,16 +200,13 @@ private[spark] abstract class MapOutputTracker(conf: SparkConf) extends Logging | |
| } | ||
| } | ||
|
|
||
| /** Unregister shuffle data */ | ||
| /** Unregister shuffle data. */ | ||
| def unregisterShuffle(shuffleId: Int) { | ||
| mapStatuses.remove(shuffleId) | ||
| } | ||
|
|
||
| def stop() { | ||
| sendTracker(StopMapOutputTracker) | ||
| mapStatuses.clear() | ||
| trackerActor = null | ||
| } | ||
| /** Stop the tracker. */ | ||
| def stop() { } | ||
| } | ||
|
|
||
| /** | ||
|
|
@@ -219,7 +221,7 @@ private[spark] class MapOutputTrackerMaster(conf: SparkConf) | |
|
|
||
| /** | ||
| * Timestamp based HashMap for storing mapStatuses and cached serialized statuses in the master, | ||
| * so that statuses are dropped only by explicit deregistering or by TTL-based cleaning (if set). | ||
| * so that statuses are dropped only by explicit de-registering or by TTL-based cleaning (if set). | ||
| * Other than these two scenarios, nothing should be dropped from this HashMap. | ||
| */ | ||
| protected val mapStatuses = new TimeStampedHashMap[Int, Array[MapStatus]]() | ||
|
|
@@ -314,7 +316,9 @@ private[spark] class MapOutputTrackerMaster(conf: SparkConf) | |
| } | ||
|
|
||
| override def stop() { | ||
| super.stop() | ||
| sendTracker(StopMapOutputTracker) | ||
| mapStatuses.clear() | ||
| trackerActor = null | ||
| metadataCleaner.cancel() | ||
| cachedSerializedStatuses.clear() | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -35,6 +35,7 @@ import org.apache.hadoop.mapreduce.{InputFormat => NewInputFormat, Job => NewHad | |
| import org.apache.hadoop.mapreduce.lib.input.{FileInputFormat => NewFileInputFormat} | ||
| import org.apache.mesos.MesosNativeLibrary | ||
|
|
||
| import org.apache.spark.broadcast.Broadcast | ||
| import org.apache.spark.deploy.{LocalSparkCluster, SparkHadoopUtil} | ||
| import org.apache.spark.partial.{ApproximateEvaluator, PartialResult} | ||
| import org.apache.spark.rdd._ | ||
|
|
@@ -227,8 +228,12 @@ class SparkContext( | |
| @volatile private[spark] var dagScheduler = new DAGScheduler(this) | ||
| dagScheduler.start() | ||
|
|
||
| private[spark] val cleaner = new ContextCleaner(this) | ||
| cleaner.start() | ||
| private[spark] val cleaner: Option[ContextCleaner] = | ||
| if (conf.getBoolean("spark.cleaner.automatic", true)) { | ||
| Some(new ContextCleaner(this)) | ||
| } else None | ||
|
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. I think style guide says this
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. Right. Fixed. Will push with all updates. |
||
|
|
||
| cleaner.foreach(_.start()) | ||
|
|
||
| postEnvironmentUpdate() | ||
|
|
||
|
|
@@ -643,9 +648,9 @@ class SparkContext( | |
| * [[org.apache.spark.broadcast.Broadcast]] object for reading it in distributed functions. | ||
| * The variable will be sent to each cluster only once. | ||
| */ | ||
| def broadcast[T](value: T) = { | ||
| def broadcast[T](value: T): Broadcast[T] = { | ||
| val bc = env.broadcastManager.newBroadcast[T](value, isLocal) | ||
| cleaner.registerBroadcastForCleanup(bc) | ||
| cleaner.foreach(_.registerBroadcastForCleanup(bc)) | ||
| bc | ||
| } | ||
|
|
||
|
|
@@ -840,7 +845,7 @@ class SparkContext( | |
| dagScheduler = null | ||
| if (dagSchedulerCopy != null) { | ||
| metadataCleaner.cancel() | ||
| cleaner.stop() | ||
| cleaner.foreach(_.stop()) | ||
| dagSchedulerCopy.stop() | ||
| listenerBus.stop() | ||
| taskScheduler = null | ||
|
|
||
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.
"... keeps track of the location of the location of the mapt output..."
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.
Fixed.