🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: news.software.nntp
Article #4035

Re: mmap()'ing the active file for innd and nnrpd

#4035
From: Evan Champion
Date: Wed, 27 Dec 1995 00:00
82 lines
4770 bytes
evanc@synapse.net (Evan Champion) wrote:

>I have been looking for ways to reduce the RAM requirements of INN so
>that I can serve more clients from the same box.  The sharedactive
>patch to nnrpd doesn't do anything useful for me at all, but it gave
>me a (hopefully good) idea.

>What about having innd mmap() the active file in a shared mode to
>allow each nnrpd process to read innd's copy of the active file?  This
>would mean that there would only be 1 central copy of the active file
>for the entire system, which in my case would save about 500K/process.

I have been playing around with this a little bit on a small test
program just to see what works and what doesn't.  The major problem I
ran in to was how to actually represent the active file in memory.

The active file contains 4 fields of relatively arbitrary length.  The
first one could theoretically be up to MAXPATHLEN which is 1024 bytes
in my case.  The middle two numbers are 10 digit integers.  The last
is generally a single character but in the case of the '=' mode, it
could be 1 + MAXPATHLEN in length.

Because the fields are of arbitrary length, however, you can't mmap()
the file directly in to a structure which makes it less easy to do
direct active file modifications.

In order to mmap() in to a structure you would need to make the fields
a fixed length.  If we set a fixed limit of 256 characters for the
newsgroup names, the file would be 256 + 10 + 10 + 257 = 533 bytes per
record.  On a 15000 record active file, this would be very close to 8
MB for a file that currently takes about 500K.  This is less of a
concern, perhaps, for those using mmap, but what about people who
don't have access to mmap; that is 8 MB per innd and nnrpd...  not a
pleasant thought.

So I went back to the drawing board pretty quickly :-)

One problem is that if aliased newsgroups are needed the mode field
takes up 1 + the maximum newsgroup name length.  I personally have
only aliased a grand total of 2 newsgroups for a period of about 3
days (until all the news in that group was expired) so I'm not sure
that the aliased newsgroup feature is all that useful.  What could be
done is to make the mode field a single character and then move the
aliases to their own file.  In this case, the file would be 256 + 10 +
10 + 1 = 277 bytes, and in fact if we made the middle two fields long
integers instead of characters (at this point, the file is no longer
going to be human readable anyway), we could get it down to 256 + 4 +
4 + 1 = 265 bytes.

On 15000 records, that is down by about half to about 4 MB, which is
again probably fine for those with mmap() but not acceptable for those
without it.

Back to the drawing board again.

My next thought was about making the active file a database (ie:
Berkeley db or ndbm).  That would solve the problem of the 4 MB
resident per process but you would still be left holding the
btree/hash table and the cache resident.  I'm not sure how much db and
ndbm would hold resident on 4 MB data but I am sure that it would be
significant enough to whittle down the RAM savings to the point where
there is very little point in making the effort to do all this.

So, that was the best I can come up with for now.  I am hoping that
someone out there has some ideas on solutions to the problems I listed
above.  My best hope so far is with the database idea and some way to
hold a single copy of the indexes and cache.  I haven't done much
reading on it, but maybe mSQL could be a solution because it is (as
far as I remember) a centralised database server and as such
(hopefully) the indexes and cache are only be held resident in the
server and the client would only have to contend with a small amount
of library functions in order to deal with the server.

Relating to the history database issue, has anyone looked in to mSQL
as a way to solve the DBZ problem too?  If it would work there too,
mSQL could become the database manager for INN handling the two major
database functions for the server and clients.

Evan


Technical Details
Message-ID: <4bposb$4t1@piano.synapse.net>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!mbox2nntp-news.admin.technical.mbox.zip!not-for-mail
References: <4bp24r$ogm@piano.synapse.net>

Show Full Headers
Complete Article Headers
Message-ID: <4bposb$4t1@piano.synapse.net>
Subject: Re: mmap()'ing the active file for innd and nnrpd
Date: Wed, 27 Dec 1995 00:00:00 +0000
From: evanc@synapse.net (Evan Champion)
References: <4bp24r$ogm@piano.synapse.net>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!mbox2nntp-news.admin.technical.mbox.zip!not-for-mail
X-Deja-AN: 122969341
Distribution: world
Sender: zorch@ftp.UU.NET
Organization: Synapse Internet [www.synapse.net]
Newsgroups: news.software.nntp,news.admin.technical