Return-Path: Delivered-To: apmail-lucene-hadoop-dev-archive@locus.apache.org Received: (qmail 37066 invoked from network); 17 Mar 2006 22:01:54 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 17 Mar 2006 22:01:54 -0000 Received: (qmail 79033 invoked by uid 500); 17 Mar 2006 22:01:54 -0000 Delivered-To: apmail-lucene-hadoop-dev-archive@lucene.apache.org Received: (qmail 79013 invoked by uid 500); 17 Mar 2006 22:01:54 -0000 Mailing-List: contact hadoop-dev-help@lucene.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: hadoop-dev@lucene.apache.org Delivered-To: mailing list hadoop-dev@lucene.apache.org Received: (qmail 79004 invoked by uid 99); 17 Mar 2006 22:01:53 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 17 Mar 2006 14:01:53 -0800 X-ASF-Spam-Status: No, hits=0.0 required=10.0 tests= X-Spam-Check-By: apache.org Received: from [192.87.106.226] (HELO ajax.apache.org) (192.87.106.226) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 17 Mar 2006 14:01:53 -0800 Received: from ajax (localhost.localdomain [127.0.0.1]) by ajax.apache.org (Postfix) with ESMTP id 21455D49FE for ; Fri, 17 Mar 2006 22:01:32 +0000 (GMT) Message-ID: <1746766779.1142632892086.JavaMail.jira@ajax> Date: Fri, 17 Mar 2006 22:01:32 +0000 (GMT) From: "Sameer Paranjpye (JIRA)" To: hadoop-dev@lucene.apache.org Subject: [jira] Commented: (HADOOP-87) SequenceFile performance degrades substantially compression is on and large values are encountered In-Reply-To: <210558648.1142549462664.JavaMail.jira@ajax> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N [ http://issues.apache.org/jira/browse/HADOOP-87?page=comments#action_12370892 ] Sameer Paranjpye commented on HADOOP-87: ---------------------------------------- The commented out code is spurious and should be cut. As for the multiple append methods, it's hard to implement the new append methods functionality in terms of the old method, the reverse is doable with a small modification. The old append method expects takes a single array which contains both the key and value. So if the new methods signature was changed to: append(byte[] key, int keystart, int keylen, byte[] val, int valstart, int vallen) the old one could be implemented in terms of the new private one. I dislike methods with this many parameters but don't have a better idea. > SequenceFile performance degrades substantially compression is on and large values are encountered > -------------------------------------------------------------------------------------------------- > > Key: HADOOP-87 > URL: http://issues.apache.org/jira/browse/HADOOP-87 > Project: Hadoop > Type: Improvement > Components: io > Versions: 0.1 > Reporter: Sameer Paranjpye > Fix For: 0.1 > Attachments: hadoop_87.fix > > The code snippet in quesiton is: > if (deflateValues) { > deflateIn.reset(); > val.write(deflateIn); > deflater.reset(); > deflater.setInput(deflateIn.getData(), 0, deflateIn.getLength()); > deflater.finish(); > while (!deflater.finished()) { > int count = deflater.deflate(deflateOut); > buffer.write(deflateOut, 0, count); > } > } else { > > A couple of issues with this code: > 1. The value is serialized to the 'deflateIn' buffer which is an instance of 'DataOutputBuffer', this grows as large as needed to store the serialized value and stays as large as the largest serialized value encountered. If, for instance a stream has a single 8MB value followed by several 8KB values the size of the buffer stays at 8MB. The problem is that the *entire* 8MB buffer is always copied over the JNI boundary regardless of the size of the value. We've observed this over several runs where compression performance degrades by a couple of orders of magnitude when a very large value is encountered. Shrinking the buffer fixes the problem. > 2. Data is copied lots of times. First the value is serialized into 'deflateIn'. Second, the value is copied over the JNI boundary in *every* iteration of the while loop. Third, the compressed data is copied piecemeal into 'deflateOut'. Finally, it is appended to 'buffer'. > Proposed fix: > 1. Don't let big buffers persist. Allow 'deflateIn' to grow to a *persistent* maximum reasonable size, say 64KB. If a larger value is encountered, grow the buffer in order to process the value, then shrink it back to the maximum size. To do this, we add a 'reset' method which takes a buffer size. > 2. Don't use a loop to deflate. The maximum size of the output can be determined by 'maxOutputSize = inputSize * 1.01 + 12'. This is the maximum output size that zlib will produce. We allocate a large enough output buffer and compress everything in 1 pass. The output buffer, of course, needs to shrink as well. -- This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira