Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1UPSeL-0005Cm-Hw for pgsql-hackers@arkaria.postgresql.org; Tue, 09 Apr 2013 07:07:25 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.72) (envelope-from ) id 1UPSeK-00067R-VS for pgsql-hackers@arkaria.postgresql.org; Tue, 09 Apr 2013 07:07:25 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1UPSeK-00067M-5B for pgsql-hackers@postgresql.org; Tue, 09 Apr 2013 07:07:24 +0000 Received: from szxga02-in.huawei.com ([119.145.14.65]) by magus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1UPSeE-0005yl-94 for pgsql-hackers@postgresql.org; Tue, 09 Apr 2013 07:07:23 +0000 Received: from 172.24.2.119 (EHLO szxeml205-edg.china.huawei.com) ([172.24.2.119]) by szxrg02-dlp.huawei.com (MOS 4.3.4-GA FastPath queued) with ESMTP id AZT70284; Tue, 09 Apr 2013 15:07:07 +0800 (CST) Received: from SZXEML460-HUB.china.huawei.com (10.82.67.203) by szxeml205-edg.china.huawei.com (172.24.2.58) with Microsoft SMTP Server (TLS) id 14.1.323.7; Tue, 9 Apr 2013 15:07:05 +0800 Received: from blrprnc09ns (10.18.96.98) by szxeml460-hub.china.huawei.com (10.82.67.203) with Microsoft SMTP Server id 14.1.323.7; Tue, 9 Apr 2013 15:07:04 +0800 From: Amit Kapila To: "'Robert Haas'" CC: "'Greg Smith'" , References: <29181.1363981925@sss.pgh.pa.us> <29748.1363983378@sss.pgh.pa.us> <20130401210920.GC7244@alap2.anarazel.de> <515A1393.9090908@nasby.net> <515CDC20.5090005@2ndQuadrant.com> <515e5d78.037ecd0a.4d15.ffff9299SMTPIN_ADDED_BROKEN@mx.google.com> <515f91fa.c212cd0a.236a.2ddfSMTPIN_ADDED_BROKEN@mx.google.com> In-Reply-To: Subject: Re: Page replacement algorithm in buffer cache Date: Tue, 9 Apr 2013 12:37:03 +0530 Message-ID: <006f01ce34f0$d6fa8220$84ef8660$@kapila@huawei.com> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Mailer: Microsoft Office Outlook 12.0 Thread-Index: Ac401ndUKX/uibyySAycMGGCsubq6AAGYqUA Content-Language: en-us X-Originating-IP: [10.18.96.98] X-CFilter-Loop: Reflected X-Pg-Spam-Score: -3.3 (---) 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 > -----Original Message----- > From: Robert Haas [mailto:robertmhaas@gmail.com] > Sent: Tuesday, April 09, 2013 9:28 AM > To: Amit Kapila > Cc: Greg Smith; pgsql-hackers@postgresql.org > Subject: Re: [HACKERS] Page replacement algorithm in buffer cache > > On Fri, Apr 5, 2013 at 11:08 PM, Amit Kapila > wrote: > > I still have one more doubt, consider the below scenario for cases > when we > > Invalidate buffers during moving to freelist v/s just move to > freelist > > > > Backend got the buffer from freelist for a request of page-9 > (number 9 is > > random, just to explain), it still have association with another > page-10 > > It needs to add the buffer with new tag (new page association) in > bufhash > > table and remove the buffer with oldTag (old page association). > > > > The benefit for just moving to freelist is that if we get request of > same > > page until somebody else used it for another page, it will save read > I/O. > > However on the other side for many cases > > Backend will need extra partition lock to remove oldTag (which can > lead to > > some bottleneck). > > > > I think saving read I/O is more beneficial but just not sure if that > is best > > as cases might be less for it. > > I think saving read I/O is a lot more beneficial. I haven't seen > evidence of a severe bottleneck updating the buffer mapping tables. I > have seen some evidence of spinlock-level contention on read workloads > that fit in shared buffers, because in that case the system can run > fast enough for the spinlocks protecting the lwlocks to get pretty > hot. But if you're doing writes, or if the workload doesn't fit in > shared buffers, other bottlenecks slow you down enough that this > doesn't really seem to become much of an issue. > > Also, even if you *can* find some scenario where pushing the buffer > invalidation into the background is a win, I'm not convinced that > would justify doing it, because the case where it's a huge loss - > namely, working set just a tiny bit smaller than shared_buffers - is > pretty obvious. I don't think we dare fool around with that; the > townspeople will arrive with pitchforks. > > I believe that the big win here is getting the clock sweep out of the > foreground so that BufFreelistLock doesn't catch fire. The buffer > mapping locks are partitioned and, while it's not like that completely > gets rid of the contention, it sure does help a lot. So I would view > that goal as primary, at least for now. If we get a first round of > optimization done in this area, that doesn't preclude further > improving it in the future. I agree with you that this can be first step towards improvement. > > Last time following tests have been executed to validate the results: > > > > Test suite - pgbench > > DB Size - 16 GB > > RAM - 24 GB > > Shared Buffers - 2G, 5G, 7G, 10G > > Concurrency - 8, 16, 32, 64 clients > > Pre-warm the buffers before start of test > > > > Shall we try for any other scenario's or for initial test of patch > above are > > okay. > > Seems like a reasonable place to start. I shall work on this for first CF of 9.4. With Regards, Amit Kapila. -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers