Received: from maia.hub.org (maia-3.hub.org [200.46.204.243]) by mail.postgresql.org (Postfix) with ESMTP id 8A47D1337BD5 for ; Sat, 30 Apr 2011 01:46:35 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.243]) (amavisd-maia, port 10024) with ESMTP id 34365-09 for ; Sat, 30 Apr 2011 04:46:27 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from moutng.kundenserver.de (moutng.kundenserver.de [212.227.126.187]) by mail.postgresql.org (Postfix) with ESMTP id 26E7D1337BFB for ; Sat, 30 Apr 2011 01:46:27 -0300 (ADT) Received: from [192.168.1.6] (mail.highperformancepostgresql.com [71.179.240.8]) by mrelayeu.kundenserver.de (node=mreu1) with ESMTP (Nemesis) id 0MEaJJ-1Q0Nwn0lth-00FmJ6; Sat, 30 Apr 2011 06:46:24 +0200 Message-ID: <4DBB9475.7080104@2ndQuadrant.com> Date: Sat, 30 Apr 2011 00:47:49 -0400 From: Greg Smith User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.1.16) Gecko/20110307 Icedove/3.0.11 MIME-Version: 1.0 To: Hsien-Wen Chu CC: Tom Lane , "pgsql-performance@postgresql.org" Subject: Re: VX_CONCURRENT flag on vxfs( 5.1 or later) for performance for postgresql? References: In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Provags-ID: V02:K0:i0R7u7Vz/sSUo+ug+MvHDRl10Fvw2UUGxmFL96s3y05 uhsSl9dKwQcitYzOUzjouND4ZZT8qxvXr2ZNi6gTMfDXJnx0lj CfiEdpT8deeI027nZC6hROtsLuEJaJfKJNAjx8U61qgrAj2koz S8S6ZXY1QENYQvakXKwp0pPADrPyrV1JZgEzVC5gr07Eu9T4XL 3F3QDbZBDYygMeWRQ5hSncdVCXDop8XbBBgdGEIsso= X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.9 tagged_above=-10 required=5 tests=BAYES_00=-1.9, RCVD_IN_DNSWL_NONE=-0.0001 X-Spam-Level: X-Archive-Number: 201104/431 X-Sequence-Number: 43493 On 04/30/2011 12:24 AM, Hsien-Wen Chu wrote: > I'm little bit confuse why it is not safe. and my question is following. > > for database application, we need to avoid double cache, PostgreSQL > shared_buffer will cache the data, so we do not want to file system to > cache the data right?. so the DIRECT IO is better, right?. > No. There are parts of PostgreSQL that expect the operating system to do write caching. Two examples are the transaction logs and the processing done by VACUUM. If you eliminate that with direct I/O, the slowdown can be much, much larger than what you gain by eliminating double-buffering on reads. On the read side, PostgreSQL also expects that operating system features like read-ahead are working properly. While this does introduce some double-buffering, the benefits for sequential scans are larger than that overhead, too. You may not get the expected read-ahead behavior if you use direct I/O. Direct I/O is not a magic switch that makes things faster; you have to very specifically write your application to work around what it does, good and bad, before it is expected to improves things. And PostgreSQL isn't written that way. It definitely requires OS caching to work well. > for VXFS, if the we use ioctl(fd,vx_cacheset,vx_concurrent) API, > according to the vxfs document, it will hold a shared lock for write > operation, but not the exclusive clock, also it is a direct IO, > There are very specific technical requirements that you must follow when using direct I/O. You don't get direct I/O without also following its alignment needs. Read the "Direct I/O best practices" section of http://people.redhat.com/msnitzer/docs/io-limits.txt for a quick intro to the subject. And there's this additional set of requirements you mention in order for this particular VXFS feature to work, which I can't even comment on. But you can be sure PostgreSQL doesn't try to do either of those things--it's definitely not aligning for direct I/O. Has nothing to do with ACID or the filesystem. Now, the VXFS implementation may do some tricks that bypass the alignment requirements. But even if you got it to work, it would still be slower for anything but some read-only workloads. Double buffering is really not that big of a performance problem, you just need to make sure you don't set shared_buffers to an extremely large value. -- Greg Smith 2ndQuadrant US greg@2ndQuadrant.com Baltimore, MD PostgreSQL Training, Services, and 24x7 Support www.2ndQuadrant.us "PostgreSQL 9.0 High Performance": http://www.2ndQuadrant.com/books