Re: Improve eviction algorithm in ReorderBuffer
| От | Jeff Davis |
|---|---|
| Тема | Re: Improve eviction algorithm in ReorderBuffer |
| Дата | |
| Msg-id | 12747c15811d94efcc5cda72d6b35c80d7bf3443.camel@j-davis.com обсуждение исходный текст |
| Ответ на | Re: Improve eviction algorithm in ReorderBuffer (Masahiko Sawada <sawada.mshk@gmail.com>) |
| Ответы |
Re: Improve eviction algorithm in ReorderBuffer
|
| Список | pgsql-hackers |
On Mon, 2024-04-01 at 12:42 +0900, Masahiko Sawada wrote:
> While reviewing the patches, I realized the comment of
> binearyheap_allocate() should also be updated. So I've attached the
> new patches.
In sift_{up|down}, each loop iteration calls set_node(), and each call
to set_node does a hash lookup. I didn't measure it, but that feels
wasteful.
I don't even think you really need the hash table. The key to the hash
table is a pointer, so it's not really doing anything that couldn't be
done more efficiently by just following the pointer.
I suggest that you add a "heap_index" field to ReorderBufferTXN that
would point to the index into the heap's array (the same as
bh_nodeidx_entry.index in your patch). Each time an element moves
within the heap array, just follow the pointer to the ReorderBufferTXN
object and update the heap_index -- no hash lookup required.
That's not easy to do with the current binaryheap API. But a binary
heap is not a terribly complex structure, so you can just do an inline
implementation of it where sift_{up|down} know to update the heap_index
field of the ReorderBufferTXN.
Regards,
Jeff Davis
В списке pgsql-hackers по дате отправления: