Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1UIzJL-0005ix-Hl for pgsql-hackers@arkaria.postgresql.org; Fri, 22 Mar 2013 10:34:59 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.72) (envelope-from ) id 1UIzJK-0007YX-TT for pgsql-hackers@arkaria.postgresql.org; Fri, 22 Mar 2013 10:34:58 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1UIzJJ-0007YR-Km for pgsql-hackers@postgresql.org; Fri, 22 Mar 2013 10:34:57 +0000 Received: from szxga01-in.huawei.com ([119.145.14.64]) by magus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1UIzJD-0007qs-OF for pgsql-hackers@postgresql.org; Fri, 22 Mar 2013 10:34:56 +0000 Received: from 172.24.2.119 (EHLO szxeml214-edg.china.huawei.com) ([172.24.2.119]) by szxrg01-dlp.huawei.com (MOS 4.3.4-GA FastPath queued) with ESMTP id AZN07343; Fri, 22 Mar 2013 18:34:48 +0800 (CST) Received: from SZXEML406-HUB.china.huawei.com (10.82.67.93) by szxeml214-edg.china.huawei.com (172.24.2.29) with Microsoft SMTP Server (TLS) id 14.1.323.7; Fri, 22 Mar 2013 18:33:38 +0800 Received: from blrprnc09ns (10.18.96.98) by szxeml406-hub.china.huawei.com (10.82.67.93) with Microsoft SMTP Server id 14.1.323.7; Fri, 22 Mar 2013 18:33:40 +0800 From: Amit Kapila To: "'Atri Sharma'" CC: "'Pg Hackers'" References: <514bf302.84d5440a.43f2.ffffe411SMTPIN_ADDED_BROKEN@mx.google.com> <08BBC126-D375-4743-B9A6-D1320D05D5C7@gmail.com> In-Reply-To: <08BBC126-D375-4743-B9A6-D1320D05D5C7@gmail.com> Subject: Re: Page replacement algorithm in buffer cache Date: Fri, 22 Mar 2013 16:03:39 +0530 Message-ID: <007801ce26e8$b86e0810$294a1830$@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: Ac4mxro4yxGJBnXdQt6BBgoF3dkaLwAIT7xg 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 12:00 PM Atri Sharma wrote: > > > Sent from my iPad > > On 22-Mar-2013, at 11:28, Amit Kapila wrote: > > > 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. > > > > Hmm,so in the second pass,it gets replaced,right? Yes. > I think that if the initialization of USAGE_COUNT starts at the maximum > allowed value instead of one, we can have a better solution to this > problem. So what is your idea, if you start at maximum, what we will do for further accesses to it? Why do you want to give more priority to just loaded page? > Another,more complex solution could be to introduce an ageing factor as > well. 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