Skip site navigation (1) Skip section navigation (2)

Re: [HACKERS] O_DIRECT for WAL writes

From: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
To: ITAGAKI Takahiro <itagaki(dot)takahiro(at)lab(dot)ntt(dot)co(dot)jp>
Cc: pgsql-patches(at)postgresql(dot)org
Subject: Re: [HACKERS] O_DIRECT for WAL writes
Date: 2005-07-29 03:23:55
Message-ID: 200507290323.j6T3Ntb01826@candle.pha.pa.us (view raw or flat)
Thread:
Lists: pgsql-hackerspgsql-patches
Patch applied.  Thanks.

---------------------------------------------------------------------------


ITAGAKI Takahiro wrote:
> Thanks for reviewing!
> But the patch does not work on HEAD, because of the changes in BootStrapXLOG().
> I send the patch with a fix for it.
> 
> 
> Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us> wrote:
> 
> > If you are doing fsync(), I don't see how O_DIRECT
> > makes any sense because O_DIRECT is writing to disk on every write, and
> > then what is the fsync() actually doing.
> 
> It's depends on OSes. Manpage of Linux says,
>   http://linux.com.hk/PenguinWeb/manpage.jsp?name=open&section=2
>     File I/O is done directly to/from user space buffers. The I/O is
>     synchronous, i.e., at the completion of the read(2) or write(2) system
>     call, data is **guaranteed to have been transferred**.
> But manpage of FreeBSD says,
>   http://www.manpages.info/freebsd/open.2.html
>     O_DIRECT may be used to minimize or eliminate the cache effects of read-
>     ing and writing.  The system will attempt to avoid caching the data you
>     read or write.  If it cannot avoid caching the data,
>     it will **minimize the impact the data has on the cache**.
> 
> In my understanding, the completion of write() with O_DIRECT does not always
> assure an actual write. So there may be difference between O_DIRECT+O_SYNC
> and O_DIRECT+fsync(), but I think that is not very often.
> 
> 
> > What I did was to add O_DIRECT unconditionally for all uses of O_SYNC
> > and O_DSYNC, so it is automatically used in those cases.  And of course,
> > if your operating system doens't support O_DIRECT, it isn't used.
> 
> I agree with your way, where O_DIRECT is automatically used. 
> I bet the combination of O_DIRECT and O_SYNC is always better than
> the case O_SYNC only used.
> 
> ---
> ITAGAKI Takahiro
> NTT Cyber Space Laboratories
> 

[ Attachment, skipping... ]

> 
> ---------------------------(end of broadcast)---------------------------
> TIP 1: if posting/reading through Usenet, please send an appropriate
>        subscribe-nomail command to majordomo(at)postgresql(dot)org so that your
>        message can get through to the mailing list cleanly

-- 
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman(at)candle(dot)pha(dot)pa(dot)us               |  (610) 359-1001
  +  If your life is a hard drive,     |  13 Roberts Road
  +  Christ can be your backup.        |  Newtown Square, Pennsylvania 19073

In response to

pgsql-hackers by date

Next:From: Tom LaneDate: 2005-07-29 04:28:24
Subject: Re: Information Schema DBMS VERSION wrong
Previous:From: Qingqing ZhouDate: 2005-07-29 03:20:29
Subject: Re: Race conditions, race conditions!

pgsql-patches by date

Next:From: Neil ConwayDate: 2005-07-29 03:45:40
Subject: Re: Unused MMCacheLock
Previous:From: Bruce MomjianDate: 2005-07-29 03:17:40
Subject: Re: regexp_replace

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group