Return-Path: Delivered-To: apmail-hadoop-core-dev-archive@www.apache.org Received: (qmail 43615 invoked from network); 16 May 2008 20:44:20 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 16 May 2008 20:44:20 -0000 Received: (qmail 89135 invoked by uid 500); 16 May 2008 20:44:20 -0000 Delivered-To: apmail-hadoop-core-dev-archive@hadoop.apache.org Received: (qmail 89102 invoked by uid 500); 16 May 2008 20:44:20 -0000 Mailing-List: contact core-dev-help@hadoop.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: core-dev@hadoop.apache.org Delivered-To: mailing list core-dev@hadoop.apache.org Received: (qmail 89091 invoked by uid 99); 16 May 2008 20:44:20 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 16 May 2008 13:44:20 -0700 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.140] (HELO brutus.apache.org) (140.211.11.140) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 16 May 2008 20:43:34 +0000 Received: from brutus (localhost [127.0.0.1]) by brutus.apache.org (Postfix) with ESMTP id AF1C5234C114 for ; Fri, 16 May 2008 13:43:55 -0700 (PDT) Message-ID: <6718708.1210970635716.JavaMail.jira@brutus> Date: Fri, 16 May 2008 13:43:55 -0700 (PDT) From: "Tsz Wo (Nicholas), SZE (JIRA)" To: core-dev@hadoop.apache.org Subject: [jira] Commented: (HADOOP-3398) ReduceTask::closestPowerOf2 is inefficient In-Reply-To: <1258984342.1210890055654.JavaMail.jira@brutus> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked by ClamAV on apache.org [ https://issues.apache.org/jira/browse/HADOOP-3398?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12597606#action_12597606 ] Tsz Wo (Nicholas), SZE commented on HADOOP-3398: ------------------------------------------------ Mathematically, we should throw an exception (Math.log() returns NaN for -ve numbers and -infinity for 0) when value <= 0 since logarithm is undefined. > ReduceTask::closestPowerOf2 is inefficient > ------------------------------------------ > > Key: HADOOP-3398 > URL: https://issues.apache.org/jira/browse/HADOOP-3398 > Project: Hadoop Core > Issue Type: Bug > Components: mapred > Reporter: Chris Douglas > Assignee: Chris Douglas > Priority: Trivial > Fix For: 0.18.0 > > Attachments: 3398-0.patch, 3398-1.patch, 3398-2.patch > > > ReduceTask computes the "closest power of 2" using loops > {code} > private static int getClosestPowerOf2(int value) { > int power = 0; > int approx = 1; > while (approx < value) { > ++power; > approx = (approx << 1); > } > if ((value - (approx >> 1)) < (approx - value)) { > --power; > } > return power; > } > {code} > This could be improved. -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online.