prefetching and asynchronous io

From: johnlumby <johnlumby(at)hotmail(dot)com>
To: pgsql-hackers(at)postgresql(dot)org
Subject: prefetching and asynchronous io
Date: 2012-09-11 05:53:29
Message-ID: BLU0-SMTP31709961D846CCF4F5EB4C2A3930@phx.gbl
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 08/18/2012 10:11 AM, John Lumby wrote:
>
> I've recently tried extending the postgresql prefetch mechanism on linux
> to use the posix (i.e. librt)
> aio_read and friends where possible. In other words, in
> PrefetchBuffer(), try getting a buffer
> and issuing aio_read before falling back to fposix_advise(). It
> gives me about 8% improvement
> in throughput relative to the fposix-advise variety, for a workload of
> 16 highly-disk-read-intensive applications running to 16 backends.
> For my test each application runs a query chosen to have plenty of
> bitmap heap scans.
>
> I can provide more details on my changes if interested.
>
> On whether this technique might improve sort performance :
>
> First, the disk access pattern for sorting is mostly sequential
> (although I think
> the sort module does some tricky work with reuse of pages in its
> "logtape" files
> which maybe is random-like), and there are several claims on the net
> that linux buffered file handling
> already does a pretty good job of read-ahead for a sequential access
> pattern
> without any need for the application to help it.
> I can half-confirm that in that I tried adding calls to PrefetchBuffer
> in regular heap scan
> and did not see much improvement. But I am still pursuing that area.
>
> But second, it would be easy enough to add some fposix_advise calls to
> sort and see whether
> that helps. (Can't make use of PrefetchBuffer since sort does not use
> the regular relation buffer pool)
>

I have also added prefetching calls to regular index scans
(non-bitmap, non-index-only, for btree only)
and see a 25% reduction in total elapsed time for a heavy
index-scan workload. That 25% is with just the
basic posix_fadvise, and then extending that with asynch io
gives a small extra improvement again.

John

Browse pgsql-hackers by date

  From Date Subject
Next Message Stefan Kaltenbrunner 2012-09-11 06:27:49 Re: Draft release notes complete
Previous Message Jeff Davis 2012-09-11 05:44:57 Re: Question about SSI, subxacts, and aborted read-only xacts