Re: PATCH: Keep one postmaster monitoring pipe per process

From: Thomas Munro <thomas(dot)munro(at)enterprisedb(dot)com>
To: Marco Pfatschbacher <Marco_Pfatschbacher(at)genua(dot)de>
Cc: Pg Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: PATCH: Keep one postmaster monitoring pipe per process
Date: 2016-09-15 19:29:56
Message-ID: CAEepm=27K-2AP1th97kiVvKpTuria9ocbjT0cXCJqnt4if5rJQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Fri, Sep 16, 2016 at 1:57 AM, Marco Pfatschbacher
<Marco_Pfatschbacher(at)genua(dot)de> wrote:
> the current implementation of PostmasterIsAlive() uses a pipe to
> monitor the existence of the postmaster process.
> One end of the pipe is held open in the postmaster, while the other end is
> inherited to all the auxiliary and background processes when they fork.
> This leads to multiple processes calling select(2), poll(2) and read(2)
> on the same end of the pipe.
> While this is technically perfectly ok, it has the unfortunate side
> effect that it triggers an inefficient behaviour[0] in the select/poll
> implementation on some operating systems[1]:
> The kernel can only keep track of one pid per select address and
> thus has no other choice than to wakeup(9) every process that
> is waiting on select/poll.
>
> [...]
>
> BUGS
> [...]
> "Internally to the kernel, select() and pselect() work poorly if multiple
> processes wait on the same file descriptor. Given that, it is rather
> surprising to see that many daemons are written that way."
>
> [1]
> At least OpenBSD and NetBSD are affected, FreeBSD rewrote
> their select implementation in 8.0.

Very interesting. Perhaps that is why NetBSD shows a speedup with the
kqueue patch[1] but FreeBSD doesn't. I guess that if I could get the
kqueue patch to perform better on large FreeBSD systems, it would also
be a solution to this problem.

[1] https://www.postgresql.org/message-id/flat/CAEepm%3D2i78TOJeV4O0-0meiihiRfVQ29ur7%3DMBHxsUKaPSWeAg%40mail.gmail.com

--
Thomas Munro
http://www.enterprisedb.com

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Andres Freund 2016-09-15 19:34:16 Re: Implement targetlist SRFs using ROWS FROM() (was Changed SRF in targetlist handling)
Previous Message Andres Freund 2016-09-15 19:26:16 Re: PATCH: Keep one postmaster monitoring pipe per process