Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1UIuzx-0002cj-0c for pgsql-hackers@arkaria.postgresql.org; Fri, 22 Mar 2013 05:58:41 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.72) (envelope-from ) id 1UIuzv-0001jo-Pp for pgsql-hackers@arkaria.postgresql.org; Fri, 22 Mar 2013 05:58:39 +0000 Received: from makus.postgresql.org ([2001:4800:7903:4::125]) by malur.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1UIuzu-0001ji-FW for pgsql-hackers@postgresql.org; Fri, 22 Mar 2013 05:58:38 +0000 Received: from szxga01-in.huawei.com ([119.145.14.64]) by makus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1UIuzn-00076X-MA for pgsql-hackers@postgresql.org; Fri, 22 Mar 2013 05:58:37 +0000 Received: from 172.24.2.119 (EHLO szxeml207-edg.china.huawei.com) ([172.24.2.119]) by szxrg01-dlp.huawei.com (MOS 4.3.4-GA FastPath queued) with ESMTP id AZM66307; Fri, 22 Mar 2013 13:58:29 +0800 (CST) Received: from SZXEML402-HUB.china.huawei.com (10.82.67.32) by szxeml207-edg.china.huawei.com (172.24.2.56) with Microsoft SMTP Server (TLS) id 14.1.323.7; Fri, 22 Mar 2013 13:58:20 +0800 Received: from blrprnc09ns (10.18.96.98) by szxeml402-hub.china.huawei.com (10.82.67.32) with Microsoft SMTP Server id 14.1.323.7; Fri, 22 Mar 2013 13:58:21 +0800 From: Amit Kapila To: "'Atri Sharma'" , "'Pg Hackers'" References: In-Reply-To: Subject: Re: Page replacement algorithm in buffer cache Date: Fri, 22 Mar 2013 11:28:19 +0530 Message-ID: <006201ce26c2$41bd77d0$c5386770$@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: Ac4muQ7Vb1GxR1iZSESXvcXLy1K//AABHlFA Content-Language: en-us X-Originating-IP: [10.18.96.98] X-CFilter-Loop: Reflected X-Pg-Spam-Score: -3.4 (---) 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 Friday, March 22, 2013 10:22 AM Atri Sharma wrote: > Hello all, > > Sorry if this is a naive question. > > I was going through Greg Smith's slides on buffer > cache(http://www.westnet.com/~gsmith/content/postgresql/InsideBufferCac > he.pdf). > When going through the page replacement algorithm that we use i.e. > clocksweep algorithm, I felt a potential problem in our current > system. > > Specifically, when a new entry is allocated in the buffer, it's > USAGE_COUNT is set to 1. On each sweep of the algorithm, the > USAGE_COUNT is decremented and an entry whose USAGE_COUNT becomes > zero is replaced. Yes, it is replaced but in the next clock sweep pass, not immediately after making 0. So till the time of next pass if nobody accesses the buffer and all other buffers have higher count, it can be replaced. Also the buffer, it has returned for which the usage count becomes 1, it will come to reduce the usage count only in next pass. So in whole, I think it needs 2 passes for a freshly returned buffer to be re-used incase no one uses it again. 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