Return-Path: X-Original-To: apmail-hadoop-common-issues-archive@minotaur.apache.org Delivered-To: apmail-hadoop-common-issues-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 3738018259 for ; Wed, 1 Jul 2015 22:49:05 +0000 (UTC) Received: (qmail 30893 invoked by uid 500); 1 Jul 2015 22:49:04 -0000 Delivered-To: apmail-hadoop-common-issues-archive@hadoop.apache.org Received: (qmail 30833 invoked by uid 500); 1 Jul 2015 22:49:04 -0000 Mailing-List: contact common-issues-help@hadoop.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: common-issues@hadoop.apache.org Delivered-To: mailing list common-issues@hadoop.apache.org Received: (qmail 30718 invoked by uid 99); 1 Jul 2015 22:49:04 -0000 Received: from arcas.apache.org (HELO arcas.apache.org) (140.211.11.28) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 01 Jul 2015 22:49:04 +0000 Date: Wed, 1 Jul 2015 22:49:04 +0000 (UTC) From: "Chris Nauroth (JIRA)" To: common-issues@hadoop.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Updated] (HADOOP-12172) FsShell mkdir -p makes an unnecessary check for the existence of the parent. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 [ https://issues.apache.org/jira/browse/HADOOP-12172?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Chris Nauroth updated HADOOP-12172: ----------------------------------- Attachment: HADOOP-12172.001.patch 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. > FsShell mkdir -p makes an unnecessary check for the existence of the parent. > ---------------------------------------------------------------------------- > > Key: HADOOP-12172 > URL: https://issues.apache.org/jira/browse/HADOOP-12172 > Project: Hadoop Common > Issue Type: Improvement > Components: fs > Reporter: Chris Nauroth > Assignee: Chris Nauroth > Priority: Minor > Attachments: HADOOP-12172.001.patch > > > 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. -- This message was sent by Atlassian JIRA (v6.3.4#6332)