postgresql/contrib/hstore
Andres Freund a9c35cf85c Change function call information to be variable length.
Before this change FunctionCallInfoData, the struct arguments etc for
V1 function calls are stored in, always had space for
FUNC_MAX_ARGS/100 arguments, storing datums and their nullness in two
arrays.  For nearly every function call 100 arguments is far more than
needed, therefore wasting memory. Arg and argnull being two separate
arrays also guarantees that to access a single argument, two
cachelines have to be touched.

Change the layout so there's a single variable-length array with pairs
of value / isnull. That drastically reduces memory consumption for
most function calls (on x86-64 a two argument function now uses
64bytes, previously 936 bytes), and makes it very likely that argument
value and its nullness are on the same cacheline.

Arguments are stored in a new NullableDatum struct, which, due to
padding, needs more memory per argument than before. But as usually
far fewer arguments are stored, and individual arguments are cheaper
to access, that's still a clear win.  It's likely that there's other
places where conversion to NullableDatum arrays would make sense,
e.g. TupleTableSlots, but that's for another commit.

Because the function call information is now variable-length
allocations have to take the number of arguments into account. For
heap allocations that can be done with SizeForFunctionCallInfoData(),
for on-stack allocations there's a new LOCAL_FCINFO(name, nargs) macro
that helps to allocate an appropriately sized and aligned variable.

Some places with stack allocation function call information don't know
the number of arguments at compile time, and currently variably sized
stack allocations aren't allowed in postgres. Therefore allow for
FUNC_MAX_ARGS space in these cases. They're not that common, so for
now that seems acceptable.

Because of the need to allocate FunctionCallInfo of the appropriate
size, older extensions may need to update their code. To avoid subtle
breakages, the FunctionCallInfoData struct has been renamed to
FunctionCallInfoBaseData. Most code only references FunctionCallInfo,
so that shouldn't cause much collateral damage.

This change is also a prerequisite for more efficient expression JIT
compilation (by allocating the function call information on the stack,
allowing LLVM to optimize it away); previously the size of the call
information caused problems inside LLVM's optimizer.

Author: Andres Freund
Reviewed-By: Tom Lane
Discussion: https://postgr.es/m/20180605172952.x34m5uz6ju6enaem@alap3.anarazel.de
2019-01-26 14:17:52 -08:00
..
data Add GIN support for pg_trgm. From Guillaume Smet <guillaume.smet@gmail.com> 2007-03-14 14:21:53 +00:00
expected Add a 64-bit hash function for type hstore. 2018-11-23 13:37:34 -05:00
sql Add a 64-bit hash function for type hstore. 2018-11-23 13:37:34 -05:00
.gitignore Support "make check" in contrib 2011-04-25 22:27:11 +03:00
Makefile Add a 64-bit hash function for type hstore. 2018-11-23 13:37:34 -05:00
hstore--1.0--1.1.sql Fix typo in update scripts for some contrib modules. 2013-07-19 04:13:01 +09:00
hstore--1.1--1.2.sql Fix whitespace issues found by git diff --check, add gitattributes 2013-11-10 14:48:29 -05:00
hstore--1.2--1.3.sql Introduce jsonb, a structured format for storing json. 2014-03-23 16:40:19 -04:00
hstore--1.3--1.4.sql Update extensions with GIN/GIST support for parallel query. 2016-06-14 13:34:37 -04:00
hstore--1.4--1.5.sql Distinguish selectivity of < from <= and > from >=. 2017-09-13 11:12:39 -04:00
hstore--1.4.sql Update extensions with GIN/GIST support for parallel query. 2016-06-14 13:34:37 -04:00
hstore--1.5--1.6.sql Add a 64-bit hash function for type hstore. 2018-11-23 13:37:34 -05:00
hstore--unpackaged--1.0.sql Fix typos in some error messages thrown by extension scripts when fed to psql. 2014-08-25 18:30:37 +02:00
hstore.control Add a 64-bit hash function for type hstore. 2018-11-23 13:37:34 -05:00
hstore.h Make DatumGetFoo/PG_GETARG_FOO/PG_RETURN_FOO macro names more consistent. 2017-09-18 15:21:23 -04:00
hstore_compat.c Fix hstore hash function for empty hstores upgraded from 8.4. 2018-11-24 09:59:49 +00:00
hstore_gin.c Make DatumGetFoo/PG_GETARG_FOO/PG_RETURN_FOO macro names more consistent. 2017-09-18 15:21:23 -04:00
hstore_gist.c Change TRUE/FALSE to true/false 2017-11-08 11:37:28 -05:00
hstore_io.c Fix assorted compiler warnings seen in the buildfarm. 2018-05-02 15:52:54 -04:00
hstore_op.c Change function call information to be variable length. 2019-01-26 14:17:52 -08:00