On Wed, 8 Apr 2009, Heikki Linnakangas wrote:

Josh Berkus wrote:
The other thing I was going to ask you about is using posix_fadvise as an alternative to O_DIRECT for the xlog. O_DIRECT is, AFAIK, linux-only, whereas there are "direct write" fadvise flags which work on multiple OSes.

What flags are those? I don't see any posix_fadvise flags that would do anything like O_DIRECT.

A good implementation of FADV_NOREUSE would work similarly to O_DIRECT, writing things out but not keeping them around the OS cache. (suggested long ago even: http://archives.postgresql.org//pgsql-hackers/2003-10/msg01492.php )

I know there's a problem with O_DIRECT not working on Solaris; see the following:

http://blogs.sun.com/jkshah/entry/postgresql_wal_sync_method_and
http://blogs.sun.com/roch/entry/zfs_and_directio
http://docs.sun.com/app/docs/doc/816-5168/directio-3c

I'm not sure whether using an fadvise call like FADV_NOREUSE will work any better though; it may be the case that only that directio call is sufficient on Solaris. A Solaris-specific code path that calls directio is what MySQL does here: http://dev.mysql.com/doc/refman/5.1/en/innodb-parameters.html#sysvar_innodb_flush_method

I wanted to include such a patch in 8.4 but my one Solaris project got sidelined.

Saying that O_DIRECT is "linux-only" doesn't seem right though. The same thread referenced above started by announcing O_DIRECT support on FreeBSD: http://archives.postgresql.org//pgsql-hackers/2003-10/msg01482.php and the above MySQL documentation supports that it works on FreeBSD, too. I've seen claims that it works fine on Mac OS X, too, although MySQL may not support that:
http://labs.cybozu.co.jp/blog/kazuhoatwork/2009/02/using_o_direct_on_mac_os_x.php

--
* Greg Smith gsm...@gregsmith.com http://www.gregsmith.com Baltimore, MD

--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

Reply via email to