Remove size increase in ExprEvalStep caused by hashed saops
commitfe3caa1439378830d13423939b13e39d5afa8cf0
authorDavid Rowley <drowley@postgresql.org>
Wed, 6 Jul 2022 07:40:32 +0000 (6 19:40 +1200)
committerDavid Rowley <drowley@postgresql.org>
Wed, 6 Jul 2022 07:40:32 +0000 (6 19:40 +1200)
tree80e0ed4c2dce7c2827c1f149dc5c1d174c96cf59
parent16d52fc89dbe8394ed318521e076f08fd2e4bf8c
Remove size increase in ExprEvalStep caused by hashed saops

50e17ad28 increased the size of ExprEvalStep from 64 bytes up to 88 bytes.
Lots of effort was spent during the development of the current expression
evaluation code to make an instance of this struct as small as possible.
Making this struct larger than needed reduces CPU cache efficiency during
expression evaluation which causes noticeable slowdowns during query
execution.

In order to reduce the size of the struct, here we remove the fn_addr
field. The values from this field can be obtained via fcinfo, just with
some extra pointer dereferencing. The extra indirection does not seem to
cause any noticeable slowdowns.

Various other fields have been moved into the ScalarArrayOpExprHashTable
struct. These fields are only used when the ScalarArrayOpExprHashTable
pointer has already been dereferenced, so no additional pointer
dereferences occur for these. Here we also make hash_fcinfo_data the last
field in ScalarArrayOpExprHashTable so that we can avoid a further pointer
dereference to get the FunctionCallInfoBaseData. This also saves a call to
palloc().

50e17ad28 was added in 14, but it's too late to adjust the size of the
ExprEvalStep in that version, so here we just backpatch to 15, which is
currently in beta.

Author: Andres Freund, David Rowley
Discussion: https://postgr.es/m/20220616233130.rparivafipt6doj3@alap3.anarazel.de
Backpatch-through: 15
src/backend/executor/execExpr.c
src/backend/executor/execExprInterp.c
src/include/executor/execExpr.h