On 27.02.21 09:08, Julien Rouhaud wrote:
> PFA a patch that fixes pg_prewarm and pg_stat_statements explicit alignment to
> CACHELINEALIGN, and also update the alignment in hash_estimate_size() to what I
> think ShmemInitHash will actually consume.
For extensions, wouldn't it make things better if
RequestAddinShmemSpace() applied CACHELINEALIGN() to its argument?
If you consider the typical sequence of RequestAddinShmemSpace(mysize())
and later ShmemInitStruct(..., mysize(), ...), then the size gets
rounded up to cache-line size in the second case and not the first. The
premise in your patch is that the extension should figure that out
before calling RequestAddinShmemSpace(), but that seems wrong.
Btw., I think your patch was wrong to apply CACHELINEALIGN() to
intermediate results rather than at the end.