Re: Use pread and pwrite instead of lseek + write and read

From: Oskari Saarenmaa <os(at)ohmu(dot)fi>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: Use pread and pwrite instead of lseek + write and read
Date: 2016-08-17 14:41:05
Message-ID: 7fdcb664-4f8a-8626-75df-ffde85005829@ohmu.fi
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

17.08.2016, 16:40, Tom Lane kirjoitti:
> Oskari Saarenmaa <os(at)ohmu(dot)fi> writes:
>> On my laptop a simple pgbench run (scale 100, 15 minutes) shows a 1.5%
>> performance improvement.
>
> I would have hoped for a lot better result before anyone would propose
> that we should deal with all the portability issues this'll create.

AFAICT pread and pwrite are available on pretty much all operating
systems released in 2000s; it was added to Linux in 1997. Windows and
HP-UX 10.20 don't have it, but we can just simulate it using lseek +
read/write there without adding too much code.

>> A 1.5% performance improvement is small but
>> measurable - and IMV more importantly it allows us to drop more than 100
>> lines of backwards (compatible?) code; maybe we could start targeting
>> more recent platforms in v10?
>
> That's basically nonsense: we'll end up adding way more than that to
> deal with platforms that haven't got these APIs.

Attached an updated patch that adds a configure check and uses
lseek+read/write instead pread/pwrite when the latter aren't available.
The previous code ended up seeking anyway in most of the cases and
pgbench shows no performance regression on my Linux box.

8 files changed, 54 insertions(+), 168 deletions(-)

/ Oskari

Attachment Content-Type Size
use-pread-pwrite-v2.patch application/x-patch 16.5 KB

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Craig Ringer 2016-08-17 14:44:40 Re: Are these supported??
Previous Message Craig Ringer 2016-08-17 14:39:16 Re: Why we lost Uber as a user