RE: Improve eviction algorithm in ReorderBuffer
Hayato Kuroda (Fujitsu) <kuroda.hayato@fujitsu.com>
From: "Hayato Kuroda (Fujitsu)" <kuroda.hayato@fujitsu.com>
To: 'Heikki Linnakangas' <hlinnaka@iki.fi>, Masahiko Sawada <sawada.mshk@gmail.com>
Cc: Michael Paquier <michael@paquier.xyz>, Jeff Davis <pgsql@j-davis.com>, vignesh C <vignesh21@gmail.com>, Peter Smith <smithpb2250@gmail.com>, Tomas
Vondra <tomas.vondra@enterprisedb.com>, Shubham Khanna <khannashubham1197@gmail.com>, Dilip Kumar <dilipbalaut@gmail.com>, PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>, Amit Kapila <amit.kapila16@gmail.com>
Date: 2024-04-11T01:46:37Z
Lists: pgsql-hackers
Attachments
- patchset.zip (application/x-zip-compressed)
Dear Heikki, I also prototyped the idea, which has almost the same shape. I attached just in case, but we may not have to see. Few comments based on the experiment. ``` + /* txn_heap is ordered by transaction size */ + buffer->txn_heap = pairingheap_allocate(ReorderBufferTXNSizeCompare, NULL); ``` I think the pairing heap should be in the same MemoryContext with the buffer. Can we add MemoryContextSwithTo()? ``` + /* Update the max-heap */ + if (oldsize != 0) + pairingheap_remove(rb->txn_heap, &txn->txn_node); + pairingheap_add(rb->txn_heap, &txn->txn_node); ... + /* Update the max-heap */ + pairingheap_remove(rb->txn_heap, &txn->txn_node); + if (txn->size != 0) + pairingheap_add(rb->txn_heap, &txn->txn_node); ``` Since the number of stored transactions does not affect to the insert operation, we may able to add the node while creating ReorederBufferTXN and remove while cleaning up it. This can reduce branches in ReorderBufferChangeMemoryUpdate(). Best Regards, Hayato Kuroda FUJITSU LIMITED https://www.fujitsu.com/
Commits
-
Revert indexed and enlargable binary heap implementation.
- 810f64a01567 17.0 landed
-
Replace binaryheap + index with pairingheap in reorderbuffer.c
- efb8acc0d058 17.0 landed
-
Improve eviction algorithm in ReorderBuffer using max-heap for many subtransactions.
- 5bec1d6bc5e3 17.0 landed
-
Add functions to binaryheap for efficient key removal and update.
- b84050864415 17.0 landed
-
Make binaryheap enlargeable.
- bcb14f4abca0 17.0 landed