Pack struct ParsedWord more tightly.
authorTom Lane <tgl@sss.pgh.pa.us>
Mon, 25 Sep 2023 16:07:32 +0000 (12:07 -0400)
committerTom Lane <tgl@sss.pgh.pa.us>
Mon, 25 Sep 2023 16:07:32 +0000 (12:07 -0400)
commit036297cf1b8490bb72439d9ab471670598d3ad2f
tree9354496ad16add60d10c933b9727f924885a33dc
parentcf1c65070a89de1e810ef2c5a2036ca4a56c2fdc
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
src/include/tsearch/ts_utils.h