GitHub user jongwook opened a pull request:

    https://github.com/apache/spark/pull/16916

    [SPARK-19501] Reduce the number of HDFS RPCs during YARN deployment

    ## What changes were proposed in this pull request?
    
    As discussed in [JIRA](https://issues.apache.org/jira/browse/SPARK-19501), 
this patch addresses the problem where too many HDFS RPCs are made when there 
are many URIs specified in `spark.yarn.jars`, potentially adding hundreds of 
RTTs to YARN before the application launches. This becomes significant when 
submitting the application to a non-local YARN cluster (where the RTT may be in 
order of 100ms, for example). For each URI specified, the current 
implementation makes at least two HDFS RPCs, for:
    
    - [Calling `getFileStatus()` before uploading each file to the distributed 
cache in 
`ClientDistributedCacheManager.addResource()`](https://github.com/apache/spark/blob/v2.1.0/yarn/src/main/scala/org/apache/spark/deploy/yarn/ClientDistributedCacheManager.scala#L71).
    - [Resolving any symbolic links in each of the file 
URI](https://github.com/apache/spark/blob/v2.1.0/yarn/src/main/scala/org/apache/spark/deploy/yarn/Client.scala#L377-L379),
 which repeatedly makes HDFS RPCs until the all symlinks are resolved. (see 
[`FileContext.resolve(Path)`](https://github.com/apache/hadoop/blob/release-2.7.1/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/FileContext.java#L2189-L2195),
 [`FSLinkResolver.resolve(FileContext, 
Path)`](https://github.com/apache/hadoop/blob/release-2.7.1/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/FSLinkResolver.java#L79-L112),
 and 
[`AbstractFileSystem.resolvePath()`](https://github.com/apache/hadoop/blob/release-2.7.1/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/AbstractFileSystem.java#L464-L468).)
    
    The first `getFileStatus` RPC can be removed, using `statCache` populated 
with the file statuses retrieved with [the previous `globStatus` 
call](https://github.com/apache/spark/blob/v2.1.0/yarn/src/main/scala/org/apache/spark/deploy/yarn/Client.scala#L531).
    
    The second one can be largely reduced by caching the symlink resolution 
results in a mutable.HashMap. This patch adds a local variable in 
`yarn.Client.prepareLocalResources()` and passes it as an additional parameter 
to `yarn.Client.copyFileToRemote`.  [The symlink resolution code was added in 
2013](https://github.com/apache/spark/commit/a35472e1dd2ea1b5a0b1fb6b382f5a98f5aeba5a#diff-b050df3f55b82065803d6e83453b9706R187)
 and has not changed since. I am assuming that this is still required, but 
otherwise we can remove using `symlinkCache` and symlink resolution altogether.
    
    ## How was this patch tested?
    
    This patch is based off 8e8afb3, currently the latest YARN patch on master. 
All tests except a few in spark-hive passed with `./dev/run-tests` on my 
machine, using JDK 1.8.0_112 on macOS 10.12.3; also tested myself with this 
modified version of SPARK 2.2.0-SNAPSHOT which performed a normal deployment 
and execution on a YARN cluster without errors.


You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/jongwook/spark SPARK-19501

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/spark/pull/16916.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #16916
    
----
commit 984d8180babb9f7d8b5992f97523447d6a7ca910
Author: Jong Wook Kim <[email protected]>
Date:   2017-02-13T17:47:09Z

    [SPARK-19501] Reduce the number of HDFS RPCs during YARN deployment

----


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