From: | Heikki Linnakangas <hlinnaka(at)iki(dot)fi> |
---|---|
To: | Andres Freund <andres(at)anarazel(dot)de> |
Cc: | Tristan Partin <tristan(at)neon(dot)tech>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>, Thomas Munro <thomas(dot)munro(at)gmail(dot)com> |
Subject: | Re: Refactoring backend fork+exec code |
Date: | 2024-01-24 23:51:02 |
Message-ID: | 08eff756-beeb-4a11-9eb5-d45b6af38998@iki.fi |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
On 23/01/2024 21:50, Andres Freund wrote:
> On 2024-01-23 21:07:08 +0200, Heikki Linnakangas wrote:
>> On 22/01/2024 23:07, Andres Freund wrote:
>>>> diff --git a/src/backend/utils/activity/backend_status.c b/src/backend/utils/activity/backend_status.c
>>>> index 1a1050c8da1..92f24db4e18 100644
>>>> --- a/src/backend/utils/activity/backend_status.c
>>>> +++ b/src/backend/utils/activity/backend_status.c
>>>> @@ -257,17 +257,16 @@ pgstat_beinit(void)
>>>> else
>>>> {
>>>> /* Must be an auxiliary process */
>>>> - Assert(MyAuxProcType != NotAnAuxProcess);
>>>> + Assert(IsAuxProcess(MyBackendType));
>>>> /*
>>>> * Assign the MyBEEntry for an auxiliary process. Since it doesn't
>>>> * have a BackendId, the slot is statically allocated based on the
>>>> - * auxiliary process type (MyAuxProcType). Backends use slots indexed
>>>> - * in the range from 0 to MaxBackends (exclusive), so we use
>>>> - * MaxBackends + AuxProcType as the index of the slot for an auxiliary
>>>> - * process.
>>>> + * auxiliary process type. Backends use slots indexed in the range
>>>> + * from 0 to MaxBackends (exclusive), and aux processes use the slots
>>>> + * after that.
>>>> */
>>>> - MyBEEntry = &BackendStatusArray[MaxBackends + MyAuxProcType];
>>>> + MyBEEntry = &BackendStatusArray[MaxBackends + MyBackendType - FIRST_AUX_PROC];
>>>> }
>>>
>>> Hm, this seems less than pretty. It's probably ok for now, but it seems like a
>>> better fix might be to just start assigning backend ids to aux procs or switch
>>> to indexing by pgprocno?
>>
>> Using pgprocno is a good idea. Come to think of it, why do we even have a
>> concept of backend ID that's separate from pgprocno? backend ID is used to
>> index the ProcState array, but AFAICS we could use pgprocno as the index to
>> that, too.
>
> I think we should do that. There are a few processes not participating in
> sinval, but it doesn't make enough of a difference to make sinval slower. And
> I think there'd be far bigger efficiency improvements to sinvaladt than not
> having a handful more entries.
And here we go. BackendID is now a 1-based index directly into the
PGPROC array.
--
Heikki Linnakangas
Neon (https://neon.tech)
Attachment | Content-Type | Size |
---|---|---|
v7-0001-Remove-superfluous-pgprocno-field-from-PGPROC.patch | text/x-patch | 14.3 KB |
v7-0002-Redefine-backend-ID-to-be-an-index-into-the-proc-.patch | text/x-patch | 39.9 KB |
v7-0003-Remove-MyAuxProcType-use-MyBackendType-instead.patch | text/x-patch | 10.6 KB |
v7-0004-Use-MyBackendType-in-more-places-to-check-what-pr.patch | text/x-patch | 19.4 KB |
From | Date | Subject | |
---|---|---|---|
Next Message | Michael Paquier | 2024-01-25 00:02:30 | Re: [PATCH] Add native windows on arm64 support |
Previous Message | David E. Wheeler | 2024-01-24 23:39:47 | Re: Patch: Improve Boolean Predicate JSON Path Docs |