Re: Avoid stack frame setup in performance critical routines using tail calls

Поиск
Список
Период
Сортировка
От John Naylor
Тема Re: Avoid stack frame setup in performance critical routines using tail calls
Дата
Msg-id CAFBsxsGdLkfqPdCFzQS-G7Gp6GXT44gT9M=3NYP67Dr3e_gWAA@mail.gmail.com
обсуждение исходный текст
Ответ на Re: Avoid stack frame setup in performance critical routines using tail calls  (Andres Freund <andres@anarazel.de>)
Список pgsql-hackers

On Wed, Jul 19, 2023 at 3:53 PM Andres Freund <andres@anarazel.de> wrote:
>
> Hi,
>
> David and I were chatting about this patch, in the context of his bump
> allocator patch.  Attached is a rebased version that is also split up into two
> steps, and a bit more polished.

Here is a quick test -- something similar was used to measure the slab improvements last cycle. With radix tree v37 0001-0011 from [1],

create extension bench_radix_tree;
select avg(load_ms) from generate_series(1,100) x(x), lateral (select * from bench_load_random_int(100 * 1000 * (1+x-x))) a;

The backend was pinned and turbo off. Perf runs were separate from timed runs. I included 0002 for completeness.

v37
         avg        
---------------------
 27.0400000000000000

  32.42%  postgres  bench_radix_tree.so  [.] rt_recursive_set
  21.60%  postgres  postgres             [.] SlabAlloc
  11.06%  postgres  [unknown]            [k] 0xffffffff930018f7
  10.49%  postgres  bench_radix_tree.so  [.] rt_extend_down
   7.07%  postgres  postgres             [.] MemoryContextAlloc
   4.83%  postgres  bench_radix_tree.so  [.] rt_node_insert_inner
   2.19%  postgres  bench_radix_tree.so  [.] rt_grow_node_48
   2.16%  postgres  bench_radix_tree.so  [.] rt_set.isra.0
   1.50%  postgres  bench_radix_tree.so  [.] MemoryContextAlloc@plt

v37 + palloc sibling calls
         avg        
---------------------
 26.0700000000000000

v37 + palloc sibling calls + opt aset
         avg        
---------------------
 26.0900000000000000

  33.78%  postgres  bench_radix_tree.so  [.] rt_recursive_set
  23.04%  postgres  postgres             [.] SlabAlloc
  11.43%  postgres  [unknown]            [k] 0xffffffff930018f7
  11.05%  postgres  bench_radix_tree.so  [.] rt_extend_down
   5.52%  postgres  bench_radix_tree.so  [.] rt_node_insert_inner
   2.47%  postgres  bench_radix_tree.so  [.] rt_set.isra.0
   2.30%  postgres  bench_radix_tree.so  [.] rt_grow_node_48
   1.88%  postgres  postgres             [.] MemoryContextAlloc
   1.44%  postgres  bench_radix_tree.so  [.] MemoryContextAlloc@plt

It's nice to see MemoryContextAlloc go down in the profile.

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

Предыдущее
От: "Hayato Kuroda (Fujitsu)"
Дата:
Сообщение: Suppress generating WAL records during the upgrade
Следующее
От: Hannu Krosing
Дата:
Сообщение: Re: How to build a new grammer for pg?