HyukjinKwon commented on code in PR #49032:
URL: https://github.com/apache/spark/pull/49032#discussion_r3974102410
##########
core/src/main/scala/org/apache/spark/MapOutputTracker.scala:
##########
@@ -1377,18 +1461,36 @@ private[spark] class MapOutputTrackerMaster(
Seq.empty.iterator
}
- // This method is only called in local-mode.
+ // Called in local-mode, and by BlockManagerMaster.removeShuffle to snapshot
the merger locations
+ // for a shuffle it is about to remove. No atime update, because of that
second caller: stamping
+ // here would resurrect the atime of a shuffle that is going away.
override def getShufflePushMergerLocations(shuffleId: Int):
Seq[BlockManagerId] = {
shuffleStatuses.get(shuffleId).map(_.getShufflePushMergerLocations).getOrElse(Seq.empty)
}
+ /**
+ * The location and map id of every available map output of a shuffle. Used
by the shuffle removal
+ * path to work out which blocks an external shuffle service still holds on
behalf of executors
+ * that have since gone away. Reading this takes the shuffle's
`ShuffleStatus` lock, so it is
+ * snapshotted on the caller's thread -- see
`BlockManagerMaster.removeShuffle`. No atime update,
+ * for the same reason as `getShufflePushMergerLocations` above.
+ */
+ private[spark] def getMapOutputLocations(shuffleId: Int):
Seq[(BlockManagerId, Long)] = {
+ shuffleStatuses.get(shuffleId).map { shuffleStatus =>
+ shuffleStatus.withMapStatuses { statuses =>
+ statuses.filter(_ != null).map(status => (status.location,
status.mapId)).toSeq
Review Comment:
Non-blocking: this traverses the map-status array twice and allocates an
intermediate array (`filter` then `map`). `iterator` fuses it into a single
pass. Minor — it runs once per shuffle removal, not on a hot path.
```suggestion
statuses.iterator.filter(_ != null).map(status => (status.location,
status.mapId)).toSeq
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]