Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1UuLmJ-00070q-26 for pgsql-hackers@arkaria.postgresql.org; Wed, 03 Jul 2013 12:03:19 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1UuLmI-0001DU-Gz for pgsql-hackers@arkaria.postgresql.org; Wed, 03 Jul 2013 12:03:18 +0000 Received: from makus.postgresql.org ([2001:4800:7903:4::125]) by malur.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1UuLmH-0001DN-BH for pgsql-hackers@postgresql.org; Wed, 03 Jul 2013 12:03:17 +0000 Received: from szxga03-in.huawei.com ([119.145.14.66]) by makus.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1UuLmE-0001Gs-7T for pgsql-hackers@postgresql.org; Wed, 03 Jul 2013 12:03:16 +0000 Received: from 172.24.2.119 (EHLO szxeml209-edg.china.huawei.com) ([172.24.2.119]) by szxrg03-dlp.huawei.com (MOS 4.4.2a-FCS FastPath queued) with ESMTP id ABN72748; Wed, 03 Jul 2013 19:57:31 +0800 (CST) Received: from SZXEML404-HUB.china.huawei.com (10.82.67.59) by szxeml209-edg.china.huawei.com (172.24.2.184) with Microsoft SMTP Server (TLS) id 14.1.323.7; Wed, 3 Jul 2013 19:56:03 +0800 Received: from blrprnc09ns (10.18.96.98) by szxeml404-hub.china.huawei.com (10.82.67.59) with Microsoft SMTP Server id 14.1.323.7; Wed, 3 Jul 2013 19:56:03 +0800 From: Amit Kapila To: "'Simon Riggs'" CC: "'Robert Haas'" , "'Andres Freund'" , "'Greg Smith'" , "'PostgreSQL-development'" References: <51928CDA.7030009@2ndQuadrant.com> <5194eb32.85d60e0a.1c17.2253SMTPIN_ADDED_BROKEN@mx.google.com> <519b1d5f.9025b40a.2d07.ffffed08SMTPIN_ADDED_BROKEN@mx.google.com> <519f060c.cade440a.493f.ffffb080SMTPIN_ADDED_BROKEN@mx.google.com> <51b033cf.25dc420a.1edd.ffff8fd9SMTPIN_ADDED_BROKEN@mx.google.com> <51cada34.c31b0f0a.2927.7bfbSMTPIN_ADDED_BROKEN@mx.google.com> <4174155236987592579@unknownmsgid> In-Reply-To: Subject: Re: Move unused buffers to freelist Date: Wed, 3 Jul 2013 17:26:02 +0530 Message-ID: <002d01ce77e4$4b015370$e103fa50$@kapila@huawei.com> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable X-Mailer: Microsoft Office Outlook 12.0 Thread-Index: Ac53unpPbfXwqi/GTumowwCP9oMoJgAKSOHQ Content-Language: en-us X-Originating-IP: [10.18.96.98] X-CFilter-Loop: Reflected X-Pg-Spam-Score: -1.6 (-) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-hackers Precedence: bulk Sender: pgsql-hackers-owner@postgresql.org On Wednesday, July 03, 2013 12:27 PM Simon Riggs wrote: On 28 June 2013 05:52, Amit Kapila wrote: =A0 >> As per my understanding Summarization of points raised by you and Andres >> which this patch should address to have a bigger win: >> 1. Bgwriter needs to be improved so that it can help in reducing usage count >> and finding next victim buffer >>=A0 =A0(run the clock sweep and add buffers to the free list). >>2. SetLatch for bgwriter (wakeup bgwriter) when elements in freelist are >>less. >>3. Split the workdone globallock (Buffreelist) in StrategyGetBuffer >>=A0 =A0(a spinlock for the freelist, and an lwlock for the clock sweep). >>4. Separate processes for writing dirty buffers and moving buffers to >>freelist >>5. Bgwriter needs to be more aggressive, logic based on which it calculates >>how many buffers it needs to process needs to be improved. >>6. There can be contention around buffer mapping locks, but we can focus on >>it later >>7. cacheline bouncing around the buffer header spinlocks, is there anything >>we can do to reduce this? >My perspectives here would be > * BufFreelistLock is a huge issue. Finding a next victim block needs to be an O(1) operation, yet it is currently much worse than that. Measuring=20 > contention on that lock hides that problem, since having shared buffers lock up for 100ms or more but only occasionally is a huge problem, even if it=20 > doesn't occur frequently enough for the averaged contention to show as an issue. To optimize finding next victim buffer, I am planning to run the clock sweep in background. Apart from that do you have any idea to make it closer to O(1)? With Regards, Amit Kapila. --=20 Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers