diff options
author | Robert Haas <rhaas@postgresql.org> | 2018-03-02 12:16:59 -0500 |
---|---|---|
committer | Robert Haas <rhaas@postgresql.org> | 2018-03-02 12:16:59 -0500 |
commit | 34db06ef9a1d7f36391c64293bf1e0ce44a33915 (patch) | |
tree | 19479496e2811b7b118c338e48e9a5fe8bc6e04a /src/backend/utils/adt/ruleutils.c | |
parent | 2b8c94e1b4a86907fceef87840c32d3703f7e161 (diff) | |
download | postgresql-34db06ef9a1d7f36391c64293bf1e0ce44a33915.tar.gz postgresql-34db06ef9a1d7f36391c64293bf1e0ce44a33915.zip |
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
Diffstat (limited to 'src/backend/utils/adt/ruleutils.c')
0 files changed, 0 insertions, 0 deletions