Re: slab allocator performance issues

Поиск
Список
Период
Сортировка
От John Naylor
Тема Re: slab allocator performance issues
Дата
Msg-id CAFBsxsHKxAi8+7z1L9Y4wu3UxR_ZEgp4p7wSywsay_86KJkb9w@mail.gmail.com
обсуждение исходный текст
Ответ на Re: slab allocator performance issues  (David Rowley <dgrowleyml@gmail.com>)
Ответы Re: slab allocator performance issues  (David Rowley <dgrowleyml@gmail.com>)
Список pgsql-hackers

On Wed, Oct 12, 2022 at 4:37 PM David Rowley <dgrowleyml@gmail.com> wrote:
> [v3]

+ /*
+ * Compute a shift that guarantees that shifting chunksPerBlock with it
+ * yields is smaller than SLAB_FREELIST_COUNT - 1 (one freelist is used for full blocks).
+ */
+ slab->freelist_shift = 0;
+ while ((slab->chunksPerBlock >> slab->freelist_shift) >= (SLAB_FREELIST_COUNT - 1))
+ slab->freelist_shift++;

+ /*
+ * Ensure, without a branch, that index 0 is only used for blocks entirely
+ * without free chunks.
+ * XXX: There probably is a cheaper way to do this. Needing to shift twice
+ * by slab->freelist_shift isn't great.
+ */
+ index = (freecount + (1 << slab->freelist_shift) - 1) >> slab->freelist_shift;

How about something like

#define SLAB_FREELIST_COUNT ((1<<3) + 1)
index = (freecount & (SLAB_FREELIST_COUNT - 2)) + (freecount != 0);

and dispense with both freelist_shift and the loop that computes it?

--
John Naylor
EDB: http://www.enterprisedb.com

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

Предыдущее
От: Japin Li
Дата:
Сообщение: Re: Typo about subxip in comments
Следующее
От: John Naylor
Дата:
Сообщение: Re: Use pg_pwritev_with_retry() instead of write() in dir_open_for_write() to avoid partial writes?