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

Commit 036297c

Browse files
committed
Pack struct ParsedWord more tightly.
In a 64-bit build there's an awful lot of useless pad space in ParsedWords. Since we may allocate large arrays of these, it's worth some effort to reduce their size. Here we reduce the alen field from uint32 to uint16, and then re-order the fields to avoid unnecessary padding. alen is only used to remember the allocated size of the apos[] array, which is not allowed to exceed MAXNUMPOS (256) elements, so uint16 is plenty of space for it. That gets us from 40 bytes to 24 on 64-bit builds, and from 20 bytes to 16 on 32-bit builds. Per discussion of bug #18080. Unfortunately this is an ABI break so we can't back-patch. Discussion: https://postgr.es/m/1146921.1695411070@sss.pgh.pa.us
1 parent cf1c650 commit 036297c

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/include/tsearch/ts_utils.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,22 +81,22 @@ extern void pushOperator(TSQueryParserState state, int8 oper, int16 distance);
8181
*/
8282
typedef struct
8383
{
84+
uint16 flags; /* currently, only TSL_PREFIX */
8485
uint16 len;
8586
uint16 nvariant;
87+
uint16 alen;
8688
union
8789
{
8890
uint16 pos;
8991

9092
/*
9193
* When apos array is used, apos[0] is the number of elements in the
9294
* array (excluding apos[0]), and alen is the allocated size of the
93-
* array.
95+
* array. We do not allow more than MAXNUMPOS array elements.
9496
*/
9597
uint16 *apos;
9698
} pos;
97-
uint16 flags; /* currently, only TSL_PREFIX */
9899
char *word;
99-
uint32 alen;
100100
} ParsedWord;
101101

102102
typedef struct

0 commit comments

Comments
 (0)