On Thu, 29 Apr 2021 at 12:30, Yura Sokolov <y.sokolov@postgrespro.ru> wrote:
>
> David Rowley писал 2021-04-29 02:51:
> > Another line of thought for making it go faster would be to do
> > something like get rid of the hash status field from SMgrEntry. That
> > could be either coded into a single bit we'd borrow from the hash
> > value, or it could be coded into the least significant bit of the data
> > field. A pointer to palloc'd memory should always be MAXALIGNed,
> > which means at least the lower two bits are always zero. We'd just
> > need to make sure and do something like "data & ~((uintptr_t) 3)" to
> > trim off the hash status bits before dereferencing the pointer. That
> > would make the SMgrEntry 12 bytes on a 64-bit machine. However, it
> > would also mean that some entries would span 2 cache lines, which
> > might affect performance a bit.
>
> Then data pointer will be itself unaligned to 8 bytes. While x86 is
> mostly indifferent to this, doubtfully this memory economy will pay
> off.
Actually, I didn't think very hard about that. The struct would still
be 16 bytes and just have padding so the data pointer was aligned to 8
bytes (assuming a 64-bit machine).
David