aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2002-02-19 19:53:35 +0000
committerTom Lane <tgl@sss.pgh.pa.us>2002-02-19 19:53:35 +0000
commit6e546c286c928825fe57e789b3bdd3903310c5b3 (patch)
tree62c966719d795b9f44029cb49af1e80b15e7d214
parent9103372f52ab9042a934aa857ee83a24784be3ce (diff)
downloadpostgresql-6e546c286c928825fe57e789b3bdd3903310c5b3.tar.gz
postgresql-6e546c286c928825fe57e789b3bdd3903310c5b3.zip
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.
-rw-r--r--src/backend/postmaster/postmaster.c24
1 files changed, 19 insertions, 5 deletions
diff --git a/src/backend/postmaster/postmaster.c b/src/backend/postmaster/postmaster.c
index c480bf2f41f..e5ce458c0d6 100644
--- a/src/backend/postmaster/postmaster.c
+++ b/src/backend/postmaster/postmaster.c
@@ -37,7 +37,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/postmaster/postmaster.c,v 1.264 2002/01/10 01:11:45 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/postmaster/postmaster.c,v 1.265 2002/02/19 19:53:35 tgl Exp $
*
* NOTES
*
@@ -723,6 +723,10 @@ PostmasterMain(int argc, char *argv[])
/*
* Set up signal handlers for the postmaster process.
+ *
+ * CAUTION: when changing this list, check for side-effects on the
+ * signal handling setup of child processes. See tcop/postgres.c,
+ * bootstrap/bootstrap.c, and postmaster/pgstat.c.
*/
pqinitmask();
PG_SETMASK(&BlockSig);
@@ -750,6 +754,18 @@ PostmasterMain(int argc, char *argv[])
whereToSendOutput = None;
/*
+ * On many platforms, the first call of localtime() incurs significant
+ * overhead to load timezone info from the system configuration files.
+ * By doing it once in the postmaster, we avoid having to do it in every
+ * started child process. The savings are not huge, but they add up...
+ */
+ {
+ time_t now = time(NULL);
+
+ (void) localtime(&now);
+ }
+
+ /*
* Initialize and startup the statistics collector process
*/
if (pgstat_init() < 0)
@@ -1793,7 +1809,6 @@ SignalChildren(int signal)
Dlelem *curr,
*next;
Backend *bp;
- int mypid = getpid();
curr = DLGetHead(BackendList);
while (curr)
@@ -1801,7 +1816,7 @@ SignalChildren(int signal)
next = DLGetSucc(curr);
bp = (Backend *) DLE_VAL(curr);
- if (bp->pid != mypid)
+ if (bp->pid != MyProcPid)
{
if (DebugLvl >= 1)
elog(DEBUG, "SignalChildren: sending signal %d to process %d",
@@ -2412,13 +2427,12 @@ CountChildren(void)
{
Dlelem *curr;
Backend *bp;
- int mypid = getpid();
int cnt = 0;
for (curr = DLGetHead(BackendList); curr; curr = DLGetSucc(curr))
{
bp = (Backend *) DLE_VAL(curr);
- if (bp->pid != mypid)
+ if (bp->pid != MyProcPid)
cnt++;
}
if (CheckPointPID != 0)