Re: Extended Prefetching using Asynchronous IO - proposal and patch

From: Claudio Freire <klaussfreire(at)gmail(dot)com>
To: John Lumby <johnlumby(at)hotmail(dot)com>
Cc: Heikki Linnakangas <hlinnakangas(at)vmware(dot)com>, Greg Stark <stark(at)mit(dot)edu>, pgsql hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Extended Prefetching using Asynchronous IO - proposal and patch
Date: 2014-06-25 18:20:32
Message-ID: CAGTBQpbAA_Re4rJHM=ePJPdRb1zmnw_uLmgqKziNV1W+LHHToQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general pgsql-hackers

On Tue, Jun 24, 2014 at 12:08 PM, John Lumby <johnlumby(at)hotmail(dot)com> wrote:
>> The question is, if you receive the notification of the I/O completion
>> using a signal or a thread, is it safe to release the lwlock from the
>> signal handler or a separate thread?
>
> In the forthcoming new version of the patch that uses sigevent,
> the originator locks a LWlock associated with that BAaiocb eXclusive,
> and , when signalled, in the signal handler it places that LWlock
> on a process-local queue of LWlocks awaiting release.
> (No, It cannot be safely released inside the signal handler or in a
> separate thread). Whenever the mainline passes a CHECK_INTERRUPTS macro
> and at a few additional points in bufmgr, the backend walks this process-local
> queue and releases those LWlocks. This is also done if the originator
> itself issues a ReadBuffer, which is the most frequent case in which it
> is released.

I suggest using a semaphore instead.

Semaphores are supposed to be incremented/decremented from multiple
threads or processes already. So, in theory, the callback itself
should be able to do it.

The problem with the process-local queue is that it may take time to
be processed (the time it takes to get to a CHECK_INTERRUPTS macro,
which as it happened with regexes, it can be quite high).

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Merlin Moncure 2014-06-25 18:21:44 Re: Alternative to psql -c ?
Previous Message Tom Lane 2014-06-25 16:04:44 Re: Alternative to psql -c ?

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2014-06-25 18:46:58 What's the point of json_extract_path_op etc?
Previous Message Sawada Masahiko 2014-06-25 18:07:24 Re: TODO : Allow parallel cores to be used by vacuumdb [ WIP ]