Re: Improving executor performance

From: Andreas Seltenreich <seltenreich(at)gmx(dot)de>
To: Andres Freund <andres(at)anarazel(dot)de>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: Improving executor performance
Date: 2016-07-14 21:03:10
Message-ID: 87r3aw0w6p.fsf@credativ.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

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

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Andres Freund 2016-07-14 21:09:59 Re: Improving executor performance
Previous Message Andres Freund 2016-07-14 18:53:38 Re: [PERFORM] 9.4 -> 9.5 regression with queries through pgbouncer on RHEL 6