Github user sryza commented on a diff in the pull request:

    https://github.com/apache/spark/pull/2087#discussion_r18833578
  
    --- Diff: core/src/main/scala/org/apache/spark/deploy/SparkHadoopUtil.scala 
---
    @@ -121,6 +125,31 @@ class SparkHadoopUtil extends Logging {
         UserGroupInformation.loginUserFromKeytab(principalName, keytabFilename)
       }
     
    +  /**
    +   * Returns a function that can be called to find the number of Hadoop 
FileSystem bytes read by
    +   * this thread so far. Reflection is required because thread-level 
FileSystem statistics are only
    +   * available as of Hadoop 2.5 (see HADOOP-10688). Returns None if the 
required method can't be
    +   * found.
    +   */
    +  def getInputBytesReadCallback(path: Path, conf: Configuration): 
Option[() => Long] = {
    +    val qualifiedPath = path.getFileSystem(conf).makeQualified(path)
    +    val scheme = qualifiedPath.toUri().getScheme()
    +    val stats = 
FileSystem.getAllStatistics().filter(_.getScheme().equals(scheme))
    +    try {
    +      val threadStats = stats.map(Utils.invoke(classOf[Statistics], _, 
"getThreadStatistics"))
    +      val statisticsDataClass =
    +        
Class.forName("org.apache.hadoop.fs.FileSystem$Statistics$StatisticsData")
    +      val getBytesReadMethod = 
statisticsDataClass.getDeclaredMethod("getBytesRead")
    +      val f = () => 
threadStats.map(getBytesReadMethod.invoke(_).asInstanceOf[Long]).sum
    +      val start = f()
    +      Some(() => f() - start)
    --- End diff --
    
    `getBytesRead` will give you the bytes since the thread was created.  As 
executors can put multiple tasks on the same thread, calling it without a delta 
could include bytes read from a previous task.  I'll comment / restructure this 
to make it a little more clear.


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