From: | Magnus Hagander <magnus(at)hagander(dot)net> |
---|---|
To: | Dagfinn Ilmari Mannsåker <ilmari(at)ilmari(dot)org> |
Cc: | Victor Wagner <vitus(at)wagner(dot)pp(dot)ru>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: Use pread and pwrite instead of lseek + write and read |
Date: | 2016-08-17 10:47:07 |
Message-ID: | CABUevEzF1eL02hkFbqhGmgguaq9PEKS49rWJwTU9kjHA0Hh6wA@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
On Wed, Aug 17, 2016 at 12:41 PM, Dagfinn Ilmari Mannsåker <
ilmari(at)ilmari(dot)org> wrote:
> Magnus Hagander <magnus(at)hagander(dot)net> writes:
>
> [pread/pwrite]
>
> > Yeah, Windows does not have those API calls, but it shouldn't be rocket
> > science to write a wrapper for it. The standard windows APIs can do the
> > same thing -- but they'll need access to the HANDLE for the file and not
> > the posix file descriptor.
>
Just to be clear, I'm referring to the standard ReadFile() and WriteFile()
APIs here.
> >
> > It also has things like ReadFileScatter() (
> > https://msdn.microsoft.com/en-us/library/windows/desktop/
> aa365469(v=vs.85).aspx)
> > which is not the same, but might also be interesting as a future
> > improvement.
>
> That looks a lot like POSIX readv()
> (http://pubs.opengroup.org/onlinepubs/9699919799/functions/readv.html)
> and as far as I can tell it has the same issue as it in that it doesn't
> take an offset argument, but requires you to seek first.
>
Ah yeah, for some reason I keep getting readv() and pread(). Which solve a
different problem (see below about that function not having the same issues
on windows -- but it's still not the problem we're trying to solve here)
> Linux and modern BSDs however have preadv()
> (http://manpages.ubuntu.com/manpages/xenial/en/man2/preadv.2.html)
> which takes an offset and an iovec array. I don't know if Windows and
> other platforms have anything similar.
>
ReadFileScatter() can take the offset from OVERLAPPED (same as regular
ReadFile) and an array of FILE_SEGMENT_ELEMENT, same as preadv(). But the
APIs start looking more different the further down the rabbithole you go, I
think. But the capability is definitely there (and has been for ages so is
in all supported version).
--
Magnus Hagander
Me: http://www.hagander.net/
Work: http://www.redpill-linpro.com/
From | Date | Subject | |
---|---|---|---|
Next Message | Victor Wagner | 2016-08-17 11:03:01 | Re: Use pread and pwrite instead of lseek + write and read |
Previous Message | Dagfinn Ilmari =?utf-8?Q?Manns=C3=A5ker?= | 2016-08-17 10:41:40 | Re: Use pread and pwrite instead of lseek + write and read |