From: | Oskari Saarenmaa <os(at)ohmu(dot)fi> |
---|---|
To: | pgsql-hackers(at)postgresql(dot)org |
Subject: | Use pread and pwrite instead of lseek + write and read |
Date: | 2016-08-17 07:58:09 |
Message-ID: | a86bd200-ebbe-d829-e3ca-0c4474b2fcb7@ohmu.fi |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
Hi,
The Uber blog post, among other things, pointed out that PG uses lseek +
read instead of pread. I didn't see any discussion around that and my
Google searches didn't find any posts about pread / pwrite for the past
10 years.
With that plus the "C++ port" thread in mind, I was wondering if it's
time to see if we could do better by just utilizing newer C and POSIX
features.
The attached patch replaces FileWrite and FileRead with FileWriteAt and
FileReadAt and removes most FileSeek calls. FileSeek is still around so
we can find the end of a file, but it's not used for anything else.
On my laptop a simple pgbench run (scale 100, 15 minutes) shows a 1.5%
performance improvement. 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?
Obviously this patch needs some more work before it could be merged, and
we probably still need a fallback for some platforms without pread and
pwrite (afaik Windows doesn't implement them.)
/ Oskari
Attachment | Content-Type | Size |
---|---|---|
use-pread-pwrite.patch | application/x-patch | 14.2 KB |
From | Date | Subject | |
---|---|---|---|
Next Message | Magnus Hagander | 2016-08-17 08:45:19 | Re: [RFC] Change the default of update_process_title to off |
Previous Message | Andrew Borodin | 2016-08-17 07:36:53 | Re: WIP: Covering + unique indexes. |