forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commita9c35cf
committed
Change function call information to be variable length.
Before this change FunctionCallInfoData, the struct arguments etc forV1 function calls are stored in, always had space forFUNC_MAX_ARGS/100 arguments, storing datums and their nullness in twoarrays. For nearly every function call 100 arguments is far more thanneeded, therefore wasting memory. Arg and argnull being two separatearrays also guarantees that to access a single argument, twocachelines have to be touched.Change the layout so there's a single variable-length array with pairsof value / isnull. That drastically reduces memory consumption formost function calls (on x86-64 a two argument function now uses64bytes, previously 936 bytes), and makes it very likely that argumentvalue and its nullness are on the same cacheline.Arguments are stored in a new NullableDatum struct, which, due topadding, needs more memory per argument than before. But as usuallyfar fewer arguments are stored, and individual arguments are cheaperto access, that's still a clear win. It's likely that there's otherplaces 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-lengthallocations have to take the number of arguments into account. Forheap allocations that can be done with SizeForFunctionCallInfoData(),for on-stack allocations there's a new LOCAL_FCINFO(name, nargs) macrothat helps to allocate an appropriately sized and aligned variable.Some places with stack allocation function call information don't knowthe number of arguments at compile time, and currently variably sizedstack allocations aren't allowed in postgres. Therefore allow forFUNC_MAX_ARGS space in these cases. They're not that common, so fornow that seems acceptable.Because of the need to allocate FunctionCallInfo of the appropriatesize, older extensions may need to update their code. To avoid subtlebreakages, the FunctionCallInfoData struct has been renamed toFunctionCallInfoBaseData. Most code only references FunctionCallInfo,so that shouldn't cause much collateral damage.This change is also a prerequisite for more efficient expression JITcompilation (by allocating the function call information on the stack,allowing LLVM to optimize it away); previously the size of the callinformation caused problems inside LLVM's optimizer.Author: Andres FreundReviewed-By: Tom LaneDiscussion:https://postgr.es/m/20180605172952.x34m5uz6ju6enaem@alap3.anarazel.de1 parent6d3ede5 commita9c35cf
File tree
40 files changed
+957
-1054
lines changed- contrib/hstore
- doc/src/sgml
- src
- backend
- commands
- executor
- jit/llvm
- postmaster
- tcop
- utils
- adt
- fmgr
- sort
- include
- executor
- jit
- nodes
- pl
- plperl
- plpgsql/src
- plpython
- tcl
- tools/pgindent
40 files changed
+957
-1054
lines changedLines changed: 1 addition & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
854 | 854 |
| |
855 | 855 |
| |
856 | 856 |
| |
857 |
| - | |
| 857 | + | |
858 | 858 |
| |
859 | 859 |
| |
860 | 860 |
| |
|
Lines changed: 4 additions & 4 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
34 | 34 |
| |
35 | 35 |
| |
36 | 36 |
| |
37 |
| - | |
| 37 | + | |
38 | 38 |
| |
39 | 39 |
| |
40 | 40 |
| |
41 |
| - | |
| 41 | + | |
42 | 42 |
| |
43 | 43 |
| |
44 | 44 |
| |
45 |
| - | |
| 45 | + | |
46 | 46 |
| |
47 | 47 |
| |
48 | 48 |
| |
| |||
87 | 87 |
| |
88 | 88 |
| |
89 | 89 |
| |
90 |
| - | |
| 90 | + | |
91 | 91 |
| |
92 | 92 |
| |
93 | 93 |
| |
|
Lines changed: 4 additions & 4 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
1055 | 1055 |
| |
1056 | 1056 |
| |
1057 | 1057 |
| |
| 1058 | + | |
1058 | 1059 |
| |
1059 | 1060 |
| |
1060 |
| - | |
1061 | 1061 |
| |
1062 | 1062 |
| |
1063 | 1063 |
| |
| |||
1077 | 1077 |
| |
1078 | 1078 |
| |
1079 | 1079 |
| |
1080 |
| - | |
| 1080 | + | |
1081 | 1081 |
| |
1082 |
| - | |
1083 |
| - | |
| 1082 | + | |
| 1083 | + | |
1084 | 1084 |
| |
1085 | 1085 |
| |
1086 | 1086 |
| |
|
Lines changed: 8 additions & 7 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
2216 | 2216 |
| |
2217 | 2217 |
| |
2218 | 2218 |
| |
| 2219 | + | |
2219 | 2220 |
| |
2220 | 2221 |
| |
2221 | 2222 |
| |
2222 | 2223 |
| |
2223 | 2224 |
| |
2224 | 2225 |
| |
2225 |
| - | |
2226 | 2226 |
| |
2227 | 2227 |
| |
2228 | 2228 |
| |
| |||
2297 | 2297 |
| |
2298 | 2298 |
| |
2299 | 2299 |
| |
2300 |
| - | |
| 2300 | + | |
| 2301 | + | |
2301 | 2302 |
| |
2302 | 2303 |
| |
2303 | 2304 |
| |
| |||
2318 | 2319 |
| |
2319 | 2320 |
| |
2320 | 2321 |
| |
2321 |
| - | |
2322 |
| - | |
| 2322 | + | |
| 2323 | + | |
2323 | 2324 |
| |
2324 | 2325 |
| |
2325 | 2326 |
| |
2326 | 2327 |
| |
2327 |
| - | |
2328 |
| - | |
| 2328 | + | |
| 2329 | + | |
2329 | 2330 |
| |
2330 | 2331 |
| |
2331 | 2332 |
| |
| |||
2346 | 2347 |
| |
2347 | 2348 |
| |
2348 | 2349 |
| |
2349 |
| - | |
| 2350 | + | |
2350 | 2351 |
| |
2351 | 2352 |
| |
2352 | 2353 |
| |
|
Lines changed: 4 additions & 4 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
8879 | 8879 |
| |
8880 | 8880 |
| |
8881 | 8881 |
| |
8882 |
| - | |
| 8882 | + | |
8883 | 8883 |
| |
8884 | 8884 |
| |
8885 | 8885 |
| |
8886 | 8886 |
| |
8887 | 8887 |
| |
8888 | 8888 |
| |
8889 | 8889 |
| |
8890 |
| - | |
| 8890 | + | |
8891 | 8891 |
| |
8892 | 8892 |
| |
8893 | 8893 |
| |
| |||
8901 | 8901 |
| |
8902 | 8902 |
| |
8903 | 8903 |
| |
8904 |
| - | |
| 8904 | + | |
8905 | 8905 |
| |
8906 |
| - | |
| 8906 | + | |
8907 | 8907 |
| |
8908 | 8908 |
| |
8909 | 8909 |
| |
|
Lines changed: 6 additions & 6 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
2357 | 2357 |
| |
2358 | 2358 |
| |
2359 | 2359 |
| |
2360 |
| - | |
| 2360 | + | |
2361 | 2361 |
| |
2362 | 2362 |
| |
2363 | 2363 |
| |
| |||
2402 | 2402 |
| |
2403 | 2403 |
| |
2404 | 2404 |
| |
2405 |
| - | |
| 2405 | + | |
2406 | 2406 |
| |
2407 | 2407 |
| |
2408 |
| - | |
| 2408 | + | |
2409 | 2409 |
| |
2410 | 2410 |
| |
2411 | 2411 |
| |
2412 | 2412 |
| |
2413 |
| - | |
| 2413 | + | |
2414 | 2414 |
| |
2415 | 2415 |
| |
2416 | 2416 |
| |
| |||
2428 | 2428 |
| |
2429 | 2429 |
| |
2430 | 2430 |
| |
2431 |
| - | |
| 2431 | + | |
2432 | 2432 |
| |
2433 | 2433 |
| |
2434 | 2434 |
| |
2435 |
| - | |
| 2435 | + | |
2436 | 2436 |
| |
2437 | 2437 |
| |
2438 | 2438 |
| |
|
Lines changed: 3 additions & 3 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
124 | 124 |
| |
125 | 125 |
| |
126 | 126 |
| |
127 |
| - | |
| 127 | + | |
128 | 128 |
| |
129 | 129 |
| |
130 | 130 |
| |
| |||
145 | 145 |
| |
146 | 146 |
| |
147 | 147 |
| |
148 |
| - | |
| 148 | + | |
149 | 149 |
| |
150 | 150 |
| |
151 | 151 |
| |
| |||
158 | 158 |
| |
159 | 159 |
| |
160 | 160 |
| |
161 |
| - | |
| 161 | + | |
162 | 162 |
| |
163 | 163 |
| |
164 | 164 |
| |
|
0 commit comments
Comments
(0)