🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: news.software.nntp
Article #38253

Re: Submitting to Freenix

#38253
From: Curt Welch
Date: Fri, 25 Jun 1999 00:00
76 lines
5248 bytes
Russ Allbery <rra@stanford.edu> wrote:
> I got a 17% improvement out of INN's Perl filters just by not doing a
> needless copy of the article.  Using IPC to talk to another daemon is
> *two* needless copies, through kernel space no less.  Now you can
> duplicate the same effect in shared memory, but between shared memory and
> threads I'd really rather write threads.

I've written a news server which is somwhat like innd in that it's a big
process which is select loop based.  Currently, it even handles all the
reader processes in the main processes.  But I've intended to split off
various parts in other deamons processes.  Right now, the only thing split
off is the article I/O.  I have separate processes for sets of cycbuf-like
spool files.  The spool daemons are also select loop design and can handled
multiple requests over NNTP like TCP/IP streams.

With this design, you get the article disk reads out of the main process
select loop (which would kill it since you can't select on a disk read),
and turn them into TCP/IP reads which you can select on.  It also makes it
very natural to distribute those spool deamons over multiple machines.

But, as you guys are saying, you end up having to do multiple extra
copies of the articles.  And that does eat up a lot more cpu time (at least
twice as much).  But because it's split across multiple processes you can
take advantage of SMP machines.  But it doesn't add (much) latency when
feeding because the main process does the feeding as well as the receiving.
And it doesn't wait for the article to be saved to the spool deamon before
feeding it - it just feeds it from the in-core copy.  And because it's all
one process it was easy to support multiple outgoing streams for a feed
(and multiple outgoing streams to a single remote spool as well).  When
articles need to be sent to a remote host they are just assigned to the
stream with the smalest backlog.

The tricky part of the design is keeping the main select loops running
quickly. You have to play lots of games to make sure nothing you dom't hang
the loop for two long becasue it kills the performance of everything.  And
as pointed out in this thread, you basically end up writing scheduling
software to figure out what to do next and how long to do it -- stuff you
would really like the OS to be dealing with instead of the application.

But the basic design (multiple selelct loop processes talking to each other
over TCP/IP connections) is nice in the fact that it should be very easy
to port to a wide range of Unix platforms.  It uses no threads or shared
memory, or shard disk files.  All IPC is though TCP/IP streams.  And you
can move any of the deamons to remote machines.

The next thing to split out of the main process is reader support.  I'm not
sure if I'm going to do this, but I could.  I'd create a reader deamon
which could support a few hundred connections each.  They would talk to
both the main process to get active/history information and the spool
deamons to get the articles.  They would do no disk I/O.  This would be
required to handle a very large concurrent user base because the main
process is kept busy enough receiving articles.  A heavy user load on the
main process would really slow down it's ability to receive articles
quickly.

Overview is something I've still not solved.  I'm doing it the slow way
right now by generating it on demand and caching it in-core.  But that's
both too slow on the initial fetch and unworkable for a larger reader base
(in-core cache would not be large enough).  I might end up creating a
seperate overview deamon which manages it's own overview database to deal
with this.

You can't split the history DB into a separate process from the one which
receives articles and manages the active file info because the latency of
the IPC would kill your ability to receive articles quickly (at least with
my TCP/IP based IPC solution).

So, basicaly, the design is multiple large innd-like select loop processes
each acting (to some extent) as database servers.  They each manage their
own part of the news database.

-- 
Curt Welch                                            http://CurtWelch.Com/
curt@kcwc.com                          Webmaster for http://NewsReader.Com/

Technical Details
Message-ID: <19990625104626.501$xm@newsreader.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-mail
References: <7g24e7$ckh$1@info.cs.uofs.edu> <ylogi6qrhj.fsf@windlord.stanford.edu> <7ktqaa$k06$1@twwells.com> <yl3dzg28yw.fsf@windlord.stanford.edu> <37731731$0$374@news.execpc.com> <ylg13gyawh.fsf@windlord.stanford.edu>

Show Full Headers
Complete Article Headers
Message-ID: <19990625104626.501$xm@newsreader.com>
Subject: Re: Submitting to Freenix
Date: Fri, 25 Jun 1999 00:00:00 +0000
From: curt@kcwc.com (Curt Welch)
References: <7g24e7$ckh$1@info.cs.uofs.edu> <ylogi6qrhj.fsf@windlord.stanford.edu> <7ktqaa$k06$1@twwells.com> <yl3dzg28yw.fsf@windlord.stanford.edu> <37731731$0$374@news.execpc.com> <ylg13gyawh.fsf@windlord.stanford.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: 493790523
X-Face: "p}G*1KH{+F7EYGKLb>ogDguabZ+%,?^epeFB!nzu`)`$=QcvL1KF6<0GH!Tbc!Sqo[|tV5 %IW48mQf3K=Ci&gZ7]]aazx@]Y-nq!r5{yH/#,?@lDdUDvOfByB2hVW0.@OM%{l/{cT'{w
X-User: Curt@NewsReader.Com
Organization: NewsReader.Com
X-Url: http://CurtWelch.Com/
Newsgroups: news.software.nntp