From: Andres Freund <andres@anarazel.de>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Add inlining support to LLVM JIT provider.
Date: Wed, 28 Mar 2018 20:20:58 +0000
Message-ID: <E1f1HZ4-0003yh-NE@gemulon.postgresql.org> (raw)
Add inlining support to LLVM JIT provider.
This provides infrastructure to allow JITed code to inline code
implemented in C. This e.g. can be postgres internal functions or
extension code.
This already speeds up long running queries, by allowing the LLVM
optimizer to optimize across function boundaries. The optimization
potential currently doesn't reach its full potential because LLVM
cannot optimize the FunctionCallInfoData argument fully away, because
it's allocated on the heap rather than the stack. Fixing that is
beyond what's realistic for v11.
To be able to do that, use CLANG to convert C code to LLVM bitcode,
and have LLVM build a summary for it. That bitcode can then be used to
to inline functions at runtime. For that the bitcode needs to be
installed. Postgres bitcode goes into $pkglibdir/bitcode/postgres,
extensions go into equivalent directories. PGXS has been modified so
that happens automatically if postgres has been compiled with LLVM
support.
Currently this isn't the fastest inline implementation, modules are
reloaded from disk during inlining. That's to work around an apparent
LLVM bug, triggering an apparently spurious error in LLVM assertion
enabled builds. Once that is resolved we can remove the superfluous
read from disk.
Docs will follow in a later commit containing docs for the whole JIT
feature.
Author: Andres Freund
Discussion: https://postgr.es/m/20170901064131.tazjxwus3k2w3ybh@alap3.anarazel.de
Branch
------
master
Details
-------
https://git.postgresql.org/pg/commitdiff/9370462e9a79755aea367c62eb0fef96f0c42258
Modified Files
--------------
src/Makefile.global.in | 34 +
src/backend/Makefile | 10 +
src/backend/common.mk | 6 +-
src/backend/jit/jit.c | 1 +
src/backend/jit/llvm/Makefile | 2 +-
src/backend/jit/llvm/llvmjit.c | 17 +-
src/backend/jit/llvm/llvmjit_inline.cpp | 877 ++++++++++++++++++++++++++
src/backend/optimizer/plan/planner.c | 3 +
src/backend/utils/misc/guc.c | 10 +
src/backend/utils/misc/postgresql.conf.sample | 3 +
src/include/jit/jit.h | 6 +-
src/include/jit/llvmjit.h | 1 +
src/makefiles/pgxs.mk | 26 +-
13 files changed, 988 insertions(+), 8 deletions(-)
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-committers@postgresql.org
Cc: andres@anarazel.de
Subject: Re: pgsql: Add inlining support to LLVM JIT provider.
In-Reply-To: <E1f1HZ4-0003yh-NE@gemulon.postgresql.org>
References: <E1f1HZ4-0003yh-NE@gemulon.postgresql.org>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox