Commit 51e400c9 authored by Tom Lane's avatar Tom Lane

Remove the separate 'stats buffer' process, letting backend stats messages

be delivered directly to the collector process.  The extra process context
swaps required to transfer data through the buffer process seem to outweigh
any value the buffering might have.  Per recent discussion and tests.
I modified Bruce's draft patch to use poll() rather than select() where
available (this makes a noticeable difference on my system), and fixed
up the EXEC_BACKEND case.
parent cd4609e2
<!-- $PostgreSQL: pgsql/doc/src/sgml/monitoring.sgml,v 1.35 2006/06/27 19:07:50 momjian Exp $ --> <!-- $PostgreSQL: pgsql/doc/src/sgml/monitoring.sgml,v 1.36 2006/06/29 20:00:08 tgl Exp $ -->
<chapter id="monitoring"> <chapter id="monitoring">
<title>Monitoring Database Activity</title> <title>Monitoring Database Activity</title>
...@@ -50,7 +50,7 @@ ...@@ -50,7 +50,7 @@
<screen> <screen>
$ ps auxww | grep ^postgres $ ps auxww | grep ^postgres
postgres 960 0.0 1.1 6104 1480 pts/1 SN 13:17 0:00 postgres -i postgres 960 0.0 1.1 6104 1480 pts/1 SN 13:17 0:00 postgres -i
postgres 963 0.0 1.1 7084 1472 pts/1 SN 13:17 0:00 postgres: stats buffer process postgres 963 0.0 1.1 7084 1472 pts/1 SN 13:17 0:00 postgres: writer process
postgres 965 0.0 1.1 6152 1512 pts/1 SN 13:17 0:00 postgres: stats collector process postgres 965 0.0 1.1 6152 1512 pts/1 SN 13:17 0:00 postgres: stats collector process
postgres 998 0.0 2.3 6532 2992 pts/1 SN 13:18 0:00 postgres: tgl runbug 127.0.0.1 idle postgres 998 0.0 2.3 6532 2992 pts/1 SN 13:18 0:00 postgres: tgl runbug 127.0.0.1 idle
postgres 1003 0.0 2.4 6532 3128 pts/1 SN 13:19 0:00 postgres: tgl regression [local] SELECT waiting postgres 1003 0.0 2.4 6532 3128 pts/1 SN 13:19 0:00 postgres: tgl regression [local] SELECT waiting
...@@ -60,10 +60,11 @@ postgres 1016 0.1 2.4 6532 3080 pts/1 SN 13:19 0:00 postgres: tgl reg ...@@ -60,10 +60,11 @@ postgres 1016 0.1 2.4 6532 3080 pts/1 SN 13:19 0:00 postgres: tgl reg
(The appropriate invocation of <command>ps</> varies across different (The appropriate invocation of <command>ps</> varies across different
platforms, as do the details of what is shown. This example is from a platforms, as do the details of what is shown. This example is from a
recent Linux system.) The first process listed here is the recent Linux system.) The first process listed here is the
the master server process. The command arguments master server process. The command arguments
shown for it are the same ones given when it was launched. The next two shown for it are the same ones given when it was launched. The next two
processes implement the statistics collector, which will be described in processes are background worker processes automatically launched by the
detail in the next section. (These will not be present if you have set master process. (The <quote>stats collector</> process will not be present
if you have set
the system not to start the statistics collector.) Each of the remaining the system not to start the statistics collector.) Each of the remaining
processes is a server process handling one client connection. Each such processes is a server process handling one client connection. Each such
process sets its command line display in the form process sets its command line display in the form
...@@ -83,6 +84,13 @@ postgres: <replaceable>user</> <replaceable>database</> <replaceable>host</> <re ...@@ -83,6 +84,13 @@ postgres: <replaceable>user</> <replaceable>database</> <replaceable>host</> <re
thereby release some lock or other. thereby release some lock or other.
</para> </para>
<para>
If you have turned off <xref linkend="guc-update-process-title"> then the
activity indicator is not updated; the process title is set only once
when a new process is launched. On some platforms this saves a useful
amount of per-command overhead, on others it's insignificant.
</para>
<tip> <tip>
<para> <para>
<productname>Solaris</productname> requires special handling. You must <productname>Solaris</productname> requires special handling. You must
......
This diff is collapsed.
...@@ -37,7 +37,7 @@ ...@@ -37,7 +37,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/postmaster/postmaster.c,v 1.489 2006/06/27 22:16:43 momjian Exp $ * $PostgreSQL: pgsql/src/backend/postmaster/postmaster.c,v 1.490 2006/06/29 20:00:08 tgl Exp $
* *
* NOTES * NOTES
* *
...@@ -331,8 +331,6 @@ typedef struct ...@@ -331,8 +331,6 @@ typedef struct
PROC_HDR *ProcGlobal; PROC_HDR *ProcGlobal;
PGPROC *DummyProcs; PGPROC *DummyProcs;
InheritableSocket pgStatSock; InheritableSocket pgStatSock;
InheritableSocket pgStatPipe0;
InheritableSocket pgStatPipe1;
pid_t PostmasterPid; pid_t PostmasterPid;
TimestampTz PgStartTime; TimestampTz PgStartTime;
#ifdef WIN32 #ifdef WIN32
...@@ -2352,7 +2350,7 @@ HandleChildCrash(int pid, int exitstatus, const char *procname) ...@@ -2352,7 +2350,7 @@ HandleChildCrash(int pid, int exitstatus, const char *procname)
kill(PgArchPID, SIGQUIT); kill(PgArchPID, SIGQUIT);
} }
/* Force a power-cycle of the pgstat processes too */ /* Force a power-cycle of the pgstat process too */
/* (Shouldn't be necessary, but just for luck) */ /* (Shouldn't be necessary, but just for luck) */
if (PgStatPID != 0 && !FatalError) if (PgStatPID != 0 && !FatalError)
{ {
...@@ -3324,25 +3322,13 @@ SubPostmasterMain(int argc, char *argv[]) ...@@ -3324,25 +3322,13 @@ SubPostmasterMain(int argc, char *argv[])
PgArchiverMain(argc, argv); PgArchiverMain(argc, argv);
proc_exit(0); proc_exit(0);
} }
if (strcmp(argv[1], "--forkbuf") == 0) if (strcmp(argv[1], "--forkcol") == 0)
{ {
/* Close the postmaster's sockets */ /* Close the postmaster's sockets */
ClosePostmasterPorts(false); ClosePostmasterPorts(false);
/* Do not want to attach to shared memory */ /* Do not want to attach to shared memory */
PgstatBufferMain(argc, argv);
proc_exit(0);
}
if (strcmp(argv[1], "--forkcol") == 0)
{
/*
* Do NOT close postmaster sockets here, because we are forking from
* pgstat buffer process, which already did it.
*/
/* Do not want to attach to shared memory */
PgstatCollectorMain(argc, argv); PgstatCollectorMain(argc, argv);
proc_exit(0); proc_exit(0);
} }
...@@ -3679,7 +3665,6 @@ extern slock_t *ProcStructLock; ...@@ -3679,7 +3665,6 @@ extern slock_t *ProcStructLock;
extern PROC_HDR *ProcGlobal; extern PROC_HDR *ProcGlobal;
extern PGPROC *DummyProcs; extern PGPROC *DummyProcs;
extern int pgStatSock; extern int pgStatSock;
extern int pgStatPipe[2];
#ifndef WIN32 #ifndef WIN32
#define write_inheritable_socket(dest, src, childpid) (*(dest) = (src)) #define write_inheritable_socket(dest, src, childpid) (*(dest) = (src))
...@@ -3723,8 +3708,6 @@ save_backend_variables(BackendParameters * param, Port *port, ...@@ -3723,8 +3708,6 @@ save_backend_variables(BackendParameters * param, Port *port,
param->ProcGlobal = ProcGlobal; param->ProcGlobal = ProcGlobal;
param->DummyProcs = DummyProcs; param->DummyProcs = DummyProcs;
write_inheritable_socket(&param->pgStatSock, pgStatSock, childPid); write_inheritable_socket(&param->pgStatSock, pgStatSock, childPid);
write_inheritable_socket(&param->pgStatPipe0, pgStatPipe[0], childPid);
write_inheritable_socket(&param->pgStatPipe1, pgStatPipe[1], childPid);
param->PostmasterPid = PostmasterPid; param->PostmasterPid = PostmasterPid;
param->PgStartTime = PgStartTime; param->PgStartTime = PgStartTime;
...@@ -3928,8 +3911,6 @@ restore_backend_variables(BackendParameters * param, Port *port) ...@@ -3928,8 +3911,6 @@ restore_backend_variables(BackendParameters * param, Port *port)
ProcGlobal = param->ProcGlobal; ProcGlobal = param->ProcGlobal;
DummyProcs = param->DummyProcs; DummyProcs = param->DummyProcs;
read_inheritable_socket(&pgStatSock, &param->pgStatSock); read_inheritable_socket(&pgStatSock, &param->pgStatSock);
read_inheritable_socket(&pgStatPipe[0], &param->pgStatPipe0);
read_inheritable_socket(&pgStatPipe[1], &param->pgStatPipe1);
PostmasterPid = param->PostmasterPid; PostmasterPid = param->PostmasterPid;
PgStartTime = param->PgStartTime; PgStartTime = param->PgStartTime;
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
* *
* Copyright (c) 2001-2006, PostgreSQL Global Development Group * Copyright (c) 2001-2006, PostgreSQL Global Development Group
* *
* $PostgreSQL: pgsql/src/include/pgstat.h,v 1.47 2006/06/19 01:51:21 tgl Exp $ * $PostgreSQL: pgsql/src/include/pgstat.h,v 1.48 2006/06/29 20:00:08 tgl Exp $
* ---------- * ----------
*/ */
#ifndef PGSTAT_H #ifndef PGSTAT_H
...@@ -362,7 +362,6 @@ extern int pgstat_start(void); ...@@ -362,7 +362,6 @@ extern int pgstat_start(void);
extern void pgstat_reset_all(void); extern void pgstat_reset_all(void);
#ifdef EXEC_BACKEND #ifdef EXEC_BACKEND
extern void PgstatBufferMain(int argc, char *argv[]);
extern void PgstatCollectorMain(int argc, char *argv[]); extern void PgstatCollectorMain(int argc, char *argv[]);
#endif #endif
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment