Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit ac88807

Browse files
committed
jit: Re-allow JIT compilation of execGrouping.c hashtable comparisons.
In the course of 5567d12, 356687b and 317ffdf, I changed BuildTupleHashTable[Ext]'s call to ExecBuildGroupingEqual to not pass in the parent node, but NULL. Which in turn prevents the tuple equality comparator from being JIT compiled. While that fixes bug #15486, it is not actually necessary after all of the above commits, as we don't re-build the comparator when using the new BuildTupleHashTableExt() interface (as the content of the hashtable are reset, but the TupleHashTable itself is not). Therefore re-allow jit compilation for callers that use BuildTupleHashTableExt with a separate context for "metadata" and content. As in the previous commit, there's ongoing work to make this easier to test to prevent such regressions in the future, but that infrastructure is not going to be backpatchable. The performance impact of not JIT compiling hashtable equality comparators can be substantial e.g. for aggregation queries that aggregate a lot of input rows to few output rows (when there are a lot of output groups, there will be fewer comparisons). Author: Andres Freund Discussion: https://postgr.es/m/20190927072053.njf6prdl3vb7y7qb@alap3.anarazel.de Backpatch: 11, just as 5567d12
1 parent 97e971e commit ac88807

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

src/backend/executor/execGrouping.c

+12-1
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,7 @@ BuildTupleHashTableExt(PlanState *parent,
166166
TupleHashTable hashtable;
167167
Size entrysize = sizeof(TupleHashEntryData) + additionalsize;
168168
MemoryContext oldcontext;
169+
bool allow_jit;
169170

170171
Assert(nbuckets > 0);
171172

@@ -210,13 +211,23 @@ BuildTupleHashTableExt(PlanState *parent,
210211
hashtable->tableslot = MakeSingleTupleTableSlot(CreateTupleDescCopy(inputDesc),
211212
&TTSOpsMinimalTuple);
212213

214+
/*
215+
* If the old reset interface is used (i.e. BuildTupleHashTable, rather
216+
* than BuildTupleHashTableExt), allowing JIT would lead to the generated
217+
* functions to a) live longer than the query b) be re-generated each time
218+
* the table is being reset. Therefore prevent JIT from being used in that
219+
* case, by not providing a parent node (which prevents accessing the
220+
* JitContext in the EState).
221+
*/
222+
allow_jit = metacxt != tablecxt;
223+
213224
/* build comparator for all columns */
214225
/* XXX: should we support non-minimal tuples for the inputslot? */
215226
hashtable->tab_eq_func = ExecBuildGroupingEqual(inputDesc, inputDesc,
216227
&TTSOpsMinimalTuple, &TTSOpsMinimalTuple,
217228
numCols,
218229
keyColIdx, eqfuncoids, collations,
219-
NULL);
230+
allow_jit ? parent : NULL);
220231

221232
/*
222233
* While not pretty, it's ok to not shut down this context, but instead

0 commit comments

Comments
 (0)