RE: Improve eviction algorithm in ReorderBuffer - Mailing list pgsql-hackers

From Hayato Kuroda (Fujitsu)
Subject RE: Improve eviction algorithm in ReorderBuffer
Date
Msg-id OSBPR01MB2552025406D6DEBF7EB8FDA7F5052@OSBPR01MB2552.jpnprd01.prod.outlook.com
Whole thread Raw
In response to Re: Improve eviction algorithm in ReorderBuffer  (Heikki Linnakangas <hlinnaka@iki.fi>)
Responses Re: Improve eviction algorithm in ReorderBuffer
List pgsql-hackers
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/ 


Attachment

pgsql-hackers by date:

Previous
From: David Steele
Date:
Subject: [MASSMAIL]pg_combinebackup does not detect missing files
Next
From: David Steele
Date:
Subject: Re: post-freeze damage control