Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cnult-0006YA-Em for pgsql-hackers@arkaria.postgresql.org; Tue, 14 Mar 2017 22:18:25 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1cnuls-0006P2-T2 for pgsql-hackers@arkaria.postgresql.org; Tue, 14 Mar 2017 22:18:24 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1cnukP-0003lG-Or for pgsql-hackers@postgresql.org; Tue, 14 Mar 2017 22:16:53 +0000 Received: from out1-smtp.messagingengine.com ([66.111.4.25]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1cnukM-0005hK-Vu for pgsql-hackers@postgresql.org; Tue, 14 Mar 2017 22:16:52 +0000 Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailout.nyi.internal (Postfix) with ESMTP id E74E320B31; Tue, 14 Mar 2017 18:16:49 -0400 (EDT) Received: from frontend1 ([10.202.2.160]) by compute5.internal (MEProxy); Tue, 14 Mar 2017 18:16:49 -0400 DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-me-sender :x-me-sender:x-sasl-enc:x-sasl-enc; s=smtpout; bh=OJdKN1520yes6E 2LHfqerUBogSU=; b=p/dFrrbOloqw0EOaOdmo+KHS+9Uv1W6HcLBIvkQb3yDy1V IWsx3D60A1Ua8Eh0Ws1FASHCq4GRFEvzwCEi4h+Ft5pHsQK7TkqSrhBuIUX5uCiv aNBCdC3xhtHn67vXhCkWtkWCI2TUhAuyg2cRXy514Ywe9jPhi5u9EdY0if8Kg= X-ME-Sender: X-Sasl-enc: NF3sTTpw8d7BMZ76GgXwlybIM8GSyiH81CvJesqFlNj8 1489529809 Received: from intern.anarazel.de (unknown [208.72.138.107]) by mail.messagingengine.com (Postfix) with ESMTPA id B3A187E168; Tue, 14 Mar 2017 18:16:49 -0400 (EDT) Date: Tue, 14 Mar 2017 15:16:48 -0700 From: Andres Freund To: Douglas Doole Cc: Heikki Linnakangas , Tomas Vondra , pgsql-hackers@postgresql.org Subject: Re: WIP: Faster Expression Processing v4 Message-ID: <20170314221648.jrcgh5n7ld4ej2o7@alap3.anarazel.de> References: <20170307030137.lpo4japv5oqgbqpz@alap3.anarazel.de> <2090fd00-4dec-7b42-f700-64308958504c@2ndquadrant.com> <20170313080351.4g5oubxcj4xj5y7t@alap3.anarazel.de> <20170314065259.ffef4tfhgbsaieoe@alap3.anarazel.de> <69b7bb0e-8dab-3d39-1a89-3c6ab6409f64@iki.fi> <20170314173137.5r5jtgkgx6siuwsy@alap3.anarazel.de> <58f9a171-edd7-e07d-3e21-52a451cd7c58@iki.fi> <20170314185045.tpqddwrmedgknsqe@alap3.anarazel.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Pg-Spam-Score: -2.6 (--) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-hackers Precedence: bulk Sender: pgsql-hackers-owner@postgresql.org Hi, On 2017-03-14 22:03:45 +0000, Douglas Doole wrote: > I do have one observation based on my experiments with your first version > of the code. In my tests, I found that expression init becomes a lot more > expensive in this new model. (That's neither a surprise, nor a > concern.) I suspect that's to a good degree because back then it'd often end up trying the "new" stuff, but then fall back to the old machinery due to unsupported operations. Which isn't a concern anymore, because now there's full coverage. Otherwise the cost aren't, according to my measurements, higher than before, excepting that some stuff that happened at execution time is now happening during initialization. > In particular, the function ExprEvalPushStep() is quite hot. In my > code I made the following changes: > > * Declare ExprEvalPushStep() "inline". > * Remove the "if (es->steps_alloc == 0)" condition > from ExprEvalPushStep(). > * In ExecInitExpr(), add: > state->steps_alloc = 16; > state->steps = palloc(sizeof(ExprEvalStep) * es->steps_alloc); > > I found that this cut the cost of initializing the expression by about 20%. > (Of course, that was on version 1 of your code, so the benefit may well be > different now.) Hm. Right now ExprState's are allocated in several places - but we could easily move that to a central place. Have a bit of a hard time seing that that branch during *initialization* time is that expensive, especially given that previously we allocated a lot of memory separately too. > On Tue, Mar 14, 2017 at 11:51 AM Andres Freund wrote: > > > > Hmm. Could we make the instructions variable size? It would allow packing > > > the small instructions even more tight, and we wouldn't need to obsess > > over > > > a particular maximum size for more complicated instructions. > > > > That makes jumps a lot more complicated. I'd experimented with it and > > given it up as "not worth it". > Back when I was at IBM, I spent a lot of time doing stuff like this. If you > want to commit with the fixed size arrays, I'm happy to volunteer to look > at packing it tighter as a follow-on piece of work. (It was already on my > list of things to try anyhow.) Yea, I think experimenting with that is a good idea. I just think this is complicated enough, and I don't want to add a whole lot more complexity for very debatable benefit. > > If we were to try to do so, we'd also > > not like storing the pointer and enum variants both, since it'd again > > would reduce the density. > From my experience, it's worth the small loss in density to carry around > both the pointer and the enum - it makes debugging so much easier. I found it annoying enough to print the instruction itself, due to the union - so printing the opcode using a function isn't too bad... Greetings, Andres Freund -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers