Received: from localhost (maia-3.hub.org [200.46.204.184]) by postgresql.org (Postfix) with ESMTP id 9C7C89FBB25 for ; Thu, 5 Apr 2007 18:06:18 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.184]) (amavisd-maia, port 10024) with ESMTP id 15031-10 for ; Thu, 5 Apr 2007 18:06:03 -0300 (ADT) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.4 Received: from an-out-0708.google.com (an-out-0708.google.com [209.85.132.243]) by postgresql.org (Postfix) with ESMTP id 70A469FB8BF for ; Thu, 5 Apr 2007 18:06:11 -0300 (ADT) Received: by an-out-0708.google.com with SMTP id c24so842021ana for ; Thu, 05 Apr 2007 14:06:10 -0700 (PDT) DKIM-Signature: a=rsa-sha1; c=relaxed/relaxed; d=gmail.com; s=beta; h=domainkey-signature:received:received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=JoUaQum4gYdPo2dtgrFmgKkideMFNsOGdg9qj+wpxCBKcYoUmWEUMrpcw+mgIcFP87fqKl3/eUYzUAWnGR49yR7Ey+JzMuFaD9KDsVHBoi9uMGsxTfae88M4kZdyR/R9JGZlHf2qGIiQTq50y9d2rLFZvl21gd65JYjpTlxml2Q= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=ttUAfQN2aHkXbmjBRBy3Skn8Dj/I2w7RMHT4kxngyi3x9d0uTeijmVb94Gx4Pd2rUp/adjjbcXKf1YqB30s2DIIYG5V3iPMPKifI32CykDEXeogAevI19g4/0CSkWahfacsbdtHZ4qPytuX+umFLc3bN3Tm9Oy+7XOYJ7igK9v8= Received: by 10.100.8.18 with SMTP id 18mr1633861anh.1175807169884; Thu, 05 Apr 2007 14:06:09 -0700 (PDT) Received: by 10.100.247.7 with HTTP; Thu, 5 Apr 2007 14:06:09 -0700 (PDT) Message-ID: Date: Thu, 5 Apr 2007 17:06:09 -0400 From: "Alex Deucher" To: "Xiaoning Ding" Subject: Re: a question about Direct I/O and double buffering Cc: "Erik Jones" , pgsql-performance@postgresql.org In-Reply-To: <461562F5.8070600@cse.ohio-state.edu> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <46152D5D.5030602@cse.ohio-state.edu> <4C4C834E-9304-4E23-AD15-1756921500B5@myemma.com> <46153E7D.7030208@cse.ohio-state.edu> <0F61A03E-DF77-46C2-B7E1-2E7A5F985FB8@myemma.com> <461562F5.8070600@cse.ohio-state.edu> X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200704/136 X-Sequence-Number: 24013 On 4/5/07, Xiaoning Ding wrote: > Alex Deucher wrote: > > On 4/5/07, Erik Jones wrote: > >> > >> On Apr 5, 2007, at 1:22 PM, Xiaoning Ding wrote: > >> > >> Erik Jones wrote: > >> On Apr 5, 2007, at 12:09 PM, Xiaoning Ding wrote: > >> Hi, > >> > >> A page may be double buffered in PG's buffer pool and in OS's buffer > >> cache. > >> Other DBMS like DB2 and Oracle has provided Direct I/O option to > >> eliminate > >> double buffering. I noticed there were discusses on the list. But > >> I can not find similar option in PG. Does PG support direct I/O now? > >> > >> The tuning guide of PG usually recommends a small shared buffer pool > >> (compared > >> to the size of physical memory). I think it is to avoid swapping. If > >> there were > >> swapping, OS kernel may swap out some pages in PG's buffer pool even PG > >> want to keep them in memory. i.e. PG would loose full control over > >> buffer pool. > >> A large buffer pool is not good because it may > >> 1. cause more pages double buffered, and thus decrease the efficiency of > >> buffer > >> cache and buffer pool. > >> 2. may cause swapping. > >> Am I right? > >> > >> If PG's buffer pool is small compared with physical memory, can I say > >> that the > >> hit ratio of PG's buffer pool is not so meaningful because most misses > >> can be > >> satisfied by OS Kernel's buffer cache? > >> > >> Thanks! > >> To the best of my knowledge, Postgres itself does not have a direct IO > >> option (although it would be a good addition). So, in order to use > >> direct > >> IO with postgres you'll need to consult your filesystem docs for how > >> to set > >> the forcedirectio mount option. I believe it can be set dynamically, > >> but if > >> you want it to be permanent you'll to add it to your fstab/vfstab file. > >> > >> I use Linux. It supports direct I/O on a per-file basis only. To > >> bypass OS > >> buffer cache, > >> files should be opened with O_DIRECT option. I afraid that I have to > >> modify > >> PG. > >> > >> Xiaoning > >> Looks like it. I just did a cursory search of the archives and it seems > >> that others have looked at this before so you'll probably want to start > >> there if your up to it. > >> > > > > Linux used to have (still does?) a RAW interface which might also be > > useful. I think the original code was contributed by oracle so they > > could support direct IO. > > > > Alex > I am more concerned with reads , and how to do direct I/O under Linux here. > Reading raw devices in linux bypasses OS buffer cache. But how can you > mount a raw device( it is a character device) as a file system? > In this case, I guess you'd probably have to do it within pg itself. Alex