Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bNnoK-0003A3-Jw for pgsql-hackers@arkaria.postgresql.org; Thu, 14 Jul 2016 21:04:44 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1bNnoJ-000554-7D for pgsql-hackers@arkaria.postgresql.org; Thu, 14 Jul 2016 21:04:43 +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 1bNnmw-0003Vl-Gy for pgsql-hackers@postgresql.org; Thu, 14 Jul 2016 21:03:18 +0000 Received: from gauss.credativ.com ([93.94.130.89]) by makus.postgresql.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.84_2) (envelope-from ) id 1bNnmt-00046o-50 for pgsql-hackers@postgresql.org; Thu, 14 Jul 2016 21:03:17 +0000 Received: from gauss.credativ.com (localhost [127.0.0.1]) by gauss.credativ.com (Postfix) with ESMTP id 230991B441E; Thu, 14 Jul 2016 23:03:12 +0200 (CEST) Received: from ex (ip-109-44-2-122.web.vodafone.de [109.44.2.122]) (using TLSv1 with cipher AES128-SHA (128/128 bits)) (No client certificate requested) (Authenticated sender: ase@gauss.credativ.com) by gauss.credativ.com (Postfix) with ESMTPSA id 9CA881B42FE; Thu, 14 Jul 2016 23:03:11 +0200 (CEST) From: Andreas Seltenreich To: Andres Freund Cc: pgsql-hackers@postgresql.org Subject: Re: Improving executor performance In-Reply-To: <20160714181710.sh4nt3ylzp3f55wy@alap3.anarazel.de> (Andres Freund's message of "Thu, 14 Jul 2016 11:17:10 -0700") References: <20160624232953.beub22r6yqux4gcp@alap3.anarazel.de> <20160714011850.bd5zhu35szle3n3c@alap3.anarazel.de> <878tx42j1o.fsf@credativ.de> <20160714181710.sh4nt3ylzp3f55wy@alap3.anarazel.de> User-Agent: Gnus/5.130012 (Ma Gnus v0.12) Emacs/24.4 (gnu/linux) Message-ID: <87r3aw0w6p.fsf@credativ.de> Date: Thu, 14 Jul 2016 23:03:10 +0200 MIME-Version: 1.0 Content-Type: text/plain X-Pg-Spam-Score: -1.9 (-) 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 Andres Freund writes: > The problem is that the previous form has a lot of ad-hoc analysis > strewn in. The interesting part is getting rid of all that. That's what > the new ExecInitExpr2() does. The target form can be both evaluated more > efficiently in the dispatch manner in the patch, and quite simply > converted to a JIT - without duplicating the analysis code. I did write > a small ad-hoc x86 jit, and it was really quite straightforward this > way. Ja, I see the advantage when doing ad-hoc-JIT compilation. > What did you do with JIT and expression evaluation? You basically just > replaced the toplevel ExprState note with a different evalfunc, pointing > into your code? That's the plan, yes. I'm sorry there's no publishable code yet on the the postgres side of things. Using libFirm[1], the plan is to. 1. Automatically generate Firm-IR for the static C code around expression evaluation as well operators in the system catalog. 2. Construct IR for expression trees (essentially all the function calls the executor would do). 3. Push libFirm's optimize button. At this stage, most of the dispatching goes away by inlining the calls including functions from the catalog implementing operators. 4. Generate code and replace the toplevel expression node with a funcall node. I did implement this recipe with a toy Forth interpreter to see whether libFirm was up to the job (Nobody's done JIT with libFirm before). The results were favorable[2]. Currently, a student at credativ is working on applying these techniques to postgres. regards, Andreas Footnotes: [1] http://libfirm.org/ [2] https://korte.credativ.com/~ase/firm-postgres-jit-forth.pdf -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers