-
Notifications
You must be signed in to change notification settings - Fork 29k
[SPARK-20776] Fix perf. problems in JobProgressListener caused by TaskMetrics construction #18008
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 2 commits
622951f
4675b21
782b772
214559e
6e66b80
1c62909
feda785
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 |
|---|---|---|
|
|
@@ -18,7 +18,9 @@ | |
| package org.apache.spark.executor | ||
|
|
||
| import scala.collection.JavaConverters._ | ||
| import scala.collection.mutable.{ArrayBuffer, LinkedHashMap} | ||
| import scala.collection.mutable.ArrayBuffer | ||
|
|
||
| import com.google.common.collect.Maps | ||
|
|
||
| import org.apache.spark._ | ||
| import org.apache.spark.annotation.DeveloperApi | ||
|
|
@@ -200,32 +202,47 @@ class TaskMetrics private[spark] () extends Serializable { | |
|
|
||
|
|
||
| import InternalAccumulator._ | ||
| @transient private[spark] lazy val nameToAccums = LinkedHashMap( | ||
| EXECUTOR_DESERIALIZE_TIME -> _executorDeserializeTime, | ||
| EXECUTOR_DESERIALIZE_CPU_TIME -> _executorDeserializeCpuTime, | ||
| EXECUTOR_RUN_TIME -> _executorRunTime, | ||
| EXECUTOR_CPU_TIME -> _executorCpuTime, | ||
| RESULT_SIZE -> _resultSize, | ||
| JVM_GC_TIME -> _jvmGCTime, | ||
| RESULT_SERIALIZATION_TIME -> _resultSerializationTime, | ||
| MEMORY_BYTES_SPILLED -> _memoryBytesSpilled, | ||
| DISK_BYTES_SPILLED -> _diskBytesSpilled, | ||
| PEAK_EXECUTION_MEMORY -> _peakExecutionMemory, | ||
| UPDATED_BLOCK_STATUSES -> _updatedBlockStatuses, | ||
| shuffleRead.REMOTE_BLOCKS_FETCHED -> shuffleReadMetrics._remoteBlocksFetched, | ||
| shuffleRead.LOCAL_BLOCKS_FETCHED -> shuffleReadMetrics._localBlocksFetched, | ||
| shuffleRead.REMOTE_BYTES_READ -> shuffleReadMetrics._remoteBytesRead, | ||
| shuffleRead.LOCAL_BYTES_READ -> shuffleReadMetrics._localBytesRead, | ||
| shuffleRead.FETCH_WAIT_TIME -> shuffleReadMetrics._fetchWaitTime, | ||
| shuffleRead.RECORDS_READ -> shuffleReadMetrics._recordsRead, | ||
| shuffleWrite.BYTES_WRITTEN -> shuffleWriteMetrics._bytesWritten, | ||
| shuffleWrite.RECORDS_WRITTEN -> shuffleWriteMetrics._recordsWritten, | ||
| shuffleWrite.WRITE_TIME -> shuffleWriteMetrics._writeTime, | ||
| input.BYTES_READ -> inputMetrics._bytesRead, | ||
| input.RECORDS_READ -> inputMetrics._recordsRead, | ||
| output.BYTES_WRITTEN -> outputMetrics._bytesWritten, | ||
| output.RECORDS_WRITTEN -> outputMetrics._recordsWritten | ||
| ) ++ testAccum.map(TEST_ACCUM -> _) | ||
| @transient private[spark] lazy val nameToAccums = { | ||
| // The construction of this map is a performance hotspot in the JobProgressListener, so we | ||
| // optimize this by using a pre-sized Java hashmap; see SPARK-20776 for more details. | ||
| val mapEntries = Array[(String, AccumulatorV2[_, _])]( | ||
| EXECUTOR_DESERIALIZE_TIME -> _executorDeserializeTime, | ||
| EXECUTOR_DESERIALIZE_CPU_TIME -> _executorDeserializeCpuTime, | ||
| EXECUTOR_RUN_TIME -> _executorRunTime, | ||
| EXECUTOR_CPU_TIME -> _executorCpuTime, | ||
| RESULT_SIZE -> _resultSize, | ||
| JVM_GC_TIME -> _jvmGCTime, | ||
| RESULT_SERIALIZATION_TIME -> _resultSerializationTime, | ||
| MEMORY_BYTES_SPILLED -> _memoryBytesSpilled, | ||
| DISK_BYTES_SPILLED -> _diskBytesSpilled, | ||
| PEAK_EXECUTION_MEMORY -> _peakExecutionMemory, | ||
| UPDATED_BLOCK_STATUSES -> _updatedBlockStatuses, | ||
| shuffleRead.REMOTE_BLOCKS_FETCHED -> shuffleReadMetrics._remoteBlocksFetched, | ||
| shuffleRead.LOCAL_BLOCKS_FETCHED -> shuffleReadMetrics._localBlocksFetched, | ||
| shuffleRead.REMOTE_BYTES_READ -> shuffleReadMetrics._remoteBytesRead, | ||
| shuffleRead.LOCAL_BYTES_READ -> shuffleReadMetrics._localBytesRead, | ||
| shuffleRead.FETCH_WAIT_TIME -> shuffleReadMetrics._fetchWaitTime, | ||
| shuffleRead.RECORDS_READ -> shuffleReadMetrics._recordsRead, | ||
| shuffleWrite.BYTES_WRITTEN -> shuffleWriteMetrics._bytesWritten, | ||
| shuffleWrite.RECORDS_WRITTEN -> shuffleWriteMetrics._recordsWritten, | ||
| shuffleWrite.WRITE_TIME -> shuffleWriteMetrics._writeTime, | ||
| input.BYTES_READ -> inputMetrics._bytesRead, | ||
| input.RECORDS_READ -> inputMetrics._recordsRead, | ||
| output.BYTES_WRITTEN -> outputMetrics._bytesWritten, | ||
| output.RECORDS_WRITTEN -> outputMetrics._recordsWritten | ||
| ) | ||
| val map = Maps.newHashMapWithExpectedSize[String, AccumulatorV2[_, _]](mapEntries.length) | ||
| var i = 0 | ||
| while (i < mapEntries.length) { | ||
| val e = mapEntries(i) | ||
| map.put(e._1, e._2) | ||
| i += 1 | ||
| } | ||
| testAccum.foreach { accum => | ||
| map.put(TEST_ACCUM, accum) | ||
| } | ||
| map.asScala | ||
|
||
| } | ||
|
|
||
| @transient private[spark] lazy val internalAccums: Seq[AccumulatorV2[_, _]] = | ||
| nameToAccums.values.toIndexedSeq | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.
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.
It looks like the use of
LinkedHashMapwas added by @cloud-fan in #12612 in order to preserve ordering from the old code. As far as I can tell we don't actually rely on the ordering of the entries in this map, so I didn't preserved the use ofLinkedHashMap.