Skip to content
forked from postgres/postgres

This is a modified version of PostgreSQL with just-in-time compiler for expressions. Current base version is 9.6.1.

Notifications You must be signed in to change notification settings

ispras/postgres

This branch is 240 commits ahead of, 20543 commits behind postgres/postgres:master.

Folders and files

NameName
Last commit message
Last commit date

Latest commit

3d50eaf · Nov 11, 2016
May 6, 2016
Oct 4, 2016
Oct 24, 2016
Nov 11, 2016
Apr 13, 2015
Oct 28, 2016
Jul 9, 2015
Oct 27, 2016
May 13, 2015
Feb 12, 2014
Feb 15, 2011
Feb 11, 2014
Nov 11, 2016
Jul 8, 2015
Nov 11, 2016
Nov 11, 2016

Repository files navigation

PostgreSQL with JIT compiler for expressions

This is a modified version of PostgreSQL with just-in-time compiler for expressions. Current base version is 9.6.1. Just-in-time compiler (JIT for short) improves database performance significantly on OLAP queries. This version uses LLVM JIT for query compilation and shows up to 20% improvement on TPC-H tests.

Dependencies

  • LLVM version 3.7

Building

The easiest way is to follow the process of building vanilla PostgreSQL. LLVM JIT compiler for expressions is enabled by default.

The most basic procedure is as follows:

$ git clone https://github.com/ispras/postgres
$ cd postgres
$ ./configure [configure options]
$ make [make options] -jN

Configure options

option description
--disable-llvm-jit Disables expression compilation with LLVM JIT.
--with-llvm-config=<llvm_config> Specify your own llvm-config, version 3.7.0 or 3.7.1 required for build.

Make options

option description
LLVM_BACKEND_FILE_LIMIT=<N> Parallelize compilation by splitting LLVM backend file, N — number of functions in each file (50 by default).

PostgreSQL GUC settings

setting description
enable_llvm_jit Enable LLVM JIT of expressions (enabled by default).
enable_llvm_dump Dump compiled LLVM IR (developer option, disabled by default).
debug_llvm_jit Disable optimization of generated LLVM modules (developer option, disabled by default).

Internals

Internally, evaluation of each individual expression in PostgreSQL happens by means of calling a function pointer which is stored in the expression object and initialized during expression initialization phase with the address of the corresponding execution function.

Expression JIT presented here works by hooking into expression initialization phase and replacing this pointer with address of a function generated for the expression at run time.

Advice for developers

  • Enabling assertions (configure with --enable-cassert option) also turns on LLVM module verification.
  • Set enable_llvm_dump and debug_llvm_jit to on to explore compiled code.

LLVM dumps are stored in the llvm_dump subdirectory in the database directory. Each compiled expression is written into three files (substitute ### with expression number):

  • expr.### — expression tree, in the “pretty-print” format.
  • dump.###.ll, dump.###.opt.llLLVM assembly files generated for expression.

Resources

License

PostgreSQL License

About

This is a modified version of PostgreSQL with just-in-time compiler for expressions. Current base version is 9.6.1.

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

  • C 85.9%
  • PLpgSQL 5.4%
  • C++ 2.6%
  • Yacc 1.5%
  • Perl 1.5%
  • Makefile 0.8%
  • Other 2.3%