Re: [BackendXidGetPid] only access allProcs when xid matches

From: Ashutosh Bapat <ashutosh(dot)bapat(dot)oss(at)gmail(dot)com>
To: Junwang Zhao <zhjwpku(at)gmail(dot)com>
Cc: PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: [BackendXidGetPid] only access allProcs when xid matches
Date: 2023-08-09 14:46:46
Message-ID: CAExHW5v=aAXtKfKAaYx96t=VXFnkVuKShgCcD7n9-t7d=jT8=Q@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Wed, Aug 9, 2023 at 9:30 AM Junwang Zhao <zhjwpku(at)gmail(dot)com> wrote:
>
> In function `BackendXidGetPid`, when looping every proc's
> TransactionId, there is no need to access its PGPROC since there
> is shared memory access: `arrayP->pgprocnos[index]`.
>
> Though the compiler can optimize this kind of inefficiency, I
> believe we should ship with better code.
>

Looks good to me. However, I would just move the variable declaration
with their assignments inside the if () rather than combing the
expressions. It more readable that way.

--
Best Wishes,
Ashutosh Bapat

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Peter Eisentraut 2023-08-09 15:02:46 Re: Fix last unitialized memory warning
Previous Message Andres Freund 2023-08-09 14:41:51 Re: Support to define custom wait events for extensions