Re: Refactoring backend fork+exec code

From: Heikki Linnakangas <hlinnaka(at)iki(dot)fi>
To: Andres Freund <andres(at)anarazel(dot)de>, Tristan Partin <tristan(at)neon(dot)tech>
Cc: 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: 2023-11-29 23:36:25
Message-ID: e0dcfabb-f59a-45e8-bd92-f8d706c92128@iki.fi
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 11/10/2023 14:12, Heikki Linnakangas wrote:
> On 11/07/2023 01:50, Andres Freund wrote:
>>> Subject: [PATCH 3/9] Refactor CreateSharedMemoryAndSemaphores.
>>>
>>> Moves InitProcess calls a little later in EXEC_BACKEND case.
>>
>> What's the reason for this part?
>
> The point is that with this commit, InitProcess() is called at same
> place in EXEC_BACKEND mode and !EXEC_BACKEND. It feels more consistent
> that way.
>
>> ISTM that we'd really want to get away from plastering duplicated
>> InitProcess() etc everywhere.
>
> Sure, we could do more to reduce the duplication. I think this is a step
> in the right direction, though.

Here's another rebased patch set. Compared to previous version, I did a
little more refactoring around CreateSharedMemoryAndSemaphores and
InitProcess:

- patch 1 splits CreateSharedMemoryAndSemaphores into two functions:
CreateSharedMemoryAndSemaphores is now only called at postmaster
startup, and a new function called AttachSharedMemoryStructs() is called
in backends in EXEC_BACKEND mode. I extracted the common parts of those
functions to a new static function. (Some of this refactoring used to be
part of the 3rd patch in the series, but it seems useful on its own, so
I split it out.)

- patch 3 moves the call to AttachSharedMemoryStructs() to
InitProcess(), reducing the boilerplate code a little.

The patches are incrementally useful, so if you don't have time to
review all of them, a review on a subset would be useful too.

--
Heikki Linnakangas
Neon (https://neon.tech)

Attachment Content-Type Size
v3-0001-Refactor-CreateSharedMemoryAndSemaphores.patch text/x-patch 10.3 KB
v3-0002-Pass-BackgroundWorker-entry-in-the-parameter-file.patch text/x-patch 5.6 KB
v3-0003-Refactor-how-InitProcess-is-called.patch text/x-patch 7.5 KB
v3-0004-Pass-CAC-as-argument-to-backend-process.patch text/x-patch 5.4 KB
v3-0005-Remove-ConnCreate-and-ConnFree-and-allocate-Port-.patch text/x-patch 3.8 KB
v3-0006-Introduce-ClientSocket-rename-some-funcs.patch text/x-patch 25.9 KB
v3-0007-Refactor-postmaster-child-process-launching.patch text/x-patch 137.4 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Jeff Davis 2023-11-29 23:46:26 encoding affects ICU regex character classification
Previous Message Heikki Linnakangas 2023-11-29 23:16:30 Re: Streaming I/O, vectored I/O (WIP)