Re: macOS prefetching support

From: Thomas Munro <thomas(dot)munro(at)gmail(dot)com>
To: Peter Eisentraut <peter(at)eisentraut(dot)org>
Cc: pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: macOS prefetching support
Date: 2024-08-17 01:22:30
Message-ID: CA+hUKGL_HCZQt41FNNcoL5uCL0K_UoJ61pKrAcj1Mc2P=3zj8Q@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Sat, Aug 17, 2024 at 6:58 AM Peter Eisentraut <peter(at)eisentraut(dot)org> wrote:
> solaris fake

I'm half tempted to suggest that we take this exception out. If it's
there, we call it. It doesn't do anything right now, but it's a cheap
empty user space function, and I heard they are thinking about adding
a real syscall. (In a burst of enthusiasm for standards and stuff, I
talked to people involved in all the OSes using ZFS, to suggest
hooking that up; they added some other stuff I asked about so I think
it's a real threat.) But I haven't noticed any users on this list in
many years, to opine either way.

It doesn't do anything on Cygwin either. Actually, it's worse than
nothing, it looks like it makes two useless system calls adjusting the
"sequential" flag on the file handle. But really, of the 3 ways to
build on Windows, only MSVC has real users, so it makes no useless
system calls at all, so I don't propose to change anything due to this
observation.

> win32 no

I guess you could implement this in two ways:

* CreateFileMapping(), MapViewOfFile(), PrefetchVirtualMemory(),
UnmapViewOfFile(), Closehandle(). That's a lot system calls and maybe
expensive VM stuff, who knows.

* ReadFileEx() in OVERLAPPED mode (async), into a dummy buffer, with a
completion callback that frees the buffer and OVERLAPPED object.
That's a lot of extra work allocating memory, copying to user space,
scheduling a callback, and freeing memory for nothing.

Both are terrible, but likely still better than an I/O stall, I dunno.
I think the VMS, NT, Unix-hater view would be: why would you want such
a stupid programming interface anyway, when you could use async I/O
properly? I love Unix, but they'd have a point.

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Noah Misch 2024-08-17 04:07:48 Re: race condition in pg_class
Previous Message Bruce Momjian 2024-08-17 01:12:08 Re: Streaming I/O, vectored I/O (WIP)