Обсуждение: Re: [COMMITTERS] pgsql: Correctly align page's images in generic wal API

Поиск
Список
Период
Сортировка

Re: [COMMITTERS] pgsql: Correctly align page's images in generic wal API

От
Michael Paquier
Дата:
On Tue, May 17, 2016 at 6:01 AM, Teodor Sigaev <teodor@sigaev.ru> wrote:
> Correctly align page's images in generic wal API
>
> Page image should be MAXALIGN'ed because existing code could directly align
> pointers in page instead of align offset from beginning of page.
>
> Found during play with indexes as extenstion, Alexander Korotkov and me

Instead of allocating this memory unconditionally for each buffer,
wouldn't it be better to set all the page pointers to NULL in
GenericXLogStart and allocate memory only once a buffer is registered
in GenericXLogRegisterBuffer when finding a free slot? This patch is
wasting many cycles.
-- 
Michael



Re: [COMMITTERS] pgsql: Correctly align page's images in generic wal API

От
Teodor Sigaev
Дата:
> Instead of allocating this memory unconditionally for each buffer,
> wouldn't it be better to set all the page pointers to NULL in
> GenericXLogStart and allocate memory only once a buffer is registered
> in GenericXLogRegisterBuffer when finding a free slot? This patch is
> wasting many cycles.


GenericXLogRegisterBuffer() could be called in another MemoryContext what
can be a reason for strange bugs. Right now only a few pages could be
involved in one round of GenericWal. I don't believe that such allocation
could be a reason of noticable performance degradation. Although I didn't
check that.
-- 
Teodor Sigaev                                   E-mail: teodor@sigaev.ru
  WWW: http://www.sigaev.ru/
 



Re: Re: [COMMITTERS] pgsql: Correctly align page's images in generic wal API

От
Tom Lane
Дата:
Teodor Sigaev <teodor@sigaev.ru> writes:
>> Instead of allocating this memory unconditionally for each buffer,
>> wouldn't it be better to set all the page pointers to NULL in
>> GenericXLogStart and allocate memory only once a buffer is registered
>> in GenericXLogRegisterBuffer when finding a free slot? This patch is
>> wasting many cycles.

> GenericXLogRegisterBuffer() could be called in another MemoryContext what
> can be a reason for strange bugs. Right now only a few pages could be
> involved in one round of GenericWal. I don't believe that such allocation
> could be a reason of noticable performance degradation. Although I didn't
> check that.

You could allocate all the pages in one palloc, though, and then just
set the pointers via address arithmetic.
        regards, tom lane