Re: performance: use pread instead of lseek+read

From: Manfred Spraul <manfred(at)colorfullife(dot)com>
To: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, pgsql-patches(at)postgresql(dot)org
Subject: Re: performance: use pread instead of lseek+read
Date: 2003-03-06 19:49:48
Message-ID: 3E67A65C.7070206@colorfullife.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

In response to

Responses

Browse pgsql-patches by date

  From Date Subject
Next Message Bruce Momjian 2003-03-06 20:04:43 Re: [PATCHES] psql \pset pager always for 7.3.2 (patch)
Previous Message Greg Sabino Mullane 2003-03-06 19:27:27 FAQ: Deleting all but one identical row