Github user cloud-fan commented on a diff in the pull request:

    https://github.com/apache/spark/pull/17617#discussion_r119275374
  
    --- Diff: core/src/main/scala/org/apache/spark/deploy/SparkHadoopUtil.scala 
---
    @@ -143,14 +144,18 @@ class SparkHadoopUtil extends Logging {
        * Returns a function that can be called to find Hadoop FileSystem bytes 
read. If
        * getFSBytesReadOnThreadCallback is called from thread r at time t, the 
returned callback will
        * return the bytes read on r since t.
    -   *
    -   * @return None if the required method can't be found.
        */
       private[spark] def getFSBytesReadOnThreadCallback(): () => Long = {
    -    val threadStats = 
FileSystem.getAllStatistics.asScala.map(_.getThreadStatistics)
    -    val f = () => threadStats.map(_.getBytesRead).sum
    -    val baselineBytesRead = f()
    -    () => f() - baselineBytesRead
    +    val f = () => 
FileSystem.getAllStatistics.asScala.map(_.getThreadStatistics.getBytesRead).sum
    +    val baseline = (Thread.currentThread().getId, f())
    +    val bytesReadMap = new ConcurrentHashMap[Long, Long]()
    +
    +    () => {
    +      bytesReadMap.put(Thread.currentThread().getId, f())
    +      bytesReadMap.asScala.map { case (k, v) =>
    --- End diff --
    
    this is not atomic, shall we synchronize on `bytesReadMap` when calculating 
the sum?


---
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]

Reply via email to