Re: macOS prefetching support

From: Peter Eisentraut <peter(at)eisentraut(dot)org>
To: Thomas Munro <thomas(dot)munro(at)gmail(dot)com>
Cc: pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: macOS prefetching support
Date: 2024-08-16 18:58:33
Message-ID: 1751ce08-55f0-4ce9-a875-ac33ea04f52c@eisentraut.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 14.08.24 16:39, Peter Eisentraut wrote:
> On 14.08.24 14:36, Thomas Munro wrote:
>> On Wed, Aug 14, 2024 at 7:04 PM Peter Eisentraut
>> <peter(at)eisentraut(dot)org> wrote:
>>> Attached is a patch to implement this.  It seems to work, but of course
>>> it's kind of hard to tell whether it actually does anything useful.
>>
>> Header order problem: pg_config_os.h defines __darwin__, but
>> pg_config_manual.h is included first, and tests __darwin__.  I hacked
>> my way around that, and then made a table of 40,000,000 integers in a
>> 2GB buffer pool.  I used "select count(pg_buffercache_evict(buffered))
>> from pg_buffer_cache", and "sudo purge", to clear the two layers of
>> cache for each test, and then measured:
>>
>> maintenance_io_concurrency=0,  ANALYZE: 2311ms
>> maintenance_io_concurrency=10, ANALYZE:  652ms
>> maintenance_io_concurrency=25, ANALYZE:  389ms
>>
>> It works!
>
> Cool!  I'll work on a more polished patch.

Here it is.

Some interesting questions:

What to do about the order of the symbols and include files. I threw
something into src/include/port/darwin.h, but I'm not sure if that's
good. Alternatively, we could not use __darwin__ but instead the more
standard and predefined defined(__APPLE__) && defined(__MACH__).

How to document it. The current documentation makes references mainly
to the availability of posix_fadvise(). That seems quite low-level.
How could a user of a prepared package even find out about that? Should
we just say "requires OS support" (kind of like I did here) and you can
query the effective state by looking at the *_io_concurrency settings?
Or do we need a read-only parameter that shows whether prefetch support
exists (kind of along the lines of huge pages)?

Btw., for context, here is what I gather the prefetch support (with this
patch) is:

cygwin posix_fadvise
darwin fcntl
freebsd posix_fadvise
linux posix_fadvise
netbsd posix_fadvise
openbsd no
solaris fake
win32 no

(There is also the possibility that we provide an implementation of
posix_fadvise() for macOS that wraps the platform-specific code in this
patch. And then Apple could just take that. ;-) )

Attachment Content-Type Size
v2-0001-Add-prefetching-support-on-macOS.patch text/plain 7.7 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Heikki Linnakangas 2024-08-16 19:26:51 Re: Add new protocol message to change GUCs for usage with future protocol-only GUCs
Previous Message Nathan Bossart 2024-08-16 18:56:05 Re: Remove dependence on integer wrapping