From: | Robert Haas <rhaas(at)postgresql(dot)org> |
---|---|
To: | pgsql-committers(at)postgresql(dot)org |
Subject: | pgsql: shm_mq: Reduce spinlock usage. |
Date: | 2018-03-02 17:19:58 |
Message-ID: | E1eroLe-0003nE-NJ@gemulon.postgresql.org |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-committers |
shm_mq: Reduce spinlock usage.
Previously, mq_bytes_read and mq_bytes_written were protected by the
spinlock, but that turns out to cause pretty serious spinlock
contention on queries which send many tuples through a Gather or
Gather Merge node. This patches changes things so that we instead
read and write those values using 8-byte atomics. Since mq_bytes_read
can only be changed by the receiver and mq_bytes_written can only be
changed by the sender, the only purpose of the spinlock is to prevent
reads and writes of these values from being torn on platforms where
8-byte memory access is not atomic, making the conversion fairly
straightforward.
Testing shows that this produces some slowdown if we're using emulated
64-bit atomics, but since they should be available on any platform
where performance is a primary concern, that seems OK. It's faster,
sometimes a lot faster, on platforms where such atomics are available.
Patch by me, reviewed by Andres Freund, who also suggested the
design. Also tested by Rafia Sabih.
Discussion: http://postgr.es/m/CA+TgmoYuK0XXxmUNTFT9TSNiBtWnRwasBcHHRCOK9iYmDLQVPg@mail.gmail.com
Branch
------
master
Details
-------
https://git.postgresql.org/pg/commitdiff/34db06ef9a1d7f36391c64293bf1e0ce44a33915
Modified Files
--------------
src/backend/storage/ipc/shm_mq.c | 251 ++++++++++++++++++++-------------------
1 file changed, 129 insertions(+), 122 deletions(-)
From | Date | Subject | |
---|---|---|---|
Next Message | Robert Haas | 2018-03-02 17:21:33 | pgsql: shm_mq: Have the receiver set the sender's less frequently. |
Previous Message | Fujii Masao | 2018-03-02 16:42:17 | pgsql: Improve tab-completion for ALTER INDEX RESET/SET. |