Re: [POC] Faster processing at Gather node
Rafia Sabih <rafia.sabih@enterprisedb.com>
On Sat, Sep 9, 2017 at 8:14 AM, Amit Kapila <amit.kapila16@gmail.com> wrote: > On Fri, Sep 8, 2017 at 11:07 PM, Alexander Kuzmenkov > <a.kuzmenkov@postgrespro.ru> wrote: >> Hi Rafia, >> >> I like the idea of reducing locking overhead by sending tuples in bulk. The >> implementation could probably be simpler: you could extend the API of shm_mq >> to decouple notifying the sender from actually putting data into the queue >> (i.e., make shm_mq_notify_receiver public and make a variant of shm_mq_sendv >> that doesn't send the notification). >> > > Rafia can comment on details, but I would like to bring it to your > notice that we need kind of local buffer (queue) for gathermerge > processing as well where the data needs to be fetched in order from > queues. So, there is always a chance that some of the workers have > filled their queues while waiting for the master to extract the data. > I think the patch posted by Rafia on the nearby thread [1] addresses > both the problems by one patch. > > > [1] - https://www.postgresql.org/message-id/CAOGQiiNiMhq5Pg3LiYxjfi2B9eAQ_q5YjS%3DfHiBJmbSOF74aBQ%40mail.gmail.com > Thanks Alexander for your interest in this work. As rightly pointed out by Amit, when experimenting with this patch we found that there are cases when master is busy and unable to read tuples in shared_queue and the worker get stuck as it can not process tuples any more. When experimenting aong these lines, I found that Q12 of TPC-H is showing great performance improvement when increasing shared_tuple_queue_size [1]. It was then we realised that merging this with the idea of giving an illusion of larger tuple queue size with a local queue[1] could be more beneficial. To precisely explain the meaning of merging the two ideas, now we write tuples in local_queue once shared_queue is full and as soon as we have filled some enough tuples in local queue we copy the tuples from local to shared queue in one memcpy call. It is giving good performance improvements for quite some cases. I'll be glad if you may have a look at this patch and enlighten me with your suggestions. :-) [1] - https://www.postgresql.org/message-id/CAOGQiiNiMhq5Pg3LiYxjfi2B9eAQ_q5YjS%3DfHiBJmbSOF74aBQ%40mail.gmail.com -- Regards, Rafia Sabih EnterpriseDB: http://www.enterprisedb.com/
Commits
-
C comment: fix wording about shared memory message queue
- bc0021ef09ec 11.0 landed
-
shm_mq: Have the receiver set the sender's less frequently.
- 497171d3e2aa 11.0 landed
-
shm_mq: Reduce spinlock usage.
- 34db06ef9a1d 11.0 landed
-
Remove use of byte-masking macros in record_image_cmp
- 0b5e33f667a2 11.0 cited
-
Remove memory leak protection from Gather and Gather Merge nodes.
- 9f4992e2a993 11.0 landed
-
Avoid projecting tuples unnecessarily in Gather and Gather Merge.
- b10967eddf96 11.0 landed
-
Tweak use of ExecContextForcesOids by Gather (Merge).
- 0510421ee091 11.0 landed
-
Pass eflags down to parallel workers.
- f455e1125e25 11.0 landed
-
Disable installcheck tests for test_session_hooks
- 745948422c79 11.0 cited
-
First-draft release notes for 10.1.
- 42de8a0255c2 11.0 cited
-
Remove TupleDesc remapping logic from tqueue.c.
- 6b65a7fe62e1 11.0 cited
-
Avoid memory leaks when a GatherMerge node is rescanned.
- 2d44c58c79ae 11.0 cited
-
Code review for nodeGatherMerge.c.
- 04e9678614ec 11.0 cited
-
Add a Gather Merge executor node.
- 355d3993c53e 10.0 cited
-
Push scan/join target list beneath Gather when possible.
- 992b5ba30dca 9.6.0 cited