mirror of
https://github.com/postgres/postgres.git
synced 2025-11-21 00:42:43 +03:00
shm_mq: Update mq_bytes_written less often.
Do not update shm_mq's mq_bytes_written until we have written an amount of data greater than 1/4th of the ring size, unless the caller of shm_mq_send(v) requests a flush at the end of the message. This reduces the number of calls to SetLatch(), and also the number of CPU cache misses, considerably, and thus makes shm_mq significantly faster. Dilip Kumar, reviewed by Zhihong Yu and Tomas Vondra. Some minor cosmetic changes by me. Discussion: http://postgr.es/m/CAFiTN-tVXqn_OG7tHNeSkBbN+iiCZTiQ83uakax43y1sQb2OBA@mail.gmail.com
This commit is contained in:
@@ -154,7 +154,12 @@ mq_putmessage(char msgtype, const char *s, size_t len)
|
||||
|
||||
for (;;)
|
||||
{
|
||||
result = shm_mq_sendv(pq_mq_handle, iov, 2, true);
|
||||
/*
|
||||
* Immediately notify the receiver by passing force_flush as true so
|
||||
* that the shared memory value is updated before we send the parallel
|
||||
* message signal right after this.
|
||||
*/
|
||||
result = shm_mq_sendv(pq_mq_handle, iov, 2, true, true);
|
||||
|
||||
if (pq_mq_parallel_leader_pid != 0)
|
||||
SendProcSignal(pq_mq_parallel_leader_pid,
|
||||
|
||||
Reference in New Issue
Block a user