diff options
author | Andres Freund <andres@anarazel.de> | 2018-03-22 11:05:22 -0700 |
---|---|---|
committer | Andres Freund <andres@anarazel.de> | 2018-03-22 11:05:22 -0700 |
commit | b96d550eb03cfdb000def70912ec840dbe7f67da (patch) | |
tree | 056e8d310b353869467d6136fab3355caa5fea07 /src/include/jit/jit.h | |
parent | 2fe6336e2d48d77fca6d0849f03c0faa06725159 (diff) |
Support for optimizing and emitting code in LLVM JIT provider.
This commit introduces the ability to actually generate code using
LLVM. In particular, this adds:
- Ability to emit code both in heavily optimized and largely
unoptimized fashion
- Batching facility to allow functions to be defined in small
increments, but optimized and emitted in executable form in larger
batches (for performance and memory efficiency)
- Type and function declaration synchronization between runtime
generated code and normal postgres code. This is critical to be able
to access struct fields etc.
- Developer oriented jit_dump_bitcode GUC, for inspecting / debugging
the generated code.
- per JitContext statistics of number of functions, time spent
generating code, optimizing, and emitting it. This will later be
employed for EXPLAIN support.
This commit doesn't yet contain any code actually generating
functions. That'll follow in later commits.
Documentation for GUCs added, and for JIT in general, will be added in
later commits.
Author: Andres Freund, with contributions by Pierre Ducroquet
Testing-By: Thomas Munro, Peter Eisentraut
Discussion: https://postgr.es/m/20170901064131.tazjxwus3k2w3ybh@alap3.anarazel.de
Diffstat (limited to 'src/include/jit/jit.h')
-rw-r--r-- | src/include/jit/jit.h | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/src/include/jit/jit.h b/src/include/jit/jit.h index a2f3dd9d4f2..35301674c8a 100644 --- a/src/include/jit/jit.h +++ b/src/include/jit/jit.h @@ -11,14 +11,34 @@ #ifndef JIT_H #define JIT_H +#include "executor/instrument.h" #include "utils/resowner.h" +/* Flags deterimining what kind of JIT operations to perform */ +#define PGJIT_NONE 0 +#define PGJIT_PERFORM 1 << 0 +#define PGJIT_OPT3 1 << 1 + + typedef struct JitContext { + /* see PGJIT_* above */ int flags; ResourceOwner resowner; + + /* number of emitted functions */ + size_t created_functions; + + /* accumulated time to generate code */ + instr_time generation_counter; + + /* accumulated time for optimization */ + instr_time optimization_counter; + + /* accumulated time for code emission */ + instr_time emission_counter; } JitContext; typedef struct JitProviderCallbacks JitProviderCallbacks; @@ -38,6 +58,7 @@ struct JitProviderCallbacks /* GUCs */ extern bool jit_enabled; extern char *jit_provider; +extern bool jit_dump_bitcode; extern void jit_reset_after_error(void); |