Re: Shared buffers, db transactions commited, and write IO on Solaris - Mailing list pgsql-performance
From | Erik Jones |
---|---|
Subject | Re: Shared buffers, db transactions commited, and write IO on Solaris |
Date | |
Msg-id | 84D24979-AF34-4875-9AFB-DD4A7814B99A@myemma.com Whole thread Raw |
In response to | Re: Shared buffers, db transactions commited, and write IO on Solaris (Dimitri <dimitrik.fr@gmail.com>) |
Responses |
Re: Shared buffers, db transactions commited, and write IO on Solaris
|
List | pgsql-performance |
On Mar 29, 2007, at 5:15 PM, Dimitri wrote:
>>> Erik,>> using 'forcedirectio' simply brings your write operations to the> *real* volume - means while you need to write 10 bytes you'll write 10> bytes (instead of UFS block size (8K)). So it explains me why your> write volume became slower.I men 'lower' (not slower)Sorry, that's not true. Google "ufs forcedirectio" go to the firstlink and you will find:"forcedirectioThe forcedirectio (read "force direct IO") UFS option causes data tobe buffered in kernel address whenever data is transferred betweenuser address space and the disk. In other words, it bypasses the filesystem cache. For certain types of applications -- primarily databasesystems -- this option can dramatically improve performance. In fact,some database experts have argued that a file using the forcedirectiooption will outperform a raw partition, though this opinion seemsfairly controversial.The forcedirectio improves file system performance by eliminatingdouble buffering, providing a small, efficient code path for filesystem reads and writes and removing pressure on memory."Erik, please, don't take me wrong, but reading Google (or better man pages)don't replace brain and basic practice... Direct IO option is not a silverbullet which will solve all your problems (try to do 'cp' on the mounted in'forcedirectio' filesystem, or use your mailbox on it - you'll quicklyunderstand impact)...However, what this does mean is that writes will be at the actualfilesystem block size and not the cache block size (8K v. 512K).while UFS filesystem mounted normally, it uses its own cache for alloperations (read and write) and saves data modifications on perpage basis, means: when a process writes 200 bytes there will be 200bytes modified in cache, then whole page is written (8K) once datademanded to be flushed (and WAL is writing per each commit)...Now, mounted with 'forcedirectio' option UFS is free of page size constraintand will write like a raw device an exactly demanded amount of data, means:when a process writes 200 bytes it'll write exactly 200 bytes to the disk. =
You are right in that the page size constraint is lifted in that directio cuts out the VM filesystem cache. However, the Solaris kernel still issues io ops in terms of its logical block size (which we have at the default 8K). It can issue io ops for fragments as small as 1/8th of the block size, but Postgres issues its io requests in terms of the block size which means that io ops from Postgres will be in 8K chunks which is exactly what we see when we look at our system io stats. In fact, if any io request is made that isn't a multiple of 512 bytes (the disk sector size), the file system switches back to the buffered io.
However, to understand TX number mystery I think the only possible solutionis to reproduce a small live test:(I'm sure you're aware you can mount/unmount forcedirectio dynamically?)during stable workload do:# mount -o remount,logging /path_to_your_filesystemand check if I/O volume is increasing as well TX numbersthan come back:# mount -o remount,forcedirectio /path_to_your_filesystemand see if I/O volume is decreasing as well TX numbers...
That's an excellent idea and I'll run it by the rest of our team tomorrow.
erik jones <erik@myemma.com>
software developer
615-296-0838
emma(r)
pgsql-performance by date: