INN commit: trunk (4 files)

INN Commit rra at isc.org
Tue Jun 23 18:08:14 UTC 2009


    Date: Tuesday, June 23, 2009 @ 11:08:14
  Author: iulius
Revision: 8534

Add the -L flag to makehistory in order to specify a maximum
load average.  If exceeded, the rebuild is paused until it
decreases below the specified load.

Patch by Jonathan Kamens.

Modified:
  trunk/CONTRIBUTORS
  trunk/doc/pod/makehistory.pod
  trunk/doc/pod/news.pod
  trunk/expire/makehistory.c

-------------------------+
 CONTRIBUTORS            |    2 +-
 doc/pod/makehistory.pod |   12 +++++++++++-
 doc/pod/news.pod        |   10 ++++++++--
 expire/makehistory.c    |   41 ++++++++++++++++++++++++++++++++++++++---
 4 files changed, 58 insertions(+), 7 deletions(-)

Modified: CONTRIBUTORS
===================================================================
--- CONTRIBUTORS	2009-06-21 20:14:05 UTC (rev 8533)
+++ CONTRIBUTORS	2009-06-23 18:08:14 UTC (rev 8534)
@@ -270,4 +270,4 @@
 J. Thomas Halliley, Matija Nalis, Geraint A. Edwards, Alexander Bartolich,
 David Hlacik, Andreas Mattheiss, James Ralston, Wim Lewis, Johan van Selst,
 Wolfgang M. Weyand, Berend Reitsma, William Kronert, Petr Novopashenniy,
-Steve Crook, John F. Morse, Tim Woodall
+Steve Crook, John F. Morse, Tim Woodall, Jonathan Kamens

Modified: doc/pod/makehistory.pod
===================================================================
--- doc/pod/makehistory.pod	2009-06-21 20:14:05 UTC (rev 8533)
+++ doc/pod/makehistory.pod	2009-06-23 18:08:14 UTC (rev 8534)
@@ -5,7 +5,7 @@
 =head1 SYNOPSIS
 
 B<makehistory> [B<-abFIOSx>] [B<-f> I<filename>] [B<-l> I<count>]
-[B<-s> I<size>] [B<-T> I<tmpdir>]
+[B<-L> I<load-average>] [B<-s> I<size>] [B<-T> I<tmpdir>]
 
 =head1 DESCRIPTION
 
@@ -89,6 +89,16 @@
 with buffindexed, because buffindexed does not need sorted
 overview and no batching is done.
 
+=item B<-L> I<load-average>
+
+Temporarily pause activities if the system load average exceeds the
+specified level I<load-average>.  This allows B<makehistory> to run
+on a system being used for other purposes without monopolizing system
+resources and thus making the response time for other applications
+unacceptably slow.  Using nice(1) does not help much for that because
+the problem comes from disk I/O usage, and ionice(1) is not always
+available or efficient.
+
 =item B<-O>
 
 Create the overview database as well as the F<history> file.  Overview

Modified: doc/pod/news.pod
===================================================================
--- doc/pod/news.pod	2009-06-21 20:14:05 UTC (rev 8533)
+++ doc/pod/news.pod	2009-06-23 18:08:14 UTC (rev 8534)
@@ -31,8 +31,14 @@
 
 =item *
 
-The default path for TLS certificates has changed from I<pathlib> to
-I<pathetc>.  It only affects new INN installations or generations of
+A new B<-L> flag has been added by Jonathan Kamens to B<makehistory>
+so as to specify a load average limit.  If the system load average exceeds
+the specified limit, B<makehistory> sleeps until it goes below the limit.
+
+=item *
+
+The default path for TLS certificates has changed from I<pathnews>/lib
+to I<pathetc>.  It only affects new INN installations or generations of
 certificates with C<make cert>.  Besides, a default value has been
 added to I<tlscapath> because it is required by B<nnrpd> when TLS
 is used.

Modified: expire/makehistory.c
===================================================================
--- expire/makehistory.c	2009-06-21 20:14:05 UTC (rev 8533)
+++ expire/makehistory.c	2009-06-23 18:08:14 UTC (rev 8534)
@@ -24,8 +24,28 @@
 #include "inn/vector.h"
 #include "inn/wire.h"
 
+/*
+**  If we have getloadavg, include the appropriate header file.  Otherwise,
+**  just assume that we always have a load of 0.
+*/
+#if HAVE_GETLOADAVG
+# if HAVE_SYS_LOADAVG_H
+#  include <sys/loadavg.h>
+# endif
+#else
+static int
+getloadavg(double loadavg[], int nelem)
+{
+    int i;
+
+    for (i = 0; i < nelem && i < 3; i++)
+        loadavg[i] = 0;
+    return i;
+}
+#endif
+
 static const char usage[] = "\
-Usage: makehistory [-abFIOSx] [-f file] [-l count] [-s size] [-T tmpdir]\n\
+Usage: makehistory [-abFIOSx] [-f file] [-l count] [-L load] [-s size] [-T tmpdir]\n\
 \n\
     -a          open output history file in append mode\n\
     -b          delete bad articles from spool\n\
@@ -33,6 +53,7 @@
     -f file     write history entries to file (default $pathdb/history)\n\
     -I          do not create overview for articles numbered below lowmark\n\
     -l count    size of overview updates (default 10000)\n\
+    -L load     pause when load average exceeds threshold\n\
     -O          create overview entries for articles\n\
     -S          write overview data to standard output\n\
     -s size     size new history database for approximately size entries\n\
@@ -810,6 +831,8 @@
 {
     ARTHANDLE *art = NULL;
     bool AppendMode;
+    int LoadAverage;
+    double load[1];
     int i;
     bool val;
     char *HistoryDir;
@@ -837,9 +860,10 @@
     DoOverview = false;
     Fork = false;
     AppendMode = false;
+    LoadAverage = 0;
     NoHistory = false;
 
-    while ((i = getopt(argc, argv, "abFf:Il:OSs:T:x")) != EOF) {
+    while ((i = getopt(argc, argv, "abFf:Il:L:OSs:T:x")) != EOF) {
 	switch(i) {
 	case 'a':
 	    AppendMode = true;
@@ -859,6 +883,9 @@
 	case 'l':
 	    OverTmpSegSize = atoi(optarg);
 	    break;
+        case 'L':
+            LoadAverage = atoi(optarg);
+            break;
 	case 'O':
 	    DoOverview = true;
 	    break;
@@ -956,7 +983,7 @@
 
     /*
      * Scan the entire spool, nuke any bad arts if needed, and process each
-     * article.
+     * article.  We take a break when the load is too high.
      */
 	
     while ((art = SMnext(art, RETR_ALL)) != NULL) {
@@ -965,7 +992,15 @@
 		SMcancel(*art->token);
 	    continue;
 	}
+
 	DoArt(art);
+
+        if (LoadAverage > 0) {
+            while (getloadavg(load, 1) > 0 &&
+                   (int) (load[0]) >= LoadAverage) {
+                sleep(1);
+            }
+        }
     }
 
     if (!NoHistory) {




More information about the inn-committers mailing list