From: | Thomas Munro <thomas(dot)munro(at)gmail(dot)com> |
---|---|
To: | Soumyadeep Chakraborty <soumyadeep2007(at)gmail(dot)com> |
Cc: | pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>, ashwinstar(at)gmail(dot)com |
Subject: | Re: A micro-optimisation for ProcSendSignal() |
Date: | 2021-08-03 01:44:58 |
Message-ID: | CA+hUKGJ87x0MDUW2OMdKG5nyrQHZayo8zd3yY-damyBtpc31yQ@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
Hi Soumyadeep,
On Sat, Jul 24, 2021 at 5:26 PM Soumyadeep Chakraborty
<soumyadeep2007(at)gmail(dot)com> wrote:
> On Tue, Jul 20, 2021 at 10:40 PM Thomas Munro <thomas(dot)munro(at)gmail(dot)com> wrote:
> > I wonder why we need this member anyway, when you can compute it from
> > the address... #define GetPGProcNumber(p) ((p) - ProcGlobal->allProcs)
> > or something like that? Kinda wonder why we don't use
> > GetPGProcByNumber() in more places instead of open-coding access to
> > ProcGlobal->allProcs, too...
>
> I tried this out. See attached v4 of your patch with these changes.
I like it. I've moved these changes to a separate patch, 0002, for
separate commit. I tweaked a couple of comments (it's not a position
in the "procarray", well it's a position stored in the procarray, but
that's confusing; I also found a stray comment about leader->pgprocno
that is obsoleted by this change). Does anyone have objections to
this?
I was going to commit the earlier change this morning, but then I read [1].
New idea. Instead of adding pgprocno to SERIALIZABLEXACT (which we
should really be trying to shrink, not grow), let's look it up by
vxid->backendId. I didn't consider that before, because I was trying
not to get tangled up with BackendIds for various reasons, not least
that that's yet another lock + O(n) search.
It seems likely that getting from vxid to latch will be less clumsy in
the near future. That refactoring and harmonising of backend
identifiers seems like a great idea to me. Here's a version that
anticipates that, using vxid->backendId to wake a sleeping
SERIALIZABLE READ ONLY DEFERRABLE backend, without having to add a new
member to the struct.
> A session ID seems a bit heavy just to indicate whether a backend has
> exited.
Yeah. A Greenplum-like session ID might eventually be necessary in a
world where sessions are divorced from processes and handled by a pool
of worker threads, though. /me gazes towards the horizon
[1] https://www.postgresql.org/message-id/flat/20210802164124.ufo5buo4apl6yuvs%40alap3.anarazel.de
Attachment | Content-Type | Size |
---|---|---|
v5-0001-Optimize-ProcSendSignal.patch | text/x-patch | 8.8 KB |
v5-0002-Remove-PGPROC-s-redundant-pgprocno-member.patch | text/x-patch | 12.9 KB |
From | Date | Subject | |
---|---|---|---|
Next Message | Andrew Dunstan | 2021-08-03 01:50:19 | Re: Release 13 of the PostgreSQL BuildFarm client |
Previous Message | Tom Lane | 2021-08-03 01:43:09 | Re: 2021-07 CF now in progress |