mirror of
https://github.com/postgres/postgres.git
synced 2025-10-21 02:52:47 +03:00
Add expression compilation support to LLVM JIT provider.
In addition to the interpretation of expressions (which back evaluation of WHERE clauses, target list projection, aggregates transition values etc) support compiling expressions to native code, using the infrastructure added in earlier commits. To avoid duplicating a lot of code, only support emitting code for cases that are likely to be performance critical. For expression steps that aren't deemed that, use the existing interpreter. The generated code isn't great - some architectural changes are required to address that. But this already yields a significant speedup for some analytics queries, particularly with WHERE clauses filtering a lot, or computing multiple aggregates. Author: Andres Freund Tested-By: Thomas Munro Discussion: https://postgr.es/m/20170901064131.tazjxwus3k2w3ybh@alap3.anarazel.de Disable JITing for VALUES() nodes. VALUES() nodes are only ever executed once. This is primarily helpful for debugging, when forcing JITing even for cheap queries. Author: Andres Freund Discussion: https://postgr.es/m/20170901064131.tazjxwus3k2w3ybh@alap3.anarazel.de
This commit is contained in:
@@ -19,6 +19,8 @@
|
||||
#define PGJIT_NONE 0
|
||||
#define PGJIT_PERFORM 1 << 0
|
||||
#define PGJIT_OPT3 1 << 1
|
||||
/* reserved for PGJIT_INLINE */
|
||||
#define PGJIT_EXPR 1 << 3
|
||||
|
||||
|
||||
typedef struct JitContext
|
||||
@@ -47,11 +49,14 @@ extern void _PG_jit_provider_init(JitProviderCallbacks *cb);
|
||||
typedef void (*JitProviderInit) (JitProviderCallbacks *cb);
|
||||
typedef void (*JitProviderResetAfterErrorCB) (void);
|
||||
typedef void (*JitProviderReleaseContextCB) (JitContext *context);
|
||||
struct ExprState;
|
||||
typedef bool (*JitProviderCompileExprCB) (struct ExprState *state);
|
||||
|
||||
struct JitProviderCallbacks
|
||||
{
|
||||
JitProviderResetAfterErrorCB reset_after_error;
|
||||
JitProviderReleaseContextCB release_context;
|
||||
JitProviderCompileExprCB compile_expr;
|
||||
};
|
||||
|
||||
|
||||
@@ -60,6 +65,7 @@ extern bool jit_enabled;
|
||||
extern char *jit_provider;
|
||||
extern bool jit_debugging_support;
|
||||
extern bool jit_dump_bitcode;
|
||||
extern bool jit_expressions;
|
||||
extern bool jit_profiling_support;
|
||||
extern double jit_above_cost;
|
||||
extern double jit_optimize_above_cost;
|
||||
@@ -68,4 +74,11 @@ extern double jit_optimize_above_cost;
|
||||
extern void jit_reset_after_error(void);
|
||||
extern void jit_release_context(JitContext *context);
|
||||
|
||||
/*
|
||||
* Functions for attempting to JIT code. Callers must accept that these might
|
||||
* not be able to perform JIT (i.e. return false).
|
||||
*/
|
||||
extern bool jit_compile_expr(struct ExprState *state);
|
||||
|
||||
|
||||
#endif /* JIT_H */
|
||||
|
Reference in New Issue
Block a user