Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -193,15 +193,16 @@ class DAGScheduler(
eventProcessActor ! TaskSetFailed(taskSet, reason)
}

private def getCacheLocs(rdd: RDD[_]): Array[Seq[TaskLocation]] = {
if (!cacheLocs.contains(rdd.id)) {
val blockIds = rdd.partitions.indices.map(index => RDDBlockId(rdd.id, index)).toArray[BlockId]
val locs = BlockManager.blockIdsToBlockManagers(blockIds, env, blockManagerMaster)
cacheLocs(rdd.id) = blockIds.map { id =>
locs.getOrElse(id, Nil).map(bm => TaskLocation(bm.host, bm.executorId))
}
private def getLocs(rdd: RDD[_]): Array[Seq[TaskLocation]] = {
val blockIds = rdd.partitions.indices.map(index => RDDBlockId(rdd.id, index)).toArray[BlockId]
val locs = BlockManager.blockIdsToBlockManagers(blockIds, env, blockManagerMaster)
blockIds.map { id =>
locs.getOrElse(id, Nil).map(bm => TaskLocation(bm.host, bm.executorId))
}
cacheLocs(rdd.id)
}

private def getCacheLocs(rdd: RDD[_]): Array[Seq[TaskLocation]] = {
cacheLocs.getOrElseUpdate(rdd.id,getLocs(rdd))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm, is this actually thread-safe either? It's not a concurrent Map. Even if it is, I'm not clear that it stops many values for being cached and computed for an ID, but if that's cheap and they're immutable, that could be fine.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Even if this was a concurrent map, I'm not sure that getOrElseUpdate would be thread-safe (surprisingly!):

https://issues.scala-lang.org/browse/SI-7943

}

private def clearCacheLocs() {
Expand Down