Return-Path: X-Original-To: apmail-hadoop-hdfs-user-archive@minotaur.apache.org Delivered-To: apmail-hadoop-hdfs-user-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id D2C66DADD for ; Fri, 2 Nov 2012 03:15:16 +0000 (UTC) Received: (qmail 79513 invoked by uid 500); 2 Nov 2012 03:15:11 -0000 Delivered-To: apmail-hadoop-hdfs-user-archive@hadoop.apache.org Received: (qmail 79367 invoked by uid 500); 2 Nov 2012 03:15:10 -0000 Mailing-List: contact user-help@hadoop.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: user@hadoop.apache.org Delivered-To: mailing list user@hadoop.apache.org Received: (qmail 79328 invoked by uid 99); 2 Nov 2012 03:15:08 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 02 Nov 2012 03:15:08 +0000 X-ASF-Spam-Status: No, hits=-0.7 required=5.0 tests=RCVD_IN_DNSWL_LOW,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of harsh@cloudera.com designates 209.85.210.176 as permitted sender) Received: from [209.85.210.176] (HELO mail-ia0-f176.google.com) (209.85.210.176) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 02 Nov 2012 03:15:00 +0000 Received: by mail-ia0-f176.google.com with SMTP id h11so2745366iae.35 for ; Thu, 01 Nov 2012 20:14:40 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type:x-gm-message-state; bh=8JTLvf9CorrSBjA6JI4+spu0zBEntFDzOGCwSESsAFU=; b=Ka3EolQfvL6CRRTUJLomYXjqGN7Ev4sAPdLJJ5mI/KmU+rFBIVOlEh39zQH0EO/IvM jpHB9IB+e1Bnrbxp9odIG06ti4cf8YVjMIcueS0u8BXbOEfvCrT6KTW2pc78r9TnPSiP 8KLzDdvv75aWCb+yUSaPBGnPl6SHcyAUnuEm5D1fYwkcxmIfuXOIMzz51myz4MNfntxz cXrCORQOU90FtSvsUv3Hr6p4Sx4aftj65wffBtFr+ryVMpR++KGnj3V/XU7jFYIuDsAi yTmUNZ3XmdL+BjHLR89H2IGzp+Cq+InYZOLwoWxaugK5LbWEsgQokIVjIsz3ttHL8RNW ykCw== Received: by 10.50.202.3 with SMTP id ke3mr465173igc.49.1351826080004; Thu, 01 Nov 2012 20:14:40 -0700 (PDT) MIME-Version: 1.0 Received: by 10.64.27.8 with HTTP; Thu, 1 Nov 2012 20:14:19 -0700 (PDT) In-Reply-To: References: From: Harsh J Date: Fri, 2 Nov 2012 08:44:19 +0530 Message-ID: Subject: Re: OutputFormat and Reduce Task To: user@hadoop.apache.org Content-Type: text/plain; charset=ISO-8859-1 X-Gm-Message-State: ALoCoQnStKUnLHIuhkjZPxZAWwrST7nRnMEdf5jKpKosztXKRTqSZhK0Sar79gFKgwV5EMY6SjJX X-Virus-Checked: Checked by ClamAV on apache.org Hi Dhruv, Inline. On Fri, Nov 2, 2012 at 4:15 AM, Dhruv wrote: > I'm trying to optimize the performance of my OutputFormat's implementation. > I'm doing things similar to HBase's TableOutputFormat--sending the reducer's > output to a distributed k-v store. So, the context.write() call basically > winds up doing a Put() on the store. > > Although I haven't profiled, a sequence of thread dumps on the reduce tasks > reveal that the threads are RUNNABLE and hanging out in the put() and its > subsequent method calls. So, I proceeded to decouple these two by > implementing the producer (context.write()) consumer (RecordWriter.write()) > pattern using ExecutorService. With HBase involved, this is only partly correct. The HTable API, which regular TableOutputFormat uses, provides a "AutoFlush" option which if disabled, begins to buffer writes to regionservers instead of doing a flush of Puts/Deletes at every single invoke. The TableOutputFormat by default does disable AutoFlush, to provide this behavior. Read more on that at http://hbase.apache.org/apidocs/org/apache/hadoop/hbase/client/HTable.html#setAutoFlush(boolean,%20boolean) and/or in Lars' book, "HBase: The Definitive Guide". > My understanding is that Context.write() calls RecordWriter.write() and that > these two are synchronous calls. The first will block until the second > method completes.Each reduce phase blocks until the context.write() > finishes, so the next reduce on the next key also blocks, making things run > slow in my case. Is this correct? Given the above explanation, this is untrue if HBase's TableOutputFormat is involved, but true otherwise for general FS interacting OFs. > Does this mean that OutputFormat is > instantiated once by the TaskTracker for the Job's reduce logic and all keys > operated on by the reducers get the same instance of the OutputFormat. Or, > is it that for each key operated by the reducer, a new OutputFormat is > instantiated? The TaskTracker is a service daemon that does not execute any user-code. Only a single OutputFormat object is instantiated in a single Task. The RecordWriter wrapped in it too is only instantiated once per Task. > Thanks, > Dhruv -- Harsh J