Uploaded image for project: 'Hadoop Common'
  1. Hadoop Common
  2. HADOOP-12172

FsShell mkdir -p makes an unnecessary check for the existence of the parent.

    Details

    • Type: Improvement
    • Status: Resolved
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 2.8.0, 3.0.0-alpha1
    • Component/s: fs
    • Labels:
      None
    • Target Version/s:
    • Hadoop Flags:
      Reviewed

      Description

      The mkdir command in FsShell checks for the existence of the parent of the directory and returns an error if it doesn't exist. The -p option suppresses the error and allows the directory creation to continue, implicitly creating all missing intermediate directories. However, the existence check still runs even with -p specified, and its result is ignored. Depending on the file system, this is a wasteful RPC call (HDFS) or HTTP request (WebHDFS/S3/Azure) imposing extra latency for the client and extra load for the server.

        Activity

        Hide
        cnauroth Chris Nauroth added a comment -

        Here is a small patch. The code is logically equivalent, but by reversing the order of the checks, short-circuit evaluation prevents execution of the wasteful existence check.

        To test this, I ran hdfs dfs -mkdir -p while watching the HDFS audit log. After applying this patch, the audit log showed one less getFileInfo RPC.

        Show
        cnauroth Chris Nauroth added a comment - Here is a small patch. The code is logically equivalent, but by reversing the order of the checks, short-circuit evaluation prevents execution of the wasteful existence check. To test this, I ran hdfs dfs -mkdir -p while watching the HDFS audit log. After applying this patch, the audit log showed one less getFileInfo RPC.
        Hide
        hitliuyi Yi Liu added a comment -

        +1, thanks Chris

        Show
        hitliuyi Yi Liu added a comment - +1, thanks Chris
        Hide
        hadoopqa Hadoop QA added a comment -



        -1 overall



        Vote Subsystem Runtime Comment
        0 pre-patch 16m 30s Pre-patch trunk compilation is healthy.
        +1 @author 0m 0s The patch does not contain any @author tags.
        -1 tests included 0m 0s The patch doesn't appear to include any new or modified tests. Please justify why no new tests are needed for this patch. Also please list what manual steps were performed to verify this patch.
        +1 javac 7m 34s There were no new javac warning messages.
        +1 javadoc 9m 38s There were no new javadoc warning messages.
        +1 release audit 0m 24s The applied patch does not increase the total number of release audit warnings.
        +1 checkstyle 1m 2s There were no new checkstyle issues.
        +1 whitespace 0m 0s The patch has no lines that end in whitespace.
        +1 install 1m 34s mvn install still works.
        +1 eclipse:eclipse 0m 33s The patch built with eclipse:eclipse.
        +1 findbugs 1m 50s The patch does not introduce any new Findbugs (version 3.0.0) warnings.
        +1 common tests 22m 9s Tests passed in hadoop-common.
            61m 18s  



        Subsystem Report/Notes
        Patch URL http://issues.apache.org/jira/secure/attachment/12743169/HADOOP-12172.001.patch
        Optional Tests javadoc javac unit findbugs checkstyle
        git revision trunk / 0e4b066
        hadoop-common test log https://builds.apache.org/job/PreCommit-HADOOP-Build/7131/artifact/patchprocess/testrun_hadoop-common.txt
        Test Results https://builds.apache.org/job/PreCommit-HADOOP-Build/7131/testReport/
        Java 1.7.0_55
        uname Linux asf902.gq1.ygridcore.net 3.13.0-36-lowlatency #63-Ubuntu SMP PREEMPT Wed Sep 3 21:56:12 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux
        Console output https://builds.apache.org/job/PreCommit-HADOOP-Build/7131/console

        This message was automatically generated.

        Show
        hadoopqa Hadoop QA added a comment - -1 overall Vote Subsystem Runtime Comment 0 pre-patch 16m 30s Pre-patch trunk compilation is healthy. +1 @author 0m 0s The patch does not contain any @author tags. -1 tests included 0m 0s The patch doesn't appear to include any new or modified tests. Please justify why no new tests are needed for this patch. Also please list what manual steps were performed to verify this patch. +1 javac 7m 34s There were no new javac warning messages. +1 javadoc 9m 38s There were no new javadoc warning messages. +1 release audit 0m 24s The applied patch does not increase the total number of release audit warnings. +1 checkstyle 1m 2s There were no new checkstyle issues. +1 whitespace 0m 0s The patch has no lines that end in whitespace. +1 install 1m 34s mvn install still works. +1 eclipse:eclipse 0m 33s The patch built with eclipse:eclipse. +1 findbugs 1m 50s The patch does not introduce any new Findbugs (version 3.0.0) warnings. +1 common tests 22m 9s Tests passed in hadoop-common.     61m 18s   Subsystem Report/Notes Patch URL http://issues.apache.org/jira/secure/attachment/12743169/HADOOP-12172.001.patch Optional Tests javadoc javac unit findbugs checkstyle git revision trunk / 0e4b066 hadoop-common test log https://builds.apache.org/job/PreCommit-HADOOP-Build/7131/artifact/patchprocess/testrun_hadoop-common.txt Test Results https://builds.apache.org/job/PreCommit-HADOOP-Build/7131/testReport/ Java 1.7.0_55 uname Linux asf902.gq1.ygridcore.net 3.13.0-36-lowlatency #63-Ubuntu SMP PREEMPT Wed Sep 3 21:56:12 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux Console output https://builds.apache.org/job/PreCommit-HADOOP-Build/7131/console This message was automatically generated.
        Hide
        brahmareddy Brahma Reddy Battula added a comment -

        Nice Catch Chris Nauroth,,+1 (non-binding).

        Show
        brahmareddy Brahma Reddy Battula added a comment - Nice Catch Chris Nauroth ,,+1 (non-binding).
        Hide
        cnauroth Chris Nauroth added a comment -

        Yi and Brahma, thank you for the code reviews. I have committed this to trunk and branch-2.

        The patch doesn't appear to include any new or modified tests.

        The functionality was covered by existing unit tests. I did manual testing by inspecting the HDFS audit log to confirm that this change reduced the number of RPC calls.

        Show
        cnauroth Chris Nauroth added a comment - Yi and Brahma, thank you for the code reviews. I have committed this to trunk and branch-2. The patch doesn't appear to include any new or modified tests. The functionality was covered by existing unit tests. I did manual testing by inspecting the HDFS audit log to confirm that this change reduced the number of RPC calls.
        Hide
        hudson Hudson added a comment -

        FAILURE: Integrated in Hadoop-trunk-Commit #8110 (See https://builds.apache.org/job/Hadoop-trunk-Commit/8110/)
        HADOOP-12172. FsShell mkdir -p makes an unnecessary check for the existence of the parent. Contributed by Chris Nauroth. (cnauroth: rev f3796224bfdfd88e2428cc8a9915bdfdc62b48f3)

        • hadoop-common-project/hadoop-common/CHANGES.txt
        • hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/shell/Mkdir.java
        Show
        hudson Hudson added a comment - FAILURE: Integrated in Hadoop-trunk-Commit #8110 (See https://builds.apache.org/job/Hadoop-trunk-Commit/8110/ ) HADOOP-12172 . FsShell mkdir -p makes an unnecessary check for the existence of the parent. Contributed by Chris Nauroth. (cnauroth: rev f3796224bfdfd88e2428cc8a9915bdfdc62b48f3) hadoop-common-project/hadoop-common/CHANGES.txt hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/shell/Mkdir.java
        Hide
        hudson Hudson added a comment -

        FAILURE: Integrated in Hadoop-Yarn-trunk-Java8 #246 (See https://builds.apache.org/job/Hadoop-Yarn-trunk-Java8/246/)
        HADOOP-12172. FsShell mkdir -p makes an unnecessary check for the existence of the parent. Contributed by Chris Nauroth. (cnauroth: rev f3796224bfdfd88e2428cc8a9915bdfdc62b48f3)

        • hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/shell/Mkdir.java
        • hadoop-common-project/hadoop-common/CHANGES.txt
        Show
        hudson Hudson added a comment - FAILURE: Integrated in Hadoop-Yarn-trunk-Java8 #246 (See https://builds.apache.org/job/Hadoop-Yarn-trunk-Java8/246/ ) HADOOP-12172 . FsShell mkdir -p makes an unnecessary check for the existence of the parent. Contributed by Chris Nauroth. (cnauroth: rev f3796224bfdfd88e2428cc8a9915bdfdc62b48f3) hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/shell/Mkdir.java hadoop-common-project/hadoop-common/CHANGES.txt
        Hide
        hudson Hudson added a comment -

        SUCCESS: Integrated in Hadoop-Yarn-trunk #976 (See https://builds.apache.org/job/Hadoop-Yarn-trunk/976/)
        HADOOP-12172. FsShell mkdir -p makes an unnecessary check for the existence of the parent. Contributed by Chris Nauroth. (cnauroth: rev f3796224bfdfd88e2428cc8a9915bdfdc62b48f3)

        • hadoop-common-project/hadoop-common/CHANGES.txt
        • hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/shell/Mkdir.java
        Show
        hudson Hudson added a comment - SUCCESS: Integrated in Hadoop-Yarn-trunk #976 (See https://builds.apache.org/job/Hadoop-Yarn-trunk/976/ ) HADOOP-12172 . FsShell mkdir -p makes an unnecessary check for the existence of the parent. Contributed by Chris Nauroth. (cnauroth: rev f3796224bfdfd88e2428cc8a9915bdfdc62b48f3) hadoop-common-project/hadoop-common/CHANGES.txt hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/shell/Mkdir.java
        Hide
        hudson Hudson added a comment -

        FAILURE: Integrated in Hadoop-Mapreduce-trunk-Java8 #244 (See https://builds.apache.org/job/Hadoop-Mapreduce-trunk-Java8/244/)
        HADOOP-12172. FsShell mkdir -p makes an unnecessary check for the existence of the parent. Contributed by Chris Nauroth. (cnauroth: rev f3796224bfdfd88e2428cc8a9915bdfdc62b48f3)

        • hadoop-common-project/hadoop-common/CHANGES.txt
        • hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/shell/Mkdir.java
        Show
        hudson Hudson added a comment - FAILURE: Integrated in Hadoop-Mapreduce-trunk-Java8 #244 (See https://builds.apache.org/job/Hadoop-Mapreduce-trunk-Java8/244/ ) HADOOP-12172 . FsShell mkdir -p makes an unnecessary check for the existence of the parent. Contributed by Chris Nauroth. (cnauroth: rev f3796224bfdfd88e2428cc8a9915bdfdc62b48f3) hadoop-common-project/hadoop-common/CHANGES.txt hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/shell/Mkdir.java
        Hide
        hudson Hudson added a comment -

        FAILURE: Integrated in Hadoop-Hdfs-trunk-Java8 #234 (See https://builds.apache.org/job/Hadoop-Hdfs-trunk-Java8/234/)
        HADOOP-12172. FsShell mkdir -p makes an unnecessary check for the existence of the parent. Contributed by Chris Nauroth. (cnauroth: rev f3796224bfdfd88e2428cc8a9915bdfdc62b48f3)

        • hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/shell/Mkdir.java
        • hadoop-common-project/hadoop-common/CHANGES.txt
        Show
        hudson Hudson added a comment - FAILURE: Integrated in Hadoop-Hdfs-trunk-Java8 #234 (See https://builds.apache.org/job/Hadoop-Hdfs-trunk-Java8/234/ ) HADOOP-12172 . FsShell mkdir -p makes an unnecessary check for the existence of the parent. Contributed by Chris Nauroth. (cnauroth: rev f3796224bfdfd88e2428cc8a9915bdfdc62b48f3) hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/shell/Mkdir.java hadoop-common-project/hadoop-common/CHANGES.txt
        Hide
        hudson Hudson added a comment -

        SUCCESS: Integrated in Hadoop-Hdfs-trunk #2173 (See https://builds.apache.org/job/Hadoop-Hdfs-trunk/2173/)
        HADOOP-12172. FsShell mkdir -p makes an unnecessary check for the existence of the parent. Contributed by Chris Nauroth. (cnauroth: rev f3796224bfdfd88e2428cc8a9915bdfdc62b48f3)

        • hadoop-common-project/hadoop-common/CHANGES.txt
        • hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/shell/Mkdir.java
        Show
        hudson Hudson added a comment - SUCCESS: Integrated in Hadoop-Hdfs-trunk #2173 (See https://builds.apache.org/job/Hadoop-Hdfs-trunk/2173/ ) HADOOP-12172 . FsShell mkdir -p makes an unnecessary check for the existence of the parent. Contributed by Chris Nauroth. (cnauroth: rev f3796224bfdfd88e2428cc8a9915bdfdc62b48f3) hadoop-common-project/hadoop-common/CHANGES.txt hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/shell/Mkdir.java
        Hide
        hudson Hudson added a comment -

        FAILURE: Integrated in Hadoop-Mapreduce-trunk #2192 (See https://builds.apache.org/job/Hadoop-Mapreduce-trunk/2192/)
        HADOOP-12172. FsShell mkdir -p makes an unnecessary check for the existence of the parent. Contributed by Chris Nauroth. (cnauroth: rev f3796224bfdfd88e2428cc8a9915bdfdc62b48f3)

        • hadoop-common-project/hadoop-common/CHANGES.txt
        • hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/shell/Mkdir.java
        Show
        hudson Hudson added a comment - FAILURE: Integrated in Hadoop-Mapreduce-trunk #2192 (See https://builds.apache.org/job/Hadoop-Mapreduce-trunk/2192/ ) HADOOP-12172 . FsShell mkdir -p makes an unnecessary check for the existence of the parent. Contributed by Chris Nauroth. (cnauroth: rev f3796224bfdfd88e2428cc8a9915bdfdc62b48f3) hadoop-common-project/hadoop-common/CHANGES.txt hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/shell/Mkdir.java

          People

          • Assignee:
            cnauroth Chris Nauroth
            Reporter:
            cnauroth Chris Nauroth
          • Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development