forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commit34db06e
committed
shm_mq: Reduce spinlock usage.
Previously, mq_bytes_read and mq_bytes_written were protected by thespinlock, but that turns out to cause pretty serious spinlockcontention on queries which send many tuples through a Gather orGather Merge node. This patches changes things so that we insteadread and write those values using 8-byte atomics. Since mq_bytes_readcan only be changed by the receiver and mq_bytes_written can only bechanged by the sender, the only purpose of the spinlock is to preventreads and writes of these values from being torn on platforms where8-byte memory access is not atomic, making the conversion fairlystraightforward.Testing shows that this produces some slowdown if we're using emulated64-bit atomics, but since they should be available on any platformwhere 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 thedesign. Also tested by Rafia Sabih.Discussion:http://postgr.es/m/CA+TgmoYuK0XXxmUNTFT9TSNiBtWnRwasBcHHRCOK9iYmDLQVPg@mail.gmail.com1 parent2b8c94e commit34db06e
1 file changed
+129
-122
lines changed0 commit comments
Comments
(0)