🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: news.software.nntp
3 messages
3 total messages Started by Evan Champion Wed, 27 Dec 1995 00:00
Re: mmap()'ing the active file for innd and nnrpd
#4035
Author: 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


Re: mmap()'ing the active file for innd and nnrpd
#4034
Author: Peter da Silva
Date: Wed, 27 Dec 1995 00:00
33 lines
1934 bytes
In article <4bposb$4t1@piano.synapse.net>,
Evan Champion <evanc@synapse.net> wrote:
> 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.

Just mmap() it in, and build a table of pointers to it. The length of each
field is different, but they don't vary dynamically. So you could end up with
something like this:

	struct active_file_record {
		char *ng_name;	/* space terminated */
		char *ng_next;	/* fixed length unterminated ASCII */
		char *ng_first;	/* fixed length unterminated ASCII */
		char *ng_info;	/* newline terminated */
	} *afile;

	Allocate it with a central loop that looks like:

		afile[ng].ng_name = ptr;
		ptr = strchr(ptr, '\n');
		if(!ptr) break;
		ptr++;
	
	Then parse out the ng_first/ng_next as needed.
-- 
Peter da Silva    (NIC: PJD2)      `-_-'             1601 Industrial Boulevard
Bailey Network Management           'U`             Sugar Land, TX  77487-5013
+1 713 274 5180         "Har du kramat din varg idag?"                     USA
Bailey pays for my technical expertise.        My opinions probably scare them


Re: mmap()'ing the active file for innd and nnrpd
#4040
Author: Brad Templeton
Date: Wed, 03 Jan 1996 00:00
15 lines
1313 bytes
Better to put the active file into a more usable form however, ie. a hashed
database where you can look up fields based on keys (the newsgroup name).

Of course to do this you would have to modify your hash package to work in
a special memory block, ie. don't use pointers, but offsets from the start
of the memory block.

You can write a trivial memory allocator because you never free data, just
add new groups on rare occasions.
-- 
Brad Templeton, publisher, ClariNet Communications Corp.	 info@clari.net
The net's #1 E-Newspaper (1,160,000 paid sbscrbrs.)  http://www.clari.net/brad/


Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads