Package: postgresql
Version: 9.0.4
Tags: patch

--- Please enter the report below this line. ---
Hi,

I see this is a longstanding issue. Of course, you can configure walwriter and bgwriter to sleep for 10s. However, because in some platforms, select doesn't react to signals, these sleeps have been splitted into 1s sleeps. 10-remove-sleep-cut.patch try to fix that. Moreover, the stats collector process waits for 2 seconds before looping, and it's hardcoded. 11-stats-infinite-wait.patch removes that limit.

These are clearly not final patches. They work for me, that's it. Especially, the second patch should be tested in case when the postmaster crashes unexpectedly. The first patch removes sleep cuts for any platform other than WIN32. I have no clue of a nicer condition. If someone knows something about OS that don't honors signals while in select, please let me know, and I'll improve that patch.

With that two patches applied, postgresql is very low on resource consuming when idling. That's my goal :)

Adrien

--- System information. ---
Architecture: i386
Kernel: Linux 3.0.0-1-686-pae

Debian Release: wheezy/sid
500 unstable ftp.fr.debian.org
1 experimental ftp.fr.debian.org

--- Package information. ---
Package's Depends field is empty.

Package's Recommends field is empty.

Package's Suggests field is empty.



Index: postgresql-9.0-9.0.4/src/backend/postmaster/bgwriter.c
===================================================================
--- postgresql-9.0-9.0.4.orig/src/backend/postmaster/bgwriter.c	2011-09-03 12:40:27.594284817 +0200
+++ postgresql-9.0-9.0.4/src/backend/postmaster/bgwriter.c	2011-09-03 12:41:05.762557856 +0200
@@ -627,6 +627,7 @@
 	else
 		udelay = 10000000L;		/* Ten seconds */
 
+#ifdef WIN32
 	while (udelay > 999999L)
 	{
 		if (got_SIGHUP || shutdown_requested ||
@@ -636,6 +637,7 @@
 		AbsorbFsyncRequests();
 		udelay -= 1000000L;
 	}
+#endif
 
 	if (!(got_SIGHUP || shutdown_requested ||
 	  (ckpt_active ? ImmediateCheckpointRequested() : checkpoint_requested)))
Index: postgresql-9.0-9.0.4/src/backend/postmaster/walwriter.c
===================================================================
--- postgresql-9.0-9.0.4.orig/src/backend/postmaster/walwriter.c	2011-09-03 12:41:18.614649584 +0200
+++ postgresql-9.0-9.0.4/src/backend/postmaster/walwriter.c	2011-09-03 12:41:39.222796431 +0200
@@ -254,6 +254,7 @@
 		 * reasonably quickly if signaled.
 		 */
 		udelay = WalWriterDelay * 1000L;
+#ifdef WIN32
 		while (udelay > 999999L)
 		{
 			if (got_SIGHUP || shutdown_requested)
@@ -261,6 +262,7 @@
 			pg_usleep(1000000L);
 			udelay -= 1000000L;
 		}
+#endif
 		if (!(got_SIGHUP || shutdown_requested))
 			pg_usleep(udelay);
 	}
Index: postgresql-9.0-9.0.4/src/backend/postmaster/pgstat.c
===================================================================
--- postgresql-9.0-9.0.4.orig/src/backend/postmaster/pgstat.c	2011-09-03 12:43:05.591408881 +0200
+++ postgresql-9.0-9.0.4/src/backend/postmaster/pgstat.c	2011-09-03 12:43:17.051489826 +0200
@@ -88,7 +88,7 @@
 										 * failed statistics collector; in
 										 * seconds. */
 
-#define PGSTAT_SELECT_TIMEOUT	2		/* How often to check for postmaster
+#define PGSTAT_SELECT_TIMEOUT	-1		/* How often to check for postmaster
 										 * death; in seconds. */
 
 #define PGSTAT_POLL_LOOP_COUNT	(PGSTAT_MAX_WAIT_TIME / PGSTAT_RETRY_DELAY)

Reply via email to