aboutsummaryrefslogtreecommitdiff
path: root/doc/src
diff options
context:
space:
mode:
authorAndres Freund <andres@anarazel.de>2019-01-26 14:17:52 -0800
committerAndres Freund <andres@anarazel.de>2019-01-26 14:17:52 -0800
commita9c35cf85ca1ff72f16f0f10d7ddee6e582b62b8 (patch)
tree4f34f2c902977a7ce0be7b1e32a12adf0cb223b7 /doc/src
parent6d3ede5f1c654f923b2767b0b0c3b09569adaa18 (diff)
downloadpostgresql-a9c35cf85ca1ff72f16f0f10d7ddee6e582b62b8.tar.gz
postgresql-a9c35cf85ca1ff72f16f0f10d7ddee6e582b62b8.zip
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
Diffstat (limited to 'doc/src')
-rw-r--r--doc/src/sgml/plhandler.sgml8
1 files changed, 4 insertions, 4 deletions
diff --git a/doc/src/sgml/plhandler.sgml b/doc/src/sgml/plhandler.sgml
index 73cd7d13875..14ad15aab8f 100644
--- a/doc/src/sgml/plhandler.sgml
+++ b/doc/src/sgml/plhandler.sgml
@@ -34,15 +34,15 @@
<para>
The call handler is called in the same way as any other function:
It receives a pointer to a
- <structname>FunctionCallInfoData</structname> <type>struct</type> containing
+ <structname>FunctionCallInfoBaseData</structname> <type>struct</type> containing
argument values and information about the called function, and it
is expected to return a <type>Datum</type> result (and possibly
set the <structfield>isnull</structfield> field of the
- <structname>FunctionCallInfoData</structname> structure, if it wishes
+ <structname>FunctionCallInfoBaseData</structname> structure, if it wishes
to return an SQL null result). The difference between a call
handler and an ordinary callee function is that the
<structfield>flinfo-&gt;fn_oid</structfield> field of the
- <structname>FunctionCallInfoData</structname> structure will contain
+ <structname>FunctionCallInfoBaseData</structname> structure will contain
the OID of the actual function to be called, not of the call
handler itself. The call handler must use this field to determine
which function to execute. Also, the passed argument list has
@@ -87,7 +87,7 @@
<para>
When a procedural-language function is invoked as a trigger, no arguments
are passed in the usual way, but the
- <structname>FunctionCallInfoData</structname>'s
+ <structname>FunctionCallInfoBaseData</structname>'s
<structfield>context</structfield> field points at a
<structname>TriggerData</structname> structure, rather than being <symbol>NULL</symbol>
as it is in a plain function call. A language handler should