Skip to content

Commit 6e546c2

Browse files
committed
Arrange to call localtime() during postmaster startup. On most Unixen,
the first call of localtime() in a process will read /usr/lib/tztab or local equivalent. Better to do this once in the postmaster and inherit the data by fork() than to have to do it during every backend start.
1 parent 9103372 commit 6e546c2

File tree

1 file changed

+19
-5
lines changed

1 file changed

+19
-5
lines changed

src/backend/postmaster/postmaster.c

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
*
3838
*
3939
* IDENTIFICATION
40-
* $Header: /cvsroot/pgsql/src/backend/postmaster/postmaster.c,v 1.264 2002/01/10 01:11:45 tgl Exp $
40+
* $Header: /cvsroot/pgsql/src/backend/postmaster/postmaster.c,v 1.265 2002/02/19 19:53:35 tgl Exp $
4141
*
4242
* NOTES
4343
*
@@ -723,6 +723,10 @@ PostmasterMain(int argc, char *argv[])
723723

724724
/*
725725
* Set up signal handlers for the postmaster process.
726+
*
727+
* CAUTION: when changing this list, check for side-effects on the
728+
* signal handling setup of child processes. See tcop/postgres.c,
729+
* bootstrap/bootstrap.c, and postmaster/pgstat.c.
726730
*/
727731
pqinitmask();
728732
PG_SETMASK(&BlockSig);
@@ -749,6 +753,18 @@ PostmasterMain(int argc, char *argv[])
749753
*/
750754
whereToSendOutput = None;
751755

756+
/*
757+
* On many platforms, the first call of localtime() incurs significant
758+
* overhead to load timezone info from the system configuration files.
759+
* By doing it once in the postmaster, we avoid having to do it in every
760+
* started child process. The savings are not huge, but they add up...
761+
*/
762+
{
763+
time_t now = time(NULL);
764+
765+
(void) localtime(&now);
766+
}
767+
752768
/*
753769
* Initialize and startup the statistics collector process
754770
*/
@@ -1793,15 +1809,14 @@ SignalChildren(int signal)
17931809
Dlelem *curr,
17941810
*next;
17951811
Backend *bp;
1796-
int mypid = getpid();
17971812

17981813
curr = DLGetHead(BackendList);
17991814
while (curr)
18001815
{
18011816
next = DLGetSucc(curr);
18021817
bp = (Backend *) DLE_VAL(curr);
18031818

1804-
if (bp->pid != mypid)
1819+
if (bp->pid != MyProcPid)
18051820
{
18061821
if (DebugLvl >= 1)
18071822
elog(DEBUG, "SignalChildren: sending signal %d to process %d",
@@ -2412,13 +2427,12 @@ CountChildren(void)
24122427
{
24132428
Dlelem *curr;
24142429
Backend *bp;
2415-
int mypid = getpid();
24162430
int cnt = 0;
24172431

24182432
for (curr = DLGetHead(BackendList); curr; curr = DLGetSucc(curr))
24192433
{
24202434
bp = (Backend *) DLE_VAL(curr);
2421-
if (bp->pid != mypid)
2435+
if (bp->pid != MyProcPid)
24222436
cnt++;
24232437
}
24242438
if (CheckPointPID != 0)

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy