JIT compiling with LLVM v11
Andres Freund <andres@anarazel.de>
Hi,
I've pushed a revised version of my JIT patchset.
The git tree is at
https://git.postgresql.org/git/users/andresfreund/postgres.git
in the jit branch
https://git.postgresql.org/gitweb/?p=users/andresfreund/postgres.git;a=shortlog;h=refs/heads/jit
Biggest changes:
- LLVM 3.9 - master are now supported. This includes a good chunk of
work by Pierre Ducroquet.
Doing so I found that the patches Pierre provided didn't work when a
query was expensive enough to warrant inlining. Turns out LLVM < 5
can't combine the summaries of multiple thin module summaries.
But that actually turned out to be a good thing, because it made me
think about symbol resolution preferences. Previously it was basically
arbitrary whether a function with conflicting names would be choosen
from core postgres or one of the extension libs providing it.
This is now rewritten so we don't build a combined module summary for
core postgres and extensions at backend start. Instead summaries for
core pg and extensions are loaded separately, and the correct one for
a symbol is used.
- Functions in extension libraries are now not referred to with their C
symbol in LLVM IR, instead we generate a fictious symbol that includes
the library path. E.g. hstore's hstore_from_record is now referenced as
@"pgextern.$libdir/hstore.hstore_from_record".
Both symbol resolution and inlining knows how to properly resolve
those.
- As hinted to above, the inlining support has evolved
considerably. Instead of a combined index built at backend start we
now have individual indexes for each extension / shlib. Symbols are
searched with a search path (internal functions just in the 'postgres'
index, for extensions it's main 'postgres', 'extension'), and symbols
that explicitly reference a function are just looked up within that
extension.
This has the nice advantage that we don't have to process indexes for
extensions that aren't used, which in turn means that extensions can
be installed on the system level while a backend is running, and
JITing will work even for old backends once the extension is created
(or rather functions in it).
Additionally the inline costing logic has improved, the super verbose
logging is #ifdef'ed out ('ilog' wrapper that's just (void) 0).
- The installation of bitcode is now a nice separate make function. pgxs
(including contrib's kinda use of pgxs) now automatically generate &
install bitcode when the server was compiled --with-llvm.
I learned some about make I didn't know ;).
- bunch of compilation issues (older clang, -D_NDEBUG from llvm-config
being used for all of postgres, ...) have been fixed.
- Two bigger prerequisite patches have been merged.
- lotsa smaller stuff.
Regards,
Andres
Commits
-
Improve JIT docs.
- fb604780114c 11.0 landed
-
Add documentation for the JIT feature.
- e6c039d13e16 11.0 landed
-
Add EXPLAIN support for JIT.
- 1f0c6a9e7dca 11.0 landed
-
Add inlining support to LLVM JIT provider.
- 9370462e9a79 11.0 landed
-
JIT tuple deforming in LLVM JIT provider.
- 32af96b2b118 11.0 landed
-
Add FIELDNO_* macro designating offset into structs required for JIT.
- 7ced1d124728 11.0 landed
-
Add expression compilation support to LLVM JIT provider.
- 2a0faed9d702 11.0 landed
-
Expand list of synchronized types and functions in LLVM JIT provider.
- fb46ac26fe49 11.0 landed
-
Add helpers for emitting LLVM IR.
- 7ec0d80c0508 11.0 landed
-
Basic planner and executor integration for JIT.
- cc415a56d09a 11.0 landed
-
Debugging and profiling support for LLVM JIT provider.
- 250bca7fc145 11.0 landed
-
Support for optimizing and emitting code in LLVM JIT provider.
- b96d550eb03c 11.0 landed
-
Add file containing extensions of the LLVM C API.
- 31bc604e0b74 11.0 landed
-
Basic JIT provider and error handling infrastructure.
- 432bb9e04da4 11.0 landed
-
Add configure infrastructure (--with-llvm) to enable LLVM support.
- 5b2526c83832 11.0 landed
-
Add C++ support to configure.
- 6869b4f25847 11.0 landed
-
Add PGAC_PROG_VARCC_VARFLAGS_OPT autoconf macro.
- 3de04e4ed12d 11.0 landed
-
Fix VM buffer pin management in heap_lock_updated_tuple_rec().
- 0b1d1a038bab 11.0 cited
-
Allow tupleslots to have a fixed tupledesc, use in executor nodes.
- ad7dbee368a7 11.0 landed
-
Expression evaluation based aggregate transition invocation.
- 69c3936a1499 11.0 landed
-
Perform slot validity checks in a separate pass over expression.
- b40933101ca6 11.0 landed
-
Rely on executor utils to build targetlist for DML RETURNING.
- 4717fdb14cf0 11.0 landed
-
Refer to OS X as "macOS", except for the port name which is still "darwin".
- da6c4f6ca88d 10.0 cited