Re: Use pread and pwrite instead of lseek + write and read - Mailing list pgsql-hackers

From Oskari Saarenmaa
Subject Re: Use pread and pwrite instead of lseek + write and read
Date
Msg-id 7fdcb664-4f8a-8626-75df-ffde85005829@ohmu.fi
Whole thread Raw
In response to Re: Use pread and pwrite instead of lseek + write and read  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-hackers
17.08.2016, 16:40, Tom Lane kirjoitti:
> Oskari Saarenmaa <os@ohmu.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

pgsql-hackers by date:

Previous
From: Craig Ringer
Date:
Subject: Re: Why we lost Uber as a user
Next
From: Craig Ringer
Date:
Subject: Re: Are these supported??