]> granicus.if.org Git - postgresql/commitdiff
Arrange to call localtime() during postmaster startup. On most Unixen,
authorTom Lane <tgl@sss.pgh.pa.us>
Tue, 19 Feb 2002 19:53:35 +0000 (19:53 +0000)
committerTom Lane <tgl@sss.pgh.pa.us>
Tue, 19 Feb 2002 19:53:35 +0000 (19:53 +0000)
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.

src/backend/postmaster/postmaster.c

index c480bf2f41f60c60451bd2d5921a7ec9bf04fded..e5ce458c0d664d3ea63e3654c0ae4523d7f57fb7 100644 (file)
@@ -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);
@@ -749,6 +753,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
         */
@@ -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)