Remove Start* macros from postmaster.c to ease understanding of code

Started by Reid Thompsonalmost 3 years ago5 messageshackers
Jump to latest
#1Reid Thompson
reid.thompson@crunchydata.com

Hi,

Attached is a small patch implemented as I agree with Andres' comment
below noted while reviewing the thread
/messages/by-id/20240122210740.7vq5fd4woixpwx3f@awork3.anarazel.de

I agree that its easier to not have to refer back to the macros only to
see that they're all invoking StartChildProcess(X). All invocations are
within postmaster.c.

@@ -561,13 +561,13 @@ static void ShmemBackendArrayAdd(Backend *bn);
static void ShmemBackendArrayRemove(Backend *bn);
#endif /* EXEC_BACKEND */

-#define StartupDataBase()		StartChildProcess(StartupProcess)
-#define StartArchiver()			StartChildProcess(ArchiverProcess)
-#define StartBackgroundWriter() StartChildProcess(BgWriterProcess)
-#define StartCheckpointer()		StartChildProcess(CheckpointerProcess)
-#define StartWalWriter()		StartChildProcess(WalWriterProcess)
-#define StartWalReceiver()		StartChildProcess(WalReceiverProcess)
-#define StartWalSummarizer()	StartChildProcess(WalSummarizerProcess)
+#define StartupDataBase()		StartChildProcess(B_STARTUP)
+#define StartArchiver()			StartChildProcess(B_ARCHIVER)
+#define StartBackgroundWriter() StartChildProcess(B_BG_WRITER)
+#define StartCheckpointer()		StartChildProcess(B_CHECKPOINTER)
+#define StartWalWriter()		StartChildProcess(B_WAL_WRITER)
+#define StartWalReceiver()		StartChildProcess(B_WAL_RECEIVER)
+#define StartWalSummarizer()	StartChildProcess(B_WAL_SUMMARIZER)

Not for this commit, but we ought to rip out these macros - all they do is to make it harder to understand the code.

Attachments:

0001-Remove-Start-macros-in-postmaster.c-to-ease-understa.patchtext/x-patch; charset=UTF-8; name=0001-Remove-Start-macros-in-postmaster.c-to-ease-understa.patchDownload+18-27
#2Nathan Bossart
nathandbossart@gmail.com
In reply to: Reid Thompson (#1)
Re: Remove Start* macros from postmaster.c to ease understanding of code

On Tue, Feb 06, 2024 at 11:58:50AM -0500, reid.thompson@crunchydata.com wrote:

Attached is a small patch implemented as I agree with Andres' comment
below noted while reviewing the thread
/messages/by-id/20240122210740.7vq5fd4woixpwx3f@awork3.anarazel.de

I agree that its easier to not have to refer back to the macros only to
see that they're all invoking StartChildProcess(X). All invocations are
within postmaster.c.

Seems reasonable to me.

--
Nathan Bossart
Amazon Web Services: https://aws.amazon.com

#3Bharath Rupireddy
bharath.rupireddyforpostgres@gmail.com
In reply to: Reid Thompson (#1)
Re: Remove Start* macros from postmaster.c to ease understanding of code

On Tue, Feb 6, 2024 at 10:34 PM <reid.thompson@crunchydata.com> wrote:

Hi,

Attached is a small patch implemented as I agree with Andres' comment
below noted while reviewing the thread
/messages/by-id/20240122210740.7vq5fd4woixpwx3f@awork3.anarazel.de

I agree that its easier to not have to refer back to the macros only to
see that they're all invoking StartChildProcess(X). All invocations are
within postmaster.c.

@@ -561,13 +561,13 @@ static void ShmemBackendArrayAdd(Backend *bn);
static void ShmemBackendArrayRemove(Backend *bn);
#endif /* EXEC_BACKEND */

-#define StartupDataBase()            StartChildProcess(StartupProcess)
-#define StartArchiver()                      StartChildProcess(ArchiverProcess)
-#define StartBackgroundWriter() StartChildProcess(BgWriterProcess)
-#define StartCheckpointer()          StartChildProcess(CheckpointerProcess)
-#define StartWalWriter()             StartChildProcess(WalWriterProcess)
-#define StartWalReceiver()           StartChildProcess(WalReceiverProcess)
-#define StartWalSummarizer() StartChildProcess(WalSummarizerProcess)
+#define StartupDataBase()            StartChildProcess(B_STARTUP)
+#define StartArchiver()                      StartChildProcess(B_ARCHIVER)
+#define StartBackgroundWriter() StartChildProcess(B_BG_WRITER)
+#define StartCheckpointer()          StartChildProcess(B_CHECKPOINTER)
+#define StartWalWriter()             StartChildProcess(B_WAL_WRITER)
+#define StartWalReceiver()           StartChildProcess(B_WAL_RECEIVER)
+#define StartWalSummarizer() StartChildProcess(B_WAL_SUMMARIZER)

Not for this commit, but we ought to rip out these macros - all they do is to make it harder to understand the code.

+1. Patch LGTM.

--
Bharath Rupireddy
PostgreSQL Contributors Team
RDS Open Source Databases
Amazon Web Services: https://aws.amazon.com

#4Nathan Bossart
nathandbossart@gmail.com
In reply to: Bharath Rupireddy (#3)
Re: Remove Start* macros from postmaster.c to ease understanding of code

On Wed, Feb 07, 2024 at 12:48:00AM +0530, Bharath Rupireddy wrote:

+1. Patch LGTM.

Unless there are objections, I'll plan on committing this in the next day
or two.

--
Nathan Bossart
Amazon Web Services: https://aws.amazon.com

#5Nathan Bossart
nathandbossart@gmail.com
In reply to: Nathan Bossart (#4)
Re: Remove Start* macros from postmaster.c to ease understanding of code

On Tue, Feb 06, 2024 at 02:37:25PM -0600, Nathan Bossart wrote:

Unless there are objections, I'll plan on committing this in the next day
or two.

Committed.

--
Nathan Bossart
Amazon Web Services: https://aws.amazon.com