pg.ddx.io  pgsql-performance@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Alan Stange <stange@rentec.com>
To: PFC <lists@boutiquenumerique.com>
Cc: Kevin Brown <kevin@sysexperts.com>
Cc: pgsql-performance@postgresql.org
Subject: Re: How to improve db performance with $7K?
Date: Fri, 15 Apr 2005 09:11:48 -0400
Message-ID: <425FBD94.3060600@rentec.com> (raw)
In-Reply-To: <op.so9qe5y2th1vuj@localhost>
References: <d31f71$2epm$1@news.hub.org>
	<33c6269f050406151241b01148@mail.gmail.com>
	<20050406224102.GM93835@decibel.org>
	<33c6269f0504061732195f6ae4@mail.gmail.com>
	<87wtrfmgt5.fsf@stark.xeocode.com>
	<13449.1112847297@sss.pgh.pa.us>
	<20050414055655.GB19518@filer>
	<878y3lj23o.fsf@stark.xeocode.com>
	<20050414083608.GC19518@filer>
	<446.1113489854@sss.pgh.pa.us>
	<20050415020337.GD19518@filer>
	<op.so9qe5y2th1vuj@localhost>

PFC wrote:

>
>
>> My argument is that a sufficiently smart kernel scheduler *should*
>> yield performance results that are reasonably close to what you can
>> get with that feature.  Perhaps not quite as good, but reasonably
>> close.  It shouldn't be an orders-of-magnitude type difference.
>
>
>     And a controller card (or drive) has a lot less RAM to use as a 
> cache /  queue for reordering stuff than the OS has, potentially the 
> OS can us most  of the available RAM, which can be gigabytes on a big 
> server, whereas in  the drive there are at most a few tens of 
> megabytes...
>
>     However all this is a bit looking at the problem through the wrong 
> end.  The OS should provide a multi-read call for the applications to 
> pass a  list of blocks they'll need, then reorder them and read them 
> the fastest  possible way, clustering them with similar requests from 
> other threads.
>
>     Right now when a thread/process issues a read() it will block 
> until the  block is delivered to this thread. The OS does not know if 
> this thread  will then need the next block (which can be had very 
> cheaply if you know  ahead of time you'll need it) or not. Thus it 
> must make guesses, read  ahead (sometimes), etc...

All true.  Which is why high performance computing folks use 
aio_read()/aio_write() and load up the kernel with all the requests they 
expect to make. 

The kernels that I'm familiar with will do read ahead on files based on 
some heuristics:  when you read the first byte of a file the OS will 
typically load up several pages of the file (depending on file size, 
etc).  If you continue doing read() calls without a seek() on the file 
descriptor the kernel will get the hint that you're doing a sequential 
read and continue caching up the pages ahead of time, usually using the 
pages you just read to hold the new data so that one isn't bloating out 
memory with data that won't be needed again.  Throw in a seek() and the 
amount of read ahead caching may be reduced.


One point that is being missed in all this discussion is that the file 
system also imposes some constraints on how IO's can be done.  For 
example, simply doing a write(fd, buf, 100000000) doesn't emit a stream 
of sequential blocks to the drives.  Some file systems (UFS was one) 
would force portions of large files into other cylinder groups so that 
small files could be located near the inode data, thus avoiding/reducing 
the size of seeks.  Similarly, extents need to be allocated and the 
bitmaps recording this data usually need synchronous updates, which will 
require some seeks, etc.  Not to mention the need to update inode data, 
etc.  Anyway, my point is that the allocation policies of the file 
system can confuse the situation.

Also, the seek times one sees reported are an average.  One really needs 
to look at the track-to-track seek time and also the "full stoke" seek 
times.   It takes a *long* time to move the heads across the whole 
platter.  I've seen people partition drives to only use small regions of 
the drives to avoid long seeks and to better use the increased number of 
bits going under the head in one rotation.   A 15K drive doesn't need to 
have a faster seek time than a 10K drive because the rotational speed is 
higher.  The average seek time might be faster just because the 15K 
drives are smaller with fewer number of cylinders. 

-- Alan



view thread (119+ messages)  latest in thread

Message-ID: <425FBD94.3060600@rentec.com>
Permalink:  ../425FBD94.3060600@rentec.com/
Also on:    postgresql.org/message-id/425FBD94.3060600@rentec.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-performance@postgresql.org
  Cc: stange@rentec.com, lists@boutiquenumerique.com, kevin@sysexperts.com
  Subject: Re: How to improve db performance with $7K?
  In-Reply-To: <425FBD94.3060600@rentec.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox