-
Notifications
You must be signed in to change notification settings - Fork 28.7k
[SPARK-3288] All fields in TaskMetrics should be private and use getters/setters #4020
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 all commits
c64da4f
5525c20
17146c2
26b312b
1149e78
6444391
b8c05cb
e446287
39f3810
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 |
---|---|---|
|
@@ -44,42 +44,62 @@ class TaskMetrics extends Serializable { | |
/** | ||
* Host's name the task runs on | ||
*/ | ||
var hostname: String = _ | ||
|
||
private var _hostname: String = _ | ||
def hostname = _hostname | ||
private[spark] def setHostname(value : String) = _hostname = value | ||
|
||
/** | ||
* Time taken on the executor to deserialize this task | ||
*/ | ||
var executorDeserializeTime: Long = _ | ||
|
||
private var _executorDeserializeTime: Long = _ | ||
def executorDeserializeTime = _executorDeserializeTime | ||
private[spark] def setExecutorDeserializeTime(value: Long) = _executorDeserializeTime = value | ||
|
||
|
||
/** | ||
* Time the executor spends actually running the task (including fetching shuffle data) | ||
*/ | ||
var executorRunTime: Long = _ | ||
|
||
private var _executorRunTime: Long = _ | ||
def executorRunTime = _executorRunTime | ||
private[spark] def setExecutorRunTime(value: Long) = _executorRunTime = value | ||
|
||
/** | ||
* The number of bytes this task transmitted back to the driver as the TaskResult | ||
*/ | ||
var resultSize: Long = _ | ||
private var _resultSize: Long = _ | ||
def resultSize = _resultSize | ||
private[spark] def setResultSize(value: Long) = _resultSize = value | ||
|
||
|
||
/** | ||
* Amount of time the JVM spent in garbage collection while executing this task | ||
*/ | ||
var jvmGCTime: Long = _ | ||
private var _jvmGCTime: Long = _ | ||
def jvmGCTime = _jvmGCTime | ||
private[spark] def setJvmGCTime(value: Long) = _jvmGCTime = value | ||
|
||
/** | ||
* Amount of time spent serializing the task result | ||
*/ | ||
var resultSerializationTime: Long = _ | ||
private var _resultSerializationTime: Long = _ | ||
def resultSerializationTime = _resultSerializationTime | ||
private[spark] def setResultSerializationTime(value: Long) = _resultSerializationTime = value | ||
|
||
/** | ||
* The number of in-memory bytes spilled by this task | ||
*/ | ||
var memoryBytesSpilled: Long = _ | ||
private var _memoryBytesSpilled: Long = _ | ||
def memoryBytesSpilled = _memoryBytesSpilled | ||
private[spark] def incMemoryBytesSpilled(value: Long) = _memoryBytesSpilled += value | ||
private[spark] def decMemoryBytesSpilled(value: Long) = _memoryBytesSpilled -= value | ||
|
||
/** | ||
* The number of on-disk bytes spilled by this task | ||
*/ | ||
var diskBytesSpilled: Long = _ | ||
private var _diskBytesSpilled: Long = _ | ||
def diskBytesSpilled = _diskBytesSpilled | ||
def incDiskBytesSpilled(value: Long) = _diskBytesSpilled += value | ||
def decDiskBytesSpilled(value: Long) = _diskBytesSpilled -= value | ||
|
||
/** | ||
* If this task reads from a HadoopRDD or from persisted data, metrics on how much data was read | ||
|
@@ -178,10 +198,10 @@ class TaskMetrics extends Serializable { | |
private[spark] def updateShuffleReadMetrics() = synchronized { | ||
val merged = new ShuffleReadMetrics() | ||
for (depMetrics <- depsShuffleReadMetrics) { | ||
merged.fetchWaitTime += depMetrics.fetchWaitTime | ||
merged.localBlocksFetched += depMetrics.localBlocksFetched | ||
merged.remoteBlocksFetched += depMetrics.remoteBlocksFetched | ||
merged.remoteBytesRead += depMetrics.remoteBytesRead | ||
merged.incFetchWaitTime(depMetrics.fetchWaitTime) | ||
merged.incLocalBlocksFetched(depMetrics.localBlocksFetched) | ||
merged.incRemoteBlocksFetched(depMetrics.remoteBlocksFetched) | ||
merged.incRemoteBytesRead(depMetrics.remoteBytesRead) | ||
} | ||
_shuffleReadMetrics = Some(merged) | ||
} | ||
|
@@ -265,7 +285,9 @@ case class OutputMetrics(writeMethod: DataWriteMethod.Value) { | |
/** | ||
* Total bytes written | ||
*/ | ||
var bytesWritten: Long = 0L | ||
private var _bytesWritten: Long = _ | ||
def bytesWritten = _bytesWritten | ||
private[spark] def setBytesWritten(value : Long) = _bytesWritten = value | ||
} | ||
|
||
/** | ||
|
@@ -274,32 +296,45 @@ case class OutputMetrics(writeMethod: DataWriteMethod.Value) { | |
*/ | ||
@DeveloperApi | ||
class ShuffleReadMetrics extends Serializable { | ||
/** | ||
* Number of blocks fetched in this shuffle by this task (remote or local) | ||
*/ | ||
def totalBlocksFetched: Int = remoteBlocksFetched + localBlocksFetched | ||
|
||
/** | ||
* Number of remote blocks fetched in this shuffle by this task | ||
*/ | ||
var remoteBlocksFetched: Int = _ | ||
|
||
private var _remoteBlocksFetched: Int = _ | ||
def remoteBlocksFetched = _remoteBlocksFetched | ||
private[spark] def incRemoteBlocksFetched(value: Int) = _remoteBlocksFetched += value | ||
private[spark] def defRemoteBlocksFetched(value: Int) = _remoteBlocksFetched -= value | ||
|
||
/** | ||
* Number of local blocks fetched in this shuffle by this task | ||
*/ | ||
var localBlocksFetched: Int = _ | ||
private var _localBlocksFetched: Int = _ | ||
def localBlocksFetched = _localBlocksFetched | ||
private[spark] def incLocalBlocksFetched(value: Int) = _localBlocksFetched += value | ||
private[spark] def defLocalBlocksFetched(value: Int) = _localBlocksFetched -= value | ||
|
||
|
||
/** | ||
* Time the task spent waiting for remote shuffle blocks. This only includes the time | ||
* blocking on shuffle input data. For instance if block B is being fetched while the task is | ||
* still not finished processing block A, it is not considered to be blocking on block B. | ||
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. Can we make these AtomicLong's so that the incrementing can be threadsafe. I have a pr out that does this: 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.
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. Fair enough, but it is hard to guarantee that only one thread will increment the value. We could mark the class as not thread safe by docs but it might be a ticking time bomb. Is the overhead of AtomicLong that concerning to risk concurrency issues down the line? Speaking of shuffleMetrics, can we get rid of the array of shuffleReadMetrics (depsShuffleReadMetrics) and the merge step in favor of using AtomicLongs in ShuffleReadMetrics? That way the TaskMetrics can just return the same threadsafe ShuffleReadMetrics to the tasks and there wouldn't need to be a need to call updateShuffleReadMetrics periodically in the Executor heartbeat code. |
||
*/ | ||
var fetchWaitTime: Long = _ | ||
|
||
private var _fetchWaitTime: Long = _ | ||
def fetchWaitTime = _fetchWaitTime | ||
private[spark] def incFetchWaitTime(value: Long) = _fetchWaitTime += value | ||
private[spark] def decFetchWaitTime(value: Long) = _fetchWaitTime -= value | ||
|
||
/** | ||
* Total number of remote bytes read from the shuffle by this task | ||
*/ | ||
var remoteBytesRead: Long = _ | ||
private var _remoteBytesRead: Long = _ | ||
def remoteBytesRead = _remoteBytesRead | ||
private[spark] def incRemoteBytesRead(value: Long) = _remoteBytesRead += value | ||
private[spark] def decRemoteBytesRead(value: Long) = _remoteBytesRead -= value | ||
|
||
/** | ||
* Number of blocks fetched in this shuffle by this task (remote or local) | ||
*/ | ||
def totalBlocksFetched = _remoteBlocksFetched + _localBlocksFetched | ||
} | ||
|
||
/** | ||
|
@@ -311,10 +346,18 @@ class ShuffleWriteMetrics extends Serializable { | |
/** | ||
* Number of bytes written for the shuffle by this task | ||
*/ | ||
@volatile var shuffleBytesWritten: Long = _ | ||
|
||
@volatile private var _shuffleBytesWritten: Long = _ | ||
def shuffleBytesWritten = _shuffleBytesWritten | ||
private[spark] def incShuffleBytesWritten(value: Long) = _shuffleBytesWritten += value | ||
private[spark] def decShuffleBytesWritten(value: Long) = _shuffleBytesWritten -= value | ||
|
||
/** | ||
* Time the task spent blocking on writes to disk or buffer cache, in nanoseconds | ||
*/ | ||
@volatile var shuffleWriteTime: Long = _ | ||
@volatile private var _shuffleWriteTime: Long = _ | ||
def shuffleWriteTime= _shuffleWriteTime | ||
private[spark] def incShuffleWriteTime(value: Long) = _shuffleWriteTime += value | ||
private[spark] def decShuffleWriteTime(value: Long) = _shuffleWriteTime -= value | ||
|
||
|
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -245,6 +245,7 @@ class HadoopRDD[K, V]( | |
case eof: EOFException => | ||
finished = true | ||
} | ||
|
||
(key, value) | ||
} | ||
|
||
|
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.
Should be "
value: String
" with no space (not sure why our style checks didn't catch this).