diff options
author | Robert Haas <rhaas@postgresql.org> | 2021-10-14 16:06:43 -0400 |
---|---|---|
committer | Robert Haas <rhaas@postgresql.org> | 2021-10-14 16:13:36 -0400 |
commit | 46846433a03dff4f2e08c8a161e54a842da360d6 (patch) | |
tree | 668e9ff626ab6b3b8708dcb4e6b27748db6d7a66 /src/test/modules | |
parent | 7821a0bf2096df659671924fbeef0ebc66449292 (diff) | |
download | postgresql-46846433a03dff4f2e08c8a161e54a842da360d6.tar.gz postgresql-46846433a03dff4f2e08c8a161e54a842da360d6.zip |
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
Diffstat (limited to 'src/test/modules')
-rw-r--r-- | src/test/modules/test_shm_mq/test.c | 7 | ||||
-rw-r--r-- | src/test/modules/test_shm_mq/worker.c | 2 |
2 files changed, 5 insertions, 4 deletions
diff --git a/src/test/modules/test_shm_mq/test.c b/src/test/modules/test_shm_mq/test.c index 2d8d695f97a..be074f08a31 100644 --- a/src/test/modules/test_shm_mq/test.c +++ b/src/test/modules/test_shm_mq/test.c @@ -73,7 +73,7 @@ test_shm_mq(PG_FUNCTION_ARGS) test_shm_mq_setup(queue_size, nworkers, &seg, &outqh, &inqh); /* Send the initial message. */ - res = shm_mq_send(outqh, message_size, message_contents, false); + res = shm_mq_send(outqh, message_size, message_contents, false, true); if (res != SHM_MQ_SUCCESS) ereport(ERROR, (errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE), @@ -97,7 +97,7 @@ test_shm_mq(PG_FUNCTION_ARGS) break; /* Send it back out. */ - res = shm_mq_send(outqh, len, data, false); + res = shm_mq_send(outqh, len, data, false, true); if (res != SHM_MQ_SUCCESS) ereport(ERROR, (errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE), @@ -177,7 +177,8 @@ test_shm_mq_pipelined(PG_FUNCTION_ARGS) */ if (send_count < loop_count) { - res = shm_mq_send(outqh, message_size, message_contents, true); + res = shm_mq_send(outqh, message_size, message_contents, true, + true); if (res == SHM_MQ_SUCCESS) { ++send_count; diff --git a/src/test/modules/test_shm_mq/worker.c b/src/test/modules/test_shm_mq/worker.c index 2180776a669..9b037b98fe7 100644 --- a/src/test/modules/test_shm_mq/worker.c +++ b/src/test/modules/test_shm_mq/worker.c @@ -190,7 +190,7 @@ copy_messages(shm_mq_handle *inqh, shm_mq_handle *outqh) break; /* Send it back out. */ - res = shm_mq_send(outqh, len, data, false); + res = shm_mq_send(outqh, len, data, false, true); if (res != SHM_MQ_SUCCESS) break; } |