Re: performance: use pread instead of lseek+read - Mailing list pgsql-patches

From Manfred Spraul
Subject Re: performance: use pread instead of lseek+read
Date
Msg-id 3E67A65C.7070206@colorfullife.com
Whole thread Raw
In response to Re: performance: use pread instead of lseek+read  (Bruce Momjian <pgman@candle.pha.pa.us>)
Responses Re: performance: use pread instead of lseek+read  (Bruce Momjian <pgman@candle.pha.pa.us>)
List pgsql-patches
Bruce Momjian wrote:

>BSD/OS doesn't have pread either.  Isn't pread() just a case of merging
>two system calls into one?  Does a single system call cause that much
>overhead?  I didn't think so.
>
>
As I wrote, in a microbenchmark lseek+read(,8192) was 10% slower than
pread(,,8192).

>Doesn't pread() do the lseek() internally anyway.
>
No. pread doesn't use the file pointer at all.
This is a  huge advantage if fds are shared: Two threads/processes can
read simultaneously from the same fd. This is impossible without pread -
there is only one file pointer, the threads would trash each others state.

Since postgresql doesn't share fds, the only advantage for postgresql is
the lower syscall overhead.

>>
>>
>>>- which benchmark would be interesting?
>>>
>>>
>>Something that measures the performance "in context", that is as part of
>>normal database activity, not just the syscall overhead.  pgbench is
>>notoriously hard to get reproducible numbers out of, but you could try
>>it if you like.
>>
>>
I'll try that.

--
    Manfred


pgsql-patches by date:

Previous
From: "Greg Sabino Mullane"
Date:
Subject: FAQ: Deleting all but one identical row
Next
From: Bruce Momjian
Date:
Subject: Re: psql \pset pager always for 7.3.2 (patch)