Article View: news.software.nntp
Article #17422Re: Inn Performance Questions...
From: Clayton O'Neill
Date: Thu, 01 May 1997 00:00
Date: Thu, 01 May 1997 00:00
177 lines
5849 bytes
5849 bytes
On 1 May 1997 15:09:39 GMT, ManChul Park <mpark@hurl.ns.gatech.edu> wrote:
>
>Hello,
> Since, I'm always looking to improve our INND's performance. I just
>had some quick questions...
>
>Using innreport and innd timer patch, the following is being reported
>to me. (This stat looks similar to this everyday)
>
>Code region Time Pct Invoked Each
>
>idle 00:28:51.605 2.0% 227792 7.602
>article write 04:28:05.707 18.6% 274938 58.507
>article control 00:43:22.031 3.0% 37509 69.371
>article cancel 00:00:22.112 0.0% 1319 16.764
>crosslink 00:00:12.160 0.0% 171167 0.071
>site send 00:02:48.513 0.2% 3024254 0.056
>history write 00:09:41.751 0.7% 467254 1.245
>history sync 00:00:38.060 0.0% 61746 0.616
>history lookup 09:43:28.525 40.5% 4343348 8.060
>history grep 00:00:09.093 0.0% 32104 0.283
>
>I was wondering if there is any way to improve on the history lookup time.
>Since, it is being invoked so many times, if I improve on it a little
>it will make a significant difference.
Try the attached patch. It adds a history lookup cache. Very simple
implementation, but I get about 80-85% hit rates w/ about 100-150 incoming
connections. You may want to tune down the number of cached lookups at the
top of this patch. I have it set for 64k lookups, but you may not want that
many because of memory usage.
>Also, I had compiled ACT_STYLE with the option of READ. Should I recompile
>this with MMAP? How much will this improve my Innd's performance? By the way,
>this is just a feeder machine. (Inn1.5.1, Innfeed, Solaris 2.5.1)
I see almost no difference between MMAP and READ, but I've also got
ICD_SYNC_COUNT tuned up really high. If you don't feel comfortable w/that
then you will probably get better performance from MMAP.
Index: his.c
===================================================================
RCS file: /usr/local/cvsroot/isc/inn/innd/his.c,v
retrieving revision 1.1.1.2
retrieving revision 1.2
diff -u -r1.1.1.2 -r1.2
--- his.c 1997/04/13 05:12:31 1.1.1.2
+++ his.c 1997/04/29 17:32:53 1.2
@@ -1,4 +1,4 @@
-/* $Revision: 1.1.1.2 $
+/* $Revision: 1.2 $
**
** History file routines.
*/
@@ -9,13 +9,19 @@
#include "innd.h"
#include "dbz.h"
+#define HISCACHESIZE (64*1024)
-STATIC char HIShistpath[] = _PATH_HISTORY;
-STATIC FILE *HISwritefp;
-STATIC int HISreadfd;
-STATIC int HISdirty;
-STATIC int HISincore = INND_DBZINCORE;
+typedef struct {
+ char *MessageID;
+ BOOL Found;
+} _HIScache;
+STATIC char HIShistpath[] = _PATH_HISTORY;
+STATIC FILE *HISwritefp;
+STATIC int HISreadfd;
+STATIC int HISdirty;
+STATIC int HISincore = INND_DBZINCORE;
+STATIC _HIScache HIScache[HISCACHESIZE];
/*
** Set up the history files.
@@ -46,6 +52,7 @@
exit(1);
}
}
+ memset((void *)&HIScache, '\0', sizeof(HIScache));
}
@@ -198,9 +205,18 @@
{
datum key;
datum val;
+ long hash;
+ hash = dbzhash(MessageID, strlen(MessageID)) % HISCACHESIZE;
+ if (HIScache[hash].MessageID && !strcmp(MessageID, HIScache[hash].MessageID)) {
+ return HIScache[hash].Found;
+ }
HISsetkey(MessageID, &key);
val = dbzfetch(key);
+ if (HIScache[hash].MessageID != NULL)
+ DISPOSE(HIScache[hash].MessageID);
+ HIScache[hash].MessageID = strdup(MessageID);
+ HIScache[hash].Found = (char)(val.dptr != NULL);
return val.dptr != NULL;
}
@@ -278,7 +294,16 @@
IOError("history database", i);
return FALSE;
}
-
+ i = dbzhash(Data->MessageID, Data->MessageIDLength) % HISCACHESIZE;
+ if (HIScache[i].MessageID && !strcmp(Data->MessageID, HIScache[i].MessageID)) {
+ HIScache[i].Found = TRUE;
+ } else {
+ if (HIScache[i].MessageID)
+ DISPOSE(HIScache[i].MessageID);
+ HIScache[i].MessageID = strdup(Data->MessageID);
+ HIScache[i].Found = TRUE;
+ }
+
if (++HISdirty >= ICD_SYNC_COUNT)
HISsync();
return TRUE;
Index: dbz/dbz.h
===================================================================
RCS file: /usr/local/cvsroot/isc/inn/dbz/dbz.h,v
retrieving revision 1.1.1.2
retrieving revision 1.2
diff -u -r1.1.1.2 -r1.2
--- dbz.h 1997/04/13 05:12:27 1.1.1.2
+++ dbz.h 1997/04/22 02:20:36 1.2
@@ -24,6 +24,7 @@
extern int dbzcancel();
extern int dbzdebug();
extern int dbzwritethrough();
+extern long dbzhash();
/*
* In principle we could handle unlimited-length keys by operating a chunk
--- /usr/local/news/src/inn/lib/dbz.c Wed Apr 30 18:08:50 1997
+++ dbz.c Mon Apr 21 22:15:59 1997
@@ -355,7 +355,6 @@
extern void CloseOnExec();
/* misc. forwards */
-static long hash();
static void crcinit();
static char *cipoint();
static char *mapcase();
@@ -1426,7 +1425,7 @@
{
register long h;
- h = hash(kp->dptr, kp->dsize);
+ h = dbzhash(kp->dptr, kp->dsize);
if (osp != FRESH && osp->hash == h) {
if (sp != osp)
*sp = *osp;
@@ -1716,10 +1715,10 @@
}
/*
- - hash - Honeyman's nice hashing function
+ - dbzhash - Honeyman's nice hashing function
*/
-static long
-hash(name, size)
+long
+dbzhash(name, size)
register char *name;
register int size;
{
Technical Details
Message-ID:
<slrn5mhhoh.g7b.coneill@blah.erols.com>Path:
mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!mbox2nntp-news.software.nntp.mbox.zip!not-for-mailReferences:
<5kabnj$hn8@smash.gatech.edu>Show Full Headers
Complete Article Headers
Message-ID: <slrn5mhhoh.g7b.coneill@blah.erols.com> Subject: Re: Inn Performance Questions... Date: Thu, 01 May 1997 00:00:00 +0000 From: coneill@oneill.net (Clayton O'Neill) References: <5kabnj$hn8@smash.gatech.edu> Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!mbox2nntp-news.software.nntp.mbox.zip!not-for-mail X-Deja-AN: 238682229 Organization: Erol's Internet Services X-Received-On: 1 May 1997 16:38:33 GMT Newsgroups: news.software.nntp