Github user JoshRosen commented on a diff in the pull request:
https://github.com/apache/spark/pull/6397#discussion_r30989654
--- Diff:
core/src/main/scala/org/apache/spark/util/collection/ExternalSorter.scala ---
@@ -123,43 +134,28 @@ private[spark] class ExternalSorter[K, V, C](
// grow internal data structures by growing + copying every time the
number of objects doubles.
private val serializerBatchSize =
conf.getLong("spark.shuffle.spill.batchSize", 10000)
- private def getPartition(key: K): Int = {
- if (shouldPartition) partitioner.get.getPartition(key) else 0
- }
-
- private val metaInitialRecords = 256
- private val kvChunkSize = conf.getInt("spark.shuffle.sort.kvChunkSize",
1 << 22) // 4 MB
- private val useSerializedPairBuffer =
- !ordering.isDefined &&
conf.getBoolean("spark.shuffle.sort.serializeMapOutputs", true) &&
- ser.supportsRelocationOfSerializedObjects
-
// Data structures to store in-memory objects before we spill. Depending
on whether we have an
// Aggregator set, we either put objects into an AppendOnlyMap where we
combine them, or we
// store them in an array buffer.
- private var map = new PartitionedAppendOnlyMap[K, C]
- private var buffer = if (useSerializedPairBuffer) {
- new PartitionedSerializedPairBuffer[K, C](metaInitialRecords,
kvChunkSize, serInstance)
- } else {
- new PartitionedPairBuffer[K, C]
+ private def newBuffer: () => WritablePartitionedPairCollection[K, C]
with SizeTracker = {
+ val useSerializedPairBuffer =
+ ordering.isEmpty &&
+ conf.getBoolean("spark.shuffle.sort.serializeMapOutputs", true) &&
+ ser.supportsRelocationOfSerializedObjects
+ if (useSerializedPairBuffer) {
+ val kvChunkSize = conf.getInt("spark.shuffle.sort.kvChunkSize", 1 <<
22) // 4 MB
+ () => new PartitionedSerializedPairBuffer(metaInitialRecords = 256,
kvChunkSize, serInstance)
+ } else {
+ () => new PartitionedPairBuffer[K, C]
+ }
}
+ private var map = new PartitionedAppendOnlyMap[K, C]
+ private var buffer = newBuffer()
// Total spilling statistics
private var _diskBytesSpilled = 0L
+ def diskBytesSpilled: Long = _diskBytesSpilled
- // Write metrics for current spill
- private var curWriteMetrics: ShuffleWriteMetrics = _
--- End diff --
In the old code, it was pretty hard to trace through usages of this
variable to figure out where it was reset / updated. After removing the hash
bypass code, I noticed that this variable's scope can be reduced to a local
variable in `spillToMergebableFiles`.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]