🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: news.software.readers
Article #851

Re: xrn taking up lots of memory (was Re: XRN exi

#851
From: Terry Poot
Date: Wed, 06 Nov 1991 19:24
94 lines
6260 bytes
In article <wGd_ar-@engin.umich.edu>, stealth@engin.umich.edu (Mike Pelletier)
writes:
>>Xrn allocates an array of structures for storing message headers and such in
>>newsgroups that you read.  The array is (end - start + 1) structures large,
>>where "end" is the highest number for the newsgroup in your active file and
>>"start" is the lowest number.
>
>Great idea, let's make the client's efficiency totally dependant on whether
>or not the minimum field of a server's file is updated or not...  Jeez.

If the field is there and is documented as containing the minimum article
number, why should one not assume that it does indeed contain the minimum
article number? Can we assume that the subject line contains the subject of the
message, or might that be elsewhere?

>From my high school computer science class, I know that linked lists are
>more efficient than arrays for large values, and binary trees and hash
>tables are even more efficient -- why in the world was xrn written
>that way?  

Resisting the temptation to provide a very snide answer, let me just say that
the above statement, as far as it goes, is false. The proper data structure to
represent a sequence of objects is dependent on how those objects are acquired,
how they are accessed, whether the number of objects is known in advance, etc. 

Arrays are the most efficient data structure to use for a sequence of objects
whose number and size are known in advance if those objects are to be accessed
randomly. A subscript calculation is much more efficient than chasing list or
tree pointers, or even negotiating a hash table. Those other structures are
better when you need to insert or delete, or search for a key or the number of
objects is not known in advance. None of these is the case with this
application.

>Memory ought to be allocated on an as-needed basis!  Why allocate
>40 megs if someone's going to read five articles in three groups?  An even
>better question is why allocate 40 megs AT ALL?

Most news readers want to show you the list of articles with subjects and
generally a little more info, so you can select the article to read. To do this,
it must have headers of all the articles. Since NNTP purports to supply the
minimum and maximum article numbers, the most logical and efficient way to do it
is allocate an array of headers and then get them from NNTP. 

The bug here is that NNTP lied about the minimum article number. If xrn thinks
it is going to have to display 5000 subject lines in the subject window, it has
no choice but to allocate room for that many headers. You don't really want to
wait for it to get them from NNTP every time the user scrolls the subject
window. Granted, it could keep some maximum number of headers and get a new set
only when the user scrolled over that boundary. I suspect this wasn't done
because most people don't commonly bring up a group with an incredible number of
headers.

>>You need to start running something to update the active file.
>
>That's an assumption that the client *should not* make.

The client should be allowed to assume that the data provided by NNTP is
correct. After all, what choice does it really have? If the minimum field in the
active file is not going to be correct, NNTP should use some other method to get
that data. The whole purpose of a separate interface layer such as NNTP is to
insulate the client from quirks in the server. (My NNTP server doesn't even HAVE
an active file!)

The easy fix, in this case, is to periodically run the program the corrects the
active file. I believe Henry Spencer recently stated this was going to be the
default in future versions of C news. The hard fix is for the NNTP server to
realize that it can't rely on the active file for this piece of information, and
actually go out and check the directory to see what the lowest article is. 

Arguments about whether this is a C news or NNTP problem are beyond the scope of
what an NNTP client should have to worry about. All it sees is NNTP, and the
interface for NNTP should have absolutely nothing to do with underlying
implementations. The numbers it gets from NNTP are all it can see, so they
should be right. Whoever is at fault in them being wrong, it is clearly not
xrn.

>I don't mean this to sound like a personal attack or anything like that,
>and I have no beef with the person who made this design decision, and I'd
>be willing to consider an explanation of why it operates this way.  It
>just seems stupid to me.

It seems perfectly logical and correct to me. It could maybe be better by
keeping a rolling buffer of a maximum number of headers, and getting ranges of
headers when the user scrolls out of the buffer. Of course, if you've got the
memory, you wouldn't want to wait for the buffer change, so it'd need to be a
user controllable parameter. Also, I don't know if NNTP provides a way to get a
specific range of headers. While there may be room for improvement in how memory
is handled for large groups, the current xrn processing is the obvious
straightforward implementation.
--
Terry Poot <tp@mccall.com>                   The McCall Pattern Company
(uucp: ...!rutgers!ksuvax1!deimos!mccall!tp) 615 McCall Road
(800)255-2762, in KS (913)776-4041           Manhattan, KS 66502, USA
Technical Details
Message-ID: <1991Nov6.132447@mccall.com>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!archive!mbox2nntp-news.software.readers.mbox.zip!gmdzi!zeus.ieee.org!dorm.rutgers.edu!rutgers!usc!zaphod.mps.ohio-state.edu!hobbes.physics.uiowa.edu!moe.ksu.ksu.edu!deimos.cis.ksu.edu!mccall!mccall!tp
References: <1991Oct30.185507.20043@objy.com> <sherman.689246642@foster> <1991Nov5.024522.11311@athena.mit.edu> <wGd_ar-@engin.umich.edu>

Show Full Headers
Complete Article Headers
Message-ID: <1991Nov6.132447@mccall.com>
Subject: Re: xrn taking up lots of memory (was Re: XRN exi
Date: Wed, 06 Nov 1991 19:24:47 +0000
From: tp@mccall.com (Terry Poot)
References: <1991Oct30.185507.20043@objy.com> <sherman.689246642@foster> <1991Nov5.024522.11311@athena.mit.edu> <wGd_ar-@engin.umich.edu>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!archive!mbox2nntp-news.software.readers.mbox.zip!gmdzi!zeus.ieee.org!dorm.rutgers.edu!rutgers!usc!zaphod.mps.ohio-state.edu!hobbes.physics.uiowa.edu!moe.ksu.ksu.edu!deimos.cis.ksu.edu!mccall!mccall!tp
Newsgroups: news.software.readers
Keywords: xrn
Reply-To: tp@mccall.com (Terry Poot)
Organization: The McCall Pattern Co., Manhattan, KS, USA
Lines: 94
Nntp-Posting-Host: mis1
Nntp-Posting-User: tp