Return-Path: Delivered-To: apmail-db-derby-dev-archive@www.apache.org Received: (qmail 41665 invoked from network); 26 Nov 2006 18:12:17 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 26 Nov 2006 18:12:17 -0000 Received: (qmail 67517 invoked by uid 500); 26 Nov 2006 18:12:25 -0000 Delivered-To: apmail-db-derby-dev-archive@db.apache.org Received: (qmail 67480 invoked by uid 500); 26 Nov 2006 18:12:25 -0000 Mailing-List: contact derby-dev-help@db.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: Delivered-To: mailing list derby-dev@db.apache.org Received: (qmail 67471 invoked by uid 99); 26 Nov 2006 18:12:25 -0000 Received: from herse.apache.org (HELO herse.apache.org) (140.211.11.133) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 26 Nov 2006 10:12:25 -0800 X-ASF-Spam-Status: No, hits=0.0 required=10.0 tests=UNPARSEABLE_RELAY X-Spam-Check-By: apache.org Received-SPF: pass (herse.apache.org: local policy) Received: from [192.18.1.36] (HELO gmp-ea-fw-1.sun.com) (192.18.1.36) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 26 Nov 2006 10:12:11 -0800 Received: from d1-emea-09.sun.com (d1-emea-09.sun.com [192.18.2.119]) by gmp-ea-fw-1.sun.com (8.13.6+Sun/8.12.9) with ESMTP id kAQIBl6g018317 for ; Sun, 26 Nov 2006 18:11:47 GMT Received: from conversion-daemon.d1-emea-09.sun.com by d1-emea-09.sun.com (Sun Java System Messaging Server 6.2-6.01 (built Apr 3 2006)) id <0J9C00G01NUZ7X00@d1-emea-09.sun.com> (original mail from Knut.Hatlen@Sun.COM) for derby-dev@db.apache.org; Sun, 26 Nov 2006 18:11:47 +0000 (GMT) Received: from localhost ([129.159.115.202]) by d1-emea-09.sun.com (Sun Java System Messaging Server 6.2-6.01 (built Apr 3 2006)) with ESMTPSA id <0J9C00MKBNVM09A8@d1-emea-09.sun.com> for derby-dev@db.apache.org; Sun, 26 Nov 2006 18:11:47 +0000 (GMT) Date: Sun, 26 Nov 2006 19:11:38 +0100 From: Knut Anders Hatlen Subject: Re: ArrayInputStream and performance In-reply-to: Sender: Knut.Hatlen@Sun.COM To: derby-dev@db.apache.org Message-id: Organization: Sun Microsystems MIME-version: 1.0 Content-type: text/plain; charset=us-ascii Content-transfer-encoding: 7BIT References: User-Agent: Gnus/5.110006 (No Gnus v0.6) Emacs/21.4 (usg-unix-v) X-Virus-Checked: Checked by ClamAV on apache.org Dyre.Tjeldvoll@Sun.COM writes: > Knut Anders Hatlen writes: > >> I can't answer your question, but I will add that I find much of the >> code that uses ArrayInputStream very confusing. ArrayInputStream is >> supposed to wrap a byte array to provide encapsulation and easy access >> to the data through the InputStream interface. However, many (most?) >> of the callers inline the accesses to the data (presumably for >> performance reasons), so we end up with lots of methods looking like >> this: >> >> public X readSomething(ArrayInputStream ais, byte[] data, int offset...) { >> // lots of direct manipulation of the byte array >> // ... >> // ... >> // ... >> // finally, make sure that the state of the stream is brought to a >> // consistent state: >> ais.setPosition(offset + numberOfManipulatedBytes); >> } >> >> Both the byte array and the offset are part of the ArrayInputStream >> class, so having all three of them in the parameter list feels a bit >> ugly. And if we need to manipulate the internal state directly that >> often, perhaps an InputStream is not the best data structure in the >> first place? > > I tend to agree. I just finished running derbyall with the checks > replaced by ASSERTs and I saw no failures. So unless I hear strong > objections I'll create a Jira for this change. FYI, I just ran the DERBY-1961 test clients and traced them with a DTrace script that printed how often each method was called. For the join client, ArrayInputStream.setPosition() was the most frequently called method (43837.7 calls/tx). For the single-record select client, it was third (58.4 calls/tx), only beaten by Object.() and DDMWriter.ensureLength(). I think this means that setPosition() is the engine method that is most frequently called, at least in read-mostly transactions. ArrayInputStream.setLimit() also appeared near the top of the list. See http://wiki.apache.org/db-derby/Derby1961MethodCalls for the details. -- Knut Anders