Return-Path: Delivered-To: apmail-incubator-lucy-dev-archive@www.apache.org Received: (qmail 41668 invoked from network); 9 Mar 2011 05:43:03 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 9 Mar 2011 05:43:03 -0000 Received: (qmail 22485 invoked by uid 500); 9 Mar 2011 05:43:03 -0000 Delivered-To: apmail-incubator-lucy-dev-archive@incubator.apache.org Received: (qmail 22422 invoked by uid 500); 9 Mar 2011 05:43:02 -0000 Mailing-List: contact lucy-dev-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: lucy-dev@incubator.apache.org Delivered-To: mailing list lucy-dev@incubator.apache.org Received: (qmail 22414 invoked by uid 99); 9 Mar 2011 05:43:02 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 09 Mar 2011 05:43:02 +0000 X-ASF-Spam-Status: No, hits=-0.0 required=5.0 tests=SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: local policy) Received: from [68.116.39.62] (HELO rectangular.com) (68.116.39.62) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 09 Mar 2011 05:42:58 +0000 Received: from marvin by rectangular.com with local (Exim 4.69) (envelope-from ) id 1PxC9Q-00067F-9Y for lucy-dev@incubator.apache.org; Tue, 08 Mar 2011 21:41:36 -0800 Date: Tue, 8 Mar 2011 21:41:36 -0800 From: Marvin Humphrey To: lucy-dev@incubator.apache.org Message-ID: <20110309054136.GA23459@rectangular.com> References: <20110303030834.GB5339@rectangular.com> <20110303063001.GA5707@rectangular.com> <20110307050300.GB23513@rectangular.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.18 (2008-05-17) Subject: Re: [lucy-dev] Host overriding of all non-final methods On Tue, Mar 08, 2011 at 01:10:32PM -0800, Nathan Kurz wrote: > Responding to myself, I just learned that GCC now supports Link Time > Optimization, which might make this sort of inter-module inlining > practical: . I'd known > that it was possible with LLVM: > , but not that it had > landed in GCC. Great stuff! Thanks for passing it along. Ironically, the availability of link-time optimization suggests that we should preserve the "final" keyword in Clownfish. >From what I gather, really fancy JIT inlining involves discovering all possible paths in a class hierarchy when a non-final method is invoked, and creating multiple inlined paths at the site of the invocation. I would be shocked if LLVM or GCC were able to figure out our virtual method invocation scheme well enough to discover such possibilities. The theory is similar, but those compilers wouldn't know to look. If I understand correctly, what LTO can do for us is associate a symbol with a small body of compiled code and inline that compiled code at the site of an invocation. That's possible if we alias method symbols to real function symbols, but not if the method symbols remain vtable lookup invocations as they are now. The Get() method on Lucy::Index::BitVecDelDocs returns true if the bit at "tick" is set and false otherwise. Here's what the Clownfish compiler currently produces for it: extern size_t Lucy_BitVecDelDocs_Get_OFFSET; static CHY_INLINE chy_bool_t Lucy_BitVecDelDocs_Get(const lucy_BitVecDelDocs *self, uint32_t tick) { char *const method_address = *(char**)self + Lucy_BitVecDelDocs_Get_OFFSET; const lucy_BitVec_get_t method = *((lucy_BitVec_get_t*)method_address); return method((lucy_BitVector*)self, tick); } If we change BitVecDelDocs to be a "final" class, the Clownfish compiler instead aliases Lucy_BitVecDelDocs_Get() to the function lucy_BitVec_get(): #define Lucy_BitVecDelDocs_Get(self, tick) \ lucy_BitVec_get((lucy_BitVector*)self, tick) The function body at lucy_BitVec_get() is small and would be an ideal candidate for inlining. It's a bottleneck while iterating over posting lists. I think GCC or LLVM has a decent shot at figuring out that it should inline the aliased function. I don't think there's any hope that the virtual method call will be optimized in the same manner. > This might make creating a benchmark easy enough that one can see what (if > anything) one is missing. True, that! Marvin Humphrey