summaryrefslogtreecommitdiff
path: root/src/include
diff options
context:
space:
mode:
authorAndres Freund2018-03-26 19:57:19 +0000
committerAndres Freund2018-03-26 19:57:19 +0000
commit32af96b2b118cd204ca809d7c48c7f8ea7f879cf (patch)
treed9a09cc42afb193293a0b65cfa080d676763d776 /src/include
parent64f85894ad2730fb1449a8e81dd8026604e9a546 (diff)
JIT tuple deforming in LLVM JIT provider.
Performing JIT compilation for deforming gains performance benefits over unJITed deforming from compile-time knowledge of the tuple descriptor. Fixed column widths, NOT NULLness, etc can be taken advantage of. Right now the JITed deforming is only used when deforming tuples as part of expression evaluation (and obviously only if the descriptor is known). It's likely to be beneficial in other cases, too. By default tuple deforming is JITed whenever an expression is JIT compiled. There's a separate boolean GUC controlling it, but that's expected to be primarily useful for development and benchmarking. 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
Diffstat (limited to 'src/include')
-rw-r--r--src/include/access/htup_details.h1
-rw-r--r--src/include/executor/execExpr.h1
-rw-r--r--src/include/jit/jit.h2
-rw-r--r--src/include/jit/llvmjit.h3
-rw-r--r--src/include/nodes/execnodes.h8
5 files changed, 15 insertions, 0 deletions
diff --git a/src/include/access/htup_details.h b/src/include/access/htup_details.h
index 3616a17b6fa..67342ef63dc 100644
--- a/src/include/access/htup_details.h
+++ b/src/include/access/htup_details.h
@@ -829,5 +829,6 @@ extern void heap_free_minimal_tuple(MinimalTuple mtup);
extern MinimalTuple heap_copy_minimal_tuple(MinimalTuple mtup);
extern HeapTuple heap_tuple_from_minimal_tuple(MinimalTuple mtup);
extern MinimalTuple minimal_tuple_from_heap_tuple(HeapTuple htup);
+extern size_t varsize_any(void *p);
#endif /* HTUP_DETAILS_H */
diff --git a/src/include/executor/execExpr.h b/src/include/executor/execExpr.h
index 6fc4ed640b2..f4617a28fa2 100644
--- a/src/include/executor/execExpr.h
+++ b/src/include/executor/execExpr.h
@@ -262,6 +262,7 @@ typedef struct ExprEvalStep
{
/* attribute number up to which to fetch (inclusive) */
int last_var;
+ TupleDesc known_desc;
} fetch;
/* for EEOP_INNER/OUTER/SCAN_[SYS]VAR[_FIRST] */
diff --git a/src/include/jit/jit.h b/src/include/jit/jit.h
index 703c5011dae..efcd6a52cfd 100644
--- a/src/include/jit/jit.h
+++ b/src/include/jit/jit.h
@@ -21,6 +21,7 @@
#define PGJIT_OPT3 1 << 1
/* reserved for PGJIT_INLINE */
#define PGJIT_EXPR 1 << 3
+#define PGJIT_DEFORM 1 << 4
typedef struct JitContext
@@ -67,6 +68,7 @@ extern bool jit_debugging_support;
extern bool jit_dump_bitcode;
extern bool jit_expressions;
extern bool jit_profiling_support;
+extern bool jit_tuple_deforming;
extern double jit_above_cost;
extern double jit_optimize_above_cost;
diff --git a/src/include/jit/llvmjit.h b/src/include/jit/llvmjit.h
index cc908477e8e..9443a568d85 100644
--- a/src/include/jit/llvmjit.h
+++ b/src/include/jit/llvmjit.h
@@ -32,6 +32,7 @@ extern "C"
#include "fmgr.h"
#include "jit/jit.h"
#include "nodes/pg_list.h"
+#include "access/tupdesc.h"
typedef struct LLVMJitContext
@@ -75,6 +76,7 @@ extern LLVMTypeRef StructAggStatePerGroupData;
extern LLVMValueRef AttributeTemplate;
extern LLVMValueRef FuncStrlen;
+extern LLVMValueRef FuncVarsizeAny;
extern LLVMValueRef FuncSlotGetsomeattrs;
extern LLVMValueRef FuncHeapGetsysattr;
extern LLVMValueRef FuncMakeExpandedObjectReadOnlyInternal;
@@ -107,6 +109,7 @@ extern LLVMValueRef llvm_function_reference(LLVMJitContext *context,
****************************************************************************
*/
extern bool llvm_compile_expr(struct ExprState *state);
+extern LLVMValueRef slot_compile_deform(struct LLVMJitContext *context, TupleDesc desc, int natts);
/*
****************************************************************************
diff --git a/src/include/nodes/execnodes.h b/src/include/nodes/execnodes.h
index 2c2d2823c05..6070a42b6fe 100644
--- a/src/include/nodes/execnodes.h
+++ b/src/include/nodes/execnodes.h
@@ -920,6 +920,7 @@ typedef struct PlanState
ExprState *qual; /* boolean qual condition */
struct PlanState *lefttree; /* input plan tree(s) */
struct PlanState *righttree;
+
List *initPlan; /* Init SubPlanState nodes (un-correlated expr
* subselects) */
List *subPlan; /* SubPlanState nodes in my expressions */
@@ -935,6 +936,13 @@ typedef struct PlanState
TupleTableSlot *ps_ResultTupleSlot; /* slot for my result tuples */
ExprContext *ps_ExprContext; /* node's expression-evaluation context */
ProjectionInfo *ps_ProjInfo; /* info for doing tuple projection */
+
+ /*
+ * Scanslot's descriptor if known. This is a bit of a hack, but otherwise
+ * it's hard for expression compilation to optimize based on the
+ * descriptor, without encoding knowledge about all executor nodes.
+ */
+ TupleDesc scandesc;
} PlanState;
/* ----------------