-
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 1 commit
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
…Cleaner.
- Loading branch information
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -130,7 +130,8 @@ class BlockManagerMaster(var driverActor: ActorRef, conf: SparkConf) extends Log | |
|
|
||
| /** Remove all blocks belonging to the given broadcast. */ | ||
| def removeBroadcast(broadcastId: Long, removeFromMaster: Boolean, blocking: Boolean) { | ||
| val future = askDriverWithReply[Future[Seq[Int]]](RemoveBroadcast(broadcastId, removeFromMaster)) | ||
| val future = askDriverWithReply[Future[Seq[Int]]]( | ||
| RemoveBroadcast(broadcastId, removeFromMaster)) | ||
| future.onFailure { | ||
| case e: Throwable => | ||
| logError("Failed to remove broadcast " + broadcastId + | ||
|
|
@@ -156,8 +157,8 @@ class BlockManagerMaster(var driverActor: ActorRef, conf: SparkConf) extends Log | |
| } | ||
|
|
||
| /** | ||
| * Return the block's status on all block managers, if any. This can potentially be an | ||
| * expensive operation and is used mainly for testing. | ||
| * Return the block's status on all block managers, if any. NOTE: This is a | ||
| * potentially expensive operation and should only be used for testing. | ||
| * | ||
| * If askSlaves is true, this invokes the master to query each block manager for the most | ||
| * updated block statuses. This is useful when the master is not informed of the given block | ||
|
|
@@ -184,6 +185,22 @@ class BlockManagerMaster(var driverActor: ActorRef, conf: SparkConf) extends Log | |
| }.toMap | ||
| } | ||
|
|
||
|
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 is introduced for testing broadcast cleanup (but can be used for other things in the future). |
||
| /** | ||
| * Return a list of ids of existing blocks such that the ids match the given filter. NOTE: This | ||
| * is a potentially expensive operation and should only be used for testing. | ||
| * | ||
| * If askSlaves is true, this invokes the master to query each block manager for the most | ||
| * updated block statuses. This is useful when the master is not informed of the given block | ||
| * by all block managers. | ||
| */ | ||
| def getMatcinghBlockIds( | ||
| filter: BlockId => Boolean, | ||
| askSlaves: Boolean): Seq[BlockId] = { | ||
| val msg = GetMatchingBlockIds(filter, askSlaves) | ||
| val future = askDriverWithReply[Future[Seq[BlockId]]](msg) | ||
| Await.result(future, timeout) | ||
| } | ||
|
|
||
| /** Stop the driver actor, called only on the Spark driver node */ | ||
| def stop() { | ||
| if (driverActor != null) { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -39,28 +39,34 @@ class BlockManagerSlaveActor( | |
| // Operations that involve removing blocks may be slow and should be done asynchronously | ||
| override def receive = { | ||
| case RemoveBlock(blockId) => | ||
| doAsync("removing block", sender) { | ||
| doAsync[Boolean]("removing block", sender) { | ||
| blockManager.removeBlock(blockId) | ||
| true | ||
| } | ||
|
|
||
| case RemoveRdd(rddId) => | ||
| doAsync("removing RDD", sender) { | ||
| doAsync[Int]("removing RDD", sender) { | ||
| blockManager.removeRdd(rddId) | ||
| } | ||
|
|
||
| case RemoveShuffle(shuffleId) => | ||
| doAsync("removing shuffle", sender) { | ||
| doAsync[Boolean]("removing shuffle", sender) { | ||
| if (mapOutputTracker != null) { | ||
| mapOutputTracker.unregisterShuffle(shuffleId) | ||
| } | ||
| blockManager.shuffleBlockManager.removeShuffle(shuffleId) | ||
| } | ||
|
|
||
| case RemoveBroadcast(broadcastId, tellMaster) => | ||
| doAsync("removing RDD", sender) { | ||
| doAsync[Int]("removing RDD", sender) { | ||
| blockManager.removeBroadcast(broadcastId, tellMaster) | ||
| } | ||
|
|
||
| case GetBlockStatus(blockId, _) => | ||
| sender ! blockManager.getStatus(blockId) | ||
|
|
||
| case GetMatchingBlockIds(filter, _) => | ||
| sender ! blockManager.getMatchingBlockIds(filter) | ||
| } | ||
|
|
||
| private def doAsync[T](actionMessage: String, responseActor: ActorRef)(body: => T) { | ||
|
|
@@ -70,7 +76,7 @@ class BlockManagerSlaveActor( | |
| response | ||
|
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. Why not just rename |
||
| } | ||
| future.onSuccess { case response => | ||
| logDebug("Successful in " + actionMessage + ", response is " + response) | ||
| logDebug("Done " + actionMessage + ", response is " + response) | ||
|
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 probably want to include the RDD/shuffle/broadcast ID in the action message |
||
| responseActor ! response | ||
| logDebug("Sent response: " + response + " to " + responseActor) | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -47,6 +47,7 @@ private[spark] class DiskBlockManager(shuffleManager: ShuffleBlockManager, rootD | |
| private val subDirs = Array.fill(localDirs.length)(new Array[File](subDirsPerLocalDir)) | ||
| private var shuffleSender : ShuffleSender = null | ||
|
|
||
|
|
||
|
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: this was probably not intended |
||
| addShutdownHook() | ||
|
|
||
| /** | ||
|
|
@@ -95,6 +96,15 @@ private[spark] class DiskBlockManager(shuffleManager: ShuffleBlockManager, rootD | |
| getBlockLocation(blockId).file.exists() | ||
| } | ||
|
|
||
| /** List all the blocks currently stored in disk by the disk manager. */ | ||
|
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. typically people say "stored on disk" not "stored in disk"
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. Cool. |
||
| def getAllBlocks(): Seq[BlockId] = { | ||
| // Get all the files inside the array of array of directories | ||
| subDirs.flatten.filter(_ != null).flatMap { dir => | ||
| val files = dir.list() | ||
| if (files != null) files else Seq.empty | ||
| }.map(BlockId.apply) | ||
| } | ||
|
|
||
| /** Produces a unique block id and File suitable for intermediate results. */ | ||
| def createTempBlock(): (TempBlockId, File) = { | ||
| var blockId = new TempBlockId(UUID.randomUUID()) | ||
|
|
||
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.
I think style guide says this
Noneneeds its own line w/ brackets.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.
Right. Fixed. Will push with all updates.