🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: news.software.nntp
Article #14324

Re: caveat - multiple feeds to slaves

#14324
From: Joe Greco
Date: Wed, 22 Jan 1997 00:00
235 lines
11973 bytes
In article <5c5pd1$5fk@nntp1.u.washington.edu>,
Steve Jones <noyd@u.washington.edu> wrote:
>Please pardon if I come across as overly critical, I don't mean to be.

:-)  I always enjoy a healthy debate.

>In article <5c4483$bg0@earth.alpha.net>, Joe Greco <jgreco@ns.sol.net> wrote:
>>In article <5c3biu$qs4@dfw-ixnews11.ix.netcom.com>,
>>Mark Hittinger <bugs@freebsd.netcom.com> wrote:
>>>I do multiple feeds to the slaves here.  Its either have larger backlogs
>>>and nearly perfect fifo overviews or have no backlogs and not-in-order
>>>overviews.
>>
>>This sounds like something I've been working on.
>>
>>>Overview can be sorted with 'sort -n' to make it acceptable to "less tolerant
>>>readers(tm)" :-).
>>
>>Huh?
>
>If the overchan program were to keep track of the last article number 
>in a newsgroup, it could detect when it is given data for a lesser 
>article number.  It could then instead of appending the overview 
>record, rewrite the file with the new overview record inserted in the 
>proper order.  If an index of the overview file is kept in another 
>file, the rewrite can be done rather efficiently.  (Assumes that 
>the operation of opening the index file is not overly resource intensive.)  

Yes, potentially.  I considered a number of alternatives that involved
"fixing" overchan, but I was rather skeptical that any method that would
require rewriting the whole file would be practical (think about receiving
a slave feed with articles in random order, and the effect of having a
large overview file.  Assume that you are working in several groups
simultaneously, too.)

The "best" solution I could come up with was to make the records fixed
length.

>>The only consumer of the overview database files (at least in NNTP) is: 
>>nnrpd.  (Well, also expireover, but...)
>>
>>nnrpd goes to great lengths to ALWAYS provide overview data to a client
>>that requests it, using any existing ".overview" as a "cache" of already-
>>generated overview data.
>>
>>In particular, the NOV code does a linear search forward through the 
>>.overview file, caching the current location.  It will become very much
>>less efficient - but still work - if it can not find the data in the
>>.overview file, because it will open the ARTICLE and generate the data.
>>But in no case that I have seen will it cause a client to stop 
>>functioning, because nnrpd always returns the data, one way or another.
>>
>>(I just rewrote all the NNRP NOV code yet again today, so I am particularly
>>familiar with it)...
>
>>What I did:  I worked on the assumption that nonsequential delivery was a
>>likely given - many times over.  Inside nnrpd, I preprocess the data, 
>>essentially trading a full up front traversal of the .overview file (that 
>>allows me to very efficiently index the data by message number), on the 
>>assumption that once in a large group, one was likely to ask for many 
>>articles.
>
>If the overchan program did the indexing for you, for example keeping
>an .overview-index file, you'd have files you could memory map for
>efficiencies sake.  The memory savings you get from using a memory mapped
>file would be significant. (Remember to release old file versions
>regularly.)  Saving memory on a virtual memory system is equivalent to
>saving paging I/O and if you don't page, your system throughput will
>improve accordingly.

Yes, you might be able to do that, too.  It does not do much to answer
the problem of linear searches, but I would rather have linear searches
of an in-memory data structure than of a disk file.

>>It seems to be working okay, although the load averages on the machines
>>seem nearly double, performance is still excellent and I have not seen
>>any of the nasty side effects I have traditionally associated with a bunch
>>of clients grinding on the spool to manually generate NOV data.
>>
>>You might be able to do the same thing by constantly sorting your files,
>>but that's a lot of work, and doesn't happen in real time.
>
>By "real time" I assume you mean on demand by the clients.  Processing
>that can be done ahead of the demand is an improvement in service, and
>the further ahead the better.  If you can do the processing that 
>you've given to nnrpd occur in overchan, your clients will have 
>further improved response.  If you can avoid "read" operations on the 
>overchan file, and avoid the memory requirement for a read buffer (and
>it sounds like you've buffered the entire file by your comments above)
>you will have better performance.  

No.

I've mmap()'ed the entire .overview file in.  That is a separate issue and
has nothing to do with what I'm talking about.

I then walk THROUGH the file, at OVERopen time, and create an index.  This
seems expensive on large groups (i.e. "control.cancel") but does not seem
to hurt much for normal groups.

I end up doing that as a traversal of mmap()'d space (but could be a 
traversal of the disk based file via the traditional QIO access methods).

Now consider the side effects.  I'm going to oversimplify this somewhat.

Traditional: If you have a disk file and plenty of memory, you tend to 
have the overview file in cache after the first access, but you have to
research that in-core data each time you look for a record.  Even with
"last position" caching, you eat a lot of CPU time doing string copies,
ASCII-to-decimal conversions, and comparisons.

If you don't have plenty of memory, you are a hundred times worse, because
you end up hitting disk.

Hashed: you spend more time up front.  You end up pulling the entire 
overview file in memory, which is probably a good thing if you have lots
of memory.  And RAM is truly cheap these days.  Additionally, you access 
the data with a quick integer hash and linked list function, eliminating
all the grungy accesses and AtoI conversions of records you could care
less about.  AND - you don't have to worry about having your overview
database in sorted order.

Since I'm not buffering anything - I'm mmap()'ing - I don't even have to
worry too much on tight-memory systems, because it is still more optimal
than having to constantly re-search the uncached overview file.  I know
right where to go.  But there is a minor expense w.r.t. hashing the 
overview file, and that would be 16K + (12b * #entries).  My LARGEST 
newsgroup has 128616 lines in its .overview file - that means overhead
of about 1.5MB.  That same .overview file is 23MB large, and if I can
trade 1.5MB of RAM to avoid repeated traversals of a 23MB disk file,
I will!

But the REAL win is what happens when the overview data is not sorted.
If you try to read that 23MB overview file with the traditional access
methods, when it's not in the proper order, NNRP will start grinding the
system to a bloody pulp as it accesses tens of thousands of articles in
the news spool itself.

>>What I haven't done: looked at expireover to see how to make that play
>>ball.
>
>I've also hacked on nnrpd to do a few things, but what I found was 
>that my improved version didn't have a sufficiently significant impact
>on client responsiveness that maintaining my own version of the code 
>would be worthwhile.  The code I did was along the lines of what you 
>described, but didn't buffer all of the data at once.  I was 
>particularly concerned about requests for overview data in reverse 
>record order.  

I wasn't; it just happens that when I solve a problem, I try to pick the
algorithm(s) that is least capable of presenting me with a severe "worst
case" performance.

The problem I was _trying_ to solve was out-of-order overview data.

>I've found that for my site, the times when the slave falls behind in 
>it's single feed is when there are an excessive number of new files 
>being added to an already large directory.  The filesystem I am using 
>(ultrix BSD fast filesystem) does a poor job of that.  I found that if
>I filtered out the articles from the sites with the most postings to 
>"misc.jobs" (each of the thousands of articles posted weeky are on the
>senders' WWW sites in a more convenient form) my newsfeed backlogging 
>went way.

There's a thought.  "/news/control/cancel" is the other evil one, I
typically do a "cd /news/control; mv cancel x; rm -fr x" when trying
to recover.  Does wonders, didn't need that 3MB directory anyways  ;-)

>Not coincidentally, the peak in news flow during the day can coincide 
>with the peak in client activity.  For news servers which have become 
>resource constrainted, it can come down to a choice of whether the 
>client can have the news "current" or "now".  I think that for the 
>most part, clients will demand both.  Any efficiencies that can be 
>gained in either the processing of incoming news or the serving of 
>articles to the clients will benefit both activities.  I applaud your
>efforts, but find myself favoring the "now" camp.  

Eh, I don't get it.

My work was done precisely to _improve_ performance.  Anything else is
a side effect.

In a large multi-slave environment, such as the kind I'm running, or
Netcom is, it may be desirable to deliver the articles to the slaves
by any means possible.  A slave may be distant, or over a high latency
link.  Forcing ordered delivery may cause a backlog ("non-current" news).
Or you may simply be recovering from a downtime.  So the ability to 
deliver articles to the slave in an arbitrary manner and still have the
slave work correctly and rapidly is desirable.

overchan/nnrpd are problematic, because overchan assumes the data it is
writing is ordered, and nnrpd assumes that the data on disk is ordered.
That assumption breaks in light of the above "desired" ability.  I found
that even fifty clients, pounding on a machine with severely misordered
overview files, could decimate a large machine's performance by saturating
its I/O subsystem.  nnrp graciously generates the data on the fly, causing
that situation.

If you want to see what I am talking about, do the following:

% cd /nov/alt/sex
% mv .overview .overold
% sort -nr < .overold > .overview

Now open a dozen simultaneous telnet sessions to your nnrpd, and do

GROUP alt.sex
XOVER 1-99999999

in each one.

I would agree that having nnrpd preprocess the contents of the overview
file may be somewhat inefficient (at least in some cases), but it is 
NOWHERE near as inconvenient as your machine coming to a halt while
dozens of clients bash on your I/O subsystem.  And it even solves the
problem of things like reverse walkthrough's for the non-slave case.

I didn't say it was something everyone wanted to do.  I might even agree
that there are other equally feasible ways to do it, including your
overview-index idea.

But... mine was easier to code.  ;-)

Around here people like their news both "current" and "now".  I cut back
the number of reader machines last night, using this patch, and the 
burdened reader machines each handled 150% of their normal reader loads, 
without complaint, and even seemed faster than usual.

So: to put it simply, I think you're wrong, and even if not, life appears
to be better here.  ;-)

... JG

Technical Details
Message-ID: <5c671g$9be@earth.alpha.net>
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
References: <5c3biu$qs4@dfw-ixnews11.ix.netcom.com> <5c4483$bg0@earth.alpha.net> <5c5pd1$5fk@nntp1.u.washington.edu>

Show Full Headers
Complete Article Headers
Message-ID: <5c671g$9be@earth.alpha.net>
Subject: Re: caveat - multiple feeds to slaves
Date: Wed, 22 Jan 1997 00:00:00 +0000
From: jgreco@ns.sol.net (Joe Greco)
References: <5c3biu$qs4@dfw-ixnews11.ix.netcom.com> <5c4483$bg0@earth.alpha.net> <5c5pd1$5fk@nntp1.u.washington.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: 211554919
Distribution: inet
Sender: joegreco@earth.execpc.com
Organization: sol.net Network Services - Milwaukee, WI
Newsgroups: news.software.nntp