Re: [HACKERS] Should we cacheline align PGXACT?

Поиск
Список
Период
Сортировка
От Robert Haas
Тема Re: [HACKERS] Should we cacheline align PGXACT?
Дата
Msg-id CA+TgmoYLn_3qgSs0iUADC-TNxj8iQGXtXriE2YMxecZ_zf4gtA@mail.gmail.com
обсуждение исходный текст
Ответ на Re: [HACKERS] Should we cacheline align PGXACT?  (Alvaro Herrera <alvherre@2ndquadrant.com>)
Ответы Re: [HACKERS] Should we cacheline align PGXACT?  (Tom Lane <tgl@sss.pgh.pa.us>)
Re: [HACKERS] Should we cacheline align PGXACT?  (Andres Freund <andres@anarazel.de>)
Список pgsql-hackers
On Mon, Feb 13, 2017 at 11:07 AM, Alvaro Herrera
<alvherre@2ndquadrant.com> wrote:
> It seems to me that Andres comments here were largely ignored:
> https://www.postgresql.org/message-id/20160822021747.u5bqx2xwwjzac5u5@alap3.anarazel.de
> He was suggesting to increase the struct size to 16 bytes rather than
> going all the way up to 128.  Did anybody test this?

So, I think that going up to 128 bytes can't really make sense.  If
that's the best-performing solution here, then maybe what we ought to
be doing is reverting the PGXACT/PGPROC separation, sticking these
critical members at the beginning, and padding the whole PGXACT out to
a multiple of the cache line size.  Something that only touches the
PGXACT fields will touch the exact same number of cache lines with
that design, but cases that touch more than just the PGXACT fields
should perform better.  The point of moving PGXACT into a separate
structure was to reduce the number of cache lines required to build a
snapshot.  If that's going to go back up to 1 per PGPROC anyway, we
might as well at least use the rest of that cache line to store
something else that might be useful instead of pad bytes.  I think,
anyway.

If padding to 16 bytes is sufficient to get the performance
improvement (or as much as we care about), that seems more reasonable.
But it's still possible we may be gaining on one hand (because now
you'll never touch multiple cache lines for your own PGXACT) and
losing on the other (because now you're scanning 4/3 as many cache
lines to construct a snapshot).  Which of those is better might be
workload-dependent or hardware-dependent.

> Re the coding of the padding computation, seems it'd be better to use
> our standard "offsetof(last-struct-member) + sizeof(last-struct-member)"
> rather than adding each of the members' sizes individually.

I think our now-standard way of doing this is to have a "Padded"
version that is a union between the unpadded struct and char[].  c.f.
BufferDescPadded, LWLockPadded.

-- 
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company



В списке pgsql-hackers по дате отправления:

Предыдущее
От: Magnus Hagander
Дата:
Сообщение: [HACKERS] Help text for pg_basebackup -R
Следующее
От: Robert Haas
Дата:
Сообщение: Re: [HACKERS] Documentation improvements for partitioning