🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: news.software.nntp
11 messages
11 total messages Started by Mark Delany Sun, 07 Apr 1996 00:00
cyclic news file system - two interesting quirks
#6378
Author: Mark Delany
Date: Sun, 07 Apr 1996 00:00
125 lines
5875 bytes
I've finally got a stand-alone cyclic news file system kicking and have
been feeding it a reasonable sized feed for a little while so I
thought it time to post about a few residual quirks to get some
feedback.

[-- Recall from "How to do a better USENET file system" the idea of a
    cyclic file to store article and NOV data. This has the potential
    to substantially reduce I/O load for a whole stack of reasons:
    serial I/O to the disk, no UFS to fight, no expire, etc.     --]


There are two "aberrations" that come from the implementation I'm
running.


1.	Premature 'expire' of low volume NOV entries
	--------------------------------------------

This one is pretty straightforward actually and is really only a
prelude to the second, and far more serious "aberration".

Assume the simple case of a cyclic file that has just two newsgroups
being written to it. Group A is a high volume group while Group B is a
low volume group. If the article arrival order is B1, A1...A10, then
the file would look like this:

                          Next write position---+
                                                |
                                                v
.-----------------------------------------------------.
| Art   | Nov   | Art| Nov | Art  | Art   | NOV |     |
| B1    | B1    | A1 | A1-9| A2-8 | A9-10 | A10 |     |
.-----------------------------------------------------.

Note that a NOV disk block typically fits lots of NOV entries.

When article B2 arrives the article data is written at the next write
position. The NOV entry however is written into the same NOV disk
block as the last NOV entry for the same group, thus:

        Next write position---------------------------+
                           Article written here-+     |
        +--NOV written here                     |     |
        v                                       v     v
.-----------------------------------------------------.
| Art   | Nov   | Art| Nov | Art  | Art   | NOV | Art |
| B1    | B1,B2 | A1 | A1-9| A2-8 | A9-10 | A10 | B2  |
.-----------------------------------------------------.

At this point articles A11-13 arrive, the file wraps and old data is
over-written, thus:

                +---------Next write position
                |
                v
.-----------------------------------------------------.
| Art   | Nov   | Art| Nov | Art  | Art   | NOV | Art |
| A11-13| A11-13| A1 | A1-9| A2-8 | A9-10 | A10 | B2  |
.-----------------------------------------------------.

Note that Art-B1, NOV-B1 *and* NOV-B2 have been over-written.

The is OK for B1 as it has been there for a full cycle and the NOV
entry disappears at about the same time as the article.

This is not Ok for B2 as it has only just arrived, yet it is almost
immediately 'expired' as the NOV entry has been overwritten. In other
words, low-volume groups get unfairly penalized with this scheme.

My current solution is to introduce a "proximity" factor which says
that a new NOV entries must be written within a certain distance of
the article (say, within 10% of file size).

This solution wastes a bit of NOV space for low-volume groups as they
typically wont fill, but that's a small price to pay methinks.


2.	Lost of lowest valid article number
	-----------------------------------

The second and most serious problem is that it is hard to track the
lowest article number for each group (lownum). Since articles are
perpetually being over-written by new articles, it is apparent that
the lownum value needs to increase all the time to reflect these
'expired' articles.

Returning to this situation:

        Next write position---------------------------+
                                                      v
.-----------------------------------------------------.
| Art   | Nov   | Art| Nov | Art  | Art   | NOV | Art |
| B1    | B1,B2 | A1 | A1-9| A2-8 | A9-10 | A10 | B2  |
.-----------------------------------------------------.

When the next article comes along and overwrites Art-B1, how do I know
that newsgroup B now has a lownum value of 2 for the purposes of
keeping the active file accurate?

I cannot think of a good way of determining what is about to be
over-written without pre-reading it first. Pre-reads of course
introduce a *lot* of extra read I/O (albeit with limited head
movement) that I definitely want to avoid. Pre-reading also has some
nasty implications wrt re-decoding "Newsgroups" headers - ugh.

One possibility is to compute lownum on the fly as it's only needed in
response to certain NNTP commands, but that is a fairly I/O heavy
activity as it requires a read of all NOV data per newsgroup. Even
though NOV data is grouped on disk, it's still at least one disk I/O
per group, and likely more.

I don't know for sure, but in practice does lownum really need to be
accurate for all NNTP commands or only a subset?

If lownum only needs to be accurate when the NOV data is also
required, then that's easy. On the other hand, if it has to be
accurate for most, or all group related NNTP commands then I'm *very*
interested in ideas on how to efficiently determine lownum in a cycle
news file system as it's pretty much the only unresolved aspect of the
implementation (that I know of).


Regards.

Re: cyclic news file system - two interesting quirks
#6368
Author: Brad Templeton
Date: Sun, 07 Apr 1996 00:00
24 lines
1731 bytes
Actually, my own plans had never thought of putting the overview data
in with the articles.  As you note, there are problems doing that.
I felt maintaining the overview data in some other way (its own private
spools or set of cyclic files for example) might make some sense.  Overview
data is much smaller, and it's more important that it be kept contiguous
for any given newsgroup -- in fact I would say it is fairly vital, as
you expect newsreaders to make the most heavy use of overview data.

(I would change the poorly designed overview format while at it, however.)

Entirely contiguous overviews would be nice but do cost a bit of efficiency
at write time.  But they do make it up on read.  But you can compromise
and just use a very large block size for overviews.

Low article numbers are not much problem, really.  Right now they only
get calculated once a day.  You could change this to a program that just
reads the overview files and pulls out the minimum article number.


-- 
Brad Templeton, publisher, ClariNet Communications Corp.	 info@clari.net
The net's #1 E-Newspaper (1,300,000 paid sbscrbrs.)  http://www.clari.net/brad/

Re: cyclic news file system - two interesting quirks
#6369
Author: Mark Delany
Date: Sun, 07 Apr 1996 00:00
45 lines
2260 bytes
mark@kram.org (Mark Turner) writes:

>In article <4k78u1$lbu@bushwire.mira.net.au>,
>Mark Delany  <markd@mira.net.au> wrote:
>> 
>> I don't know for sure, but in practice does lownum really need to be
>> accurate for all NNTP commands or only a subset?

>Maybe you've already read the following but I'll include them here in
>case not....

>1) From INN's active(5) man page where it talks about the fields in the
>active file:

>	"The third field is the lowest article number in the group; this
>	 number is not guaranteed to be accurate, and should only be taken
>	 to be a hint."


>2) From RFC977 section 3.2.1 where it talks about the data returned by
>the "group" command:

Indeed I have, along with the common extensions draft, but thanks for
the refresher. The only NNTP command definitely affected are those
that solely rely on the active file for their answer. As far as I can
tell, the only relevant command is LIST [ACTIVE].

Both GROUP and LISTGROUP consult the directory periodically so I have
no problem doing the equivalent. Furthermore a GROUP command is likely
to be followed by an article request or two within that group thus
giving a locality win.

Doesn't tell me how to keep the info even partially accurate with the
cyclic scheme (unless I shoot for a renumber - ugh), but I agree that
a "moderately accurate" scheme should suffice for the LIST command.

Currently a cyclic renumber requires reading all of the NOV data,
which is what, around 10-15% of the news storage? So a 10G news system
will need to read over 1G of NOV to do a complete renumber. Definitely
not an option in my book.


Regards.

Re: cyclic news file system - two interesting quirks
#6380
Author: Mark Turner
Date: Sun, 07 Apr 1996 00:00
64 lines
3330 bytes
In article <4k78u1$lbu@bushwire.mira.net.au>,
Mark Delany  <markd@mira.net.au> wrote:
> 
> I don't know for sure, but in practice does lownum really need to be
> accurate for all NNTP commands or only a subset?
> 
> If lownum only needs to be accurate when the NOV data is also
> required, then that's easy. On the other hand, if it has to be
> accurate for most, or all group related NNTP commands then I'm *very*
> interested in ideas on how to efficiently determine lownum in a cycle
> news file system as it's pretty much the only unresolved aspect of the
> implementation (that I know of).

Maybe you've already read the following but I'll include them here in
case not....

1) From INN's active(5) man page where it talks about the fields in the
active file:

	"The third field is the lowest article number in the group; this
	 number is not guaranteed to be accurate, and should only be taken
	 to be a hint."


2) From RFC977 section 3.2.1 where it talks about the data returned by
the "group" command:

	"The successful selection response will return the article numbers
	 of the first and last articles in the group, and an estimate of
	 the number of articles on file in the group.  It is not necessary
	 that the estimate be correct, although that is helpful; it must
	 only be equal to or larger than the actual number of articles on
	 file.  (Some implementations will actually count the number of
	 articles on file.  Others will just subtract first article number
	 from last to get an estimate.)"

Number 1 states that INN will not always return the true low water mark
and number 2 sort of implies that at least the difference between low
and high should not be taken as the number of articles.  It could be
argued that RFC977 does not allow INN to return an incorrent low water
mark, but in practice I doubt very much whether there are many (any?)
news readers out there that would fall over if they encountered a dodgy
low water mark.

Consider also that an expire could remove articles from the "low" end of
a group and update the active file's low water mark between a reader
issuing a "group" command and it subsequently issuing an "article"
command for the lowest article.

I think it is reasonable to expect a news reader to be able to cope with
one or more articles missing at the "low" end of a group whether or not
the active file or a group command says they should be there.

Cheers,

Mark.
-- 
UnipalmPIPEX, 216 The Science Park, Cambridge, UK      Work: markt@pipex.net
Phone: +44 1223-250120, Fax: +44 1223-250121             Play: mark@kram.org
                                                 UKUU: mark@kram.ukuu.org.uk
                                      Fidonet: 2:2504/100.10 or 2:254/153.15


Re: cyclic news file system - two interesting quirks
#6389
Author: Brad Templeton
Date: Mon, 08 Apr 1996 00:00
24 lines
1836 bytes
No, remember that the overview file is read frequently (each session) by
every reader of the newsgroup.  Now I suppose one could do some balancing
of readers vs. article count, but assuming readership is high, it is worth
the trouble to build an overview file that is either entirely contiguous,
or is stored in large blocks, like 16K at a time (about 40 article headers
per 16K block on a typical system.)  Perhaps even 32K

You do *not* want to have an overview read skip all over the disk for each
1K block of overview.

In fact, ideally you want an overview format with a header table at the
front, with seek addresses, so to read an article, you read the overview
header table (cached if possible), get the seek address of the overview entry,
read that, get the seek address/coordinates of the article, and read that.

Or, of course, in reading a newsgroup, you want to read the overview entries
of all the new articles, plus, in some cases the references lines of their
predecessors.
-- 
Brad Templeton, publisher, ClariNet Communications Corp.	 info@clari.net
The net's #1 E-Newspaper (1,300,000 paid sbscrbrs.)  http://www.clari.net/brad/

Re: cyclic news file system - two interesting quirks
#6395
Author: Mark Delany
Date: Mon, 08 Apr 1996 00:00
107 lines
5130 bytes
brad@clarinet.com (Brad Templeton) writes:

>Actually, my own plans had never thought of putting the overview data
>in with the articles.  As you note, there are problems doing that.
>I felt maintaining the overview data in some other way (its own private
>spools or set of cyclic files for example) might make some sense.  Overview
>data is much smaller, and it's more important that it be kept contiguous
>for any given newsgroup -- in fact I would say it is fairly vital, as
>you expect newsreaders to make the most heavy use of overview data.

Yup. A separate spool suffers similar problems in that they are
separate spaces you have to manage and try and size proportionally to
each other. It also means potential more head movement unless you keep
all of the overview on separate disks from the articles.


A sortof cute idea that I eventually discarded was this:

.----------------------------------------------------.
| Article data                    Overview Data      |
|A1 A2 A3 B1 B2 A4->             <- A4 B2 B1 A3 A2 A1|
|                                                    |
.----------------------------------------------------.

When the two ends meet, both ends wrap. It sizes the two ends
perfectly, but all that head movement was a worry as, at some point
the two edges have to converge on one disk and the head will rattle
from one end to the other while that disk fills.


>(I would change the poorly designed overview format while at it, however.)

At the cyclic library boundary the contents of NOV and article are
unknown (the idea being of course to ultimately bolt it into the
bottom of innd which has already done all the hard work to parse the
article and prepare the NOV data). Here's what the user-supplied
pseudo-C might look like:

stash_article(iov, nov, ngcount, ngroups)

    IOVEC	iov[iovcount];	/* Holds article */
    char	nov[novlen];
    int		gcount;
    char	**grps;

{

    OPAQUE_ARTICLE_KEY	ARTKEY;
    long		gnum;
    OPAQUE_GROUP_KEY  	GRPKEY;

    cycle_art_write(mfs, iov, iovcount, &ARTKEY);	/* Write article */

    HISsetkey(messageid, &ARTKEY);	/* record the pseudo filename */

/* Stash the NOV entries in each group */

    for (i= 0; i < gcount; i++) {
	gnum = cycle_grp_write(mfs, grps[i], nov, novlen, &ARTKEY, &GRPKEY);
	active_stash_latest(ngroups[i], gnum, &GRPKEY);
    };


There's a bit of handwaving missing wrt "xref:" entries and
pre-allocation of article numbers within group, but I've left that out
for clarity.

You might note that the active file is given an additional field which
is the pointer to the last NOV entry for that group. That's quite a
significant increase in active file size btw (my active goes up by
about 30% and history goes down by about 10%). I reckon the active
file lends itself to a modified form of cycling as well, but that's
another story entirely.

>Entirely contiguous overviews would be nice but do cost a bit of efficiency
>at write time.  But they do make it up on read.  But you can compromise
>and just use a very large block size for overviews.

Unless you can fit all of the NOV entries for a given group into a
single large contiguous block then any other arrangement will
ultimately see them dispersed randomly across the NOV disk(s). What
the sequential writing helps encourage is a single head sweep across
the disk(s). In the more-than-one-block scenario, I'm not sure how
much difference it makes whether the blocks are 4K, 8K, 16K etc. The
total data read is about the same, the total head movement is about
the same, the only difference is the number of stops along the way.

Furthermore, depending on how much pointer information you retain into
the current NOV block, you may end up doing large reads to slurp in
the NOV block just to stash a single NOV entry. That strikes me as
self defeating since every inbound article requires at least one NOV
entry.

>Low article numbers are not much problem, really.  Right now they only
>get calculated once a day.  You could change this to a program that just
>reads the overview files and pulls out the minimum article number.

That's what I meant in another post by a cyclic re-number, still way
too much NOV I/O for my liking. The other point is that the articles
only disappear once a day now so the once-per-day calculation is
exactly right for the whole day. With a cyclic system articles
disappear by the minute so lownums get out of date by the minute.


Regards.

Re: cyclic news file system - two interesting quirks
#6426
Author: Mark Delany
Date: Tue, 09 Apr 1996 00:00
76 lines
3263 bytes
brad@clarinet.com (Brad Templeton) writes:


>the trouble to build an overview file that is either entirely contiguous,
>or is stored in large blocks, like 16K at a time (about 40 article headers
>per 16K block on a typical system.)  Perhaps even 32K

I agree that overview access needs to be nice and fast.

>You do *not* want to have an overview read skip all over the disk for each
>1K block of overview.

True. I've settled on 4K for now as an arbitrary number to get things
kicking, but it could be bigger.

But...

>In fact, ideally you want an overview format with a header table at the
>front, with seek addresses, so to read an article, you read the overview
>header table (cached if possible), get the seek address of the overview entry,
>read that, get the seek address/coordinates of the article, and read that.

.. doesn't this description imply skipping all over the disk? If you
have a table of seek addresses for the article *and* the overview
entry, doesn't reading even the overview entry imply skipping all over
the disk?

>Or, of course, in reading a newsgroup, you want to read the overview entries
>of all the new articles, plus, in some cases the references lines of their
>predecessors.

My plan of attack is to embed the overview entry with the pointer to
the article, eg:

.-----------------------------------.   <----Start of NOV data for group X
|0001 AAAAAA NOVNOVNOVNOVNOVNOVNOV  |
|0001 AAAAAA NOVNOVNOVNOVNOVNOVNOV  |
|0001 AAAAAA NOVNOVNOVNOVNOVNOVNOV  |
|....                               |
|                                   |
|00xx                               |
.-----------------------------------.


Where AAAAA is the pointer to the article and NOVNOVNOV is the
variable length overview data (ie the line currently written into
.overview file). Thus each slurp of data gets everything but the
article proper.

The only question is how big the block is. If it's too large, I
maintain that read and updating it *may* cost more than the win from
the contiguous read. What too large is, of course, an interesting
question. I don't pretend to know what the correct value is yet or
even it it's the same the world over.

Now, If I understand you correctly, you plan to go:


.------------------.   <----Start of NOV data for group X
|0001 AAAAAA NNNN  |
|0002 AAAAAA NNNN  |
|....              |
|                  |
.------------------.

Where NNNN is a pointer off to the overview data. Is that what you
mean? If so, isn't that ultimately more seeks depending on the NOV
fetch rate?


Regards.




Re: cyclic news file system - two interesting quirks
#6436
Author: Alan Brown
Date: Tue, 09 Apr 1996 00:00
26 lines
1821 bytes
In article <4k8iaj$neb@bushwire.mira.net.au>,
Mark Delany  <markd@mira.net.au> wrote:

>Yup. A separate spool suffers similar problems in that they are
>separate spaces you have to manage and try and size proportionally to
>each other. It also means potential more head movement unless you keep
>all of the overview on separate disks from the articles.

Given a set of striped disks is there a reason not to put the NOV
data in the usual over.view/ tree on that spread partition?

Will it impinge on the system overly?

Roll on *cheap* 800Mb-2Gb solid state hard drives - if RAM prices over the 
last 4 years had continued the trend they'd followed over the previous 20
they'd be both affordable and in common use. Then a lot of the arguements
about overview data access would be moot and our servers would have 1Gb
of memory to boot. :-)

AB
-- 
"But you can't say they have arrived to classify your nervous lies
 What's right, what's not, what may not be. Don't try your tricky tests on me
 For I won't live in fear my friend - that every day could be my end"

Re: cyclic news file system - two interesting quirks
#6544
Author: Mark Delany
Date: Sat, 13 Apr 1996 00:00
63 lines
3416 bytes
brad@clarinet.com (Brad Templeton) writes:

>In article <LOC.4kc7e5$1cq@bushwire.mira.net.au>,
>Mark Delany  <markd@mira.net.au> wrote:

>There are two things you need to do:

Indeed.

>a) Get a single article, which means read the overview to find the
>seek address of the article text, and seek to that text.   Ideally you
>want to be able to get to the overview for that article quickly, thus
>a seek address directory at some place, the front of the overview, to
>seek directly to any given article.

I can see two access paths here. First, when the reader has the
specific message id, in this case history provides a direct seek
address (where ever you now see a path in history or whatever,
substitute a human readable hex encoded string which contains a
file/drive index, a seek offset and a few other important numbers).

Second when the reader has the article number for a particular group,
it strikes me that the reader is most likely to have the article
number after it has done a GROUP command to nnrpd - sure they can get
it other ways, but this has to be the 99.9% most common sequence.

Thus if an nnrpd server minimally caches the details of the last NOV
data for the group it has read, then it has all the info it needs to
seek directly to the article location as the NOV (News OverView)
record for an article includes the seek address.

In the rare event that a reader requests an article number "out of the
blue", then the NOV will have to be read first to gain the seek
address.

>b) Read a whole series of overview records at once.  You need to seek to the
>first, and then read the rest.   To seek to the first if it's not the first
>in the whole group, you still want a seek address to go their directly.

Agreed.

>Remember overview records are around 340 bytes, so there are only 3 per
>1K disk block.  It is worth getting seek addresses where possible to cut
>down on reads.

I remember. There are also 12 per 4K block and 24 per 8K block. I
don't know why you have this facination with 1K blocks, I reckon
they're too small to be useful for both NOV and article blocks :>

My current library is limited to a unified block size for articles and
NOV and, as I may have mentioned previously, I have tentatively
settled on a unified block size of 4K as that superficially represents
a reasonable compromise between a good article block size and a
reasonable "slurp" size for NOV. But, that's pretty much just my "best
guess", it can be changed at compile time if measurements suggests a
better value. Also, there is no fundamental reason why they have to be
unified, the file structures allow it, it's just the code that
doesn't.


Regards.

Re: cyclic news file system - two interesting quirks
#6549
Author: Brad Templeton
Date: Sat, 13 Apr 1996 00:00
23 lines
1712 bytes
In article <LOC.4kc7e5$1cq@bushwire.mira.net.au>,
Mark Delany  <markd@mira.net.au> wrote:

There are two things you need to do:

a) Get a single article, which means read the overview to find the
seek address of the article text, and seek to that text.   Ideally you
want to be able to get to the overview for that article quickly, thus
a seek address directory at some place, the front of the overview, to
seek directly to any given article.

b) Read a whole series of overview records at once.  You need to seek to the
first, and then read the rest.   To seek to the first if it's not the first
in the whole group, you still want a seek address to go their directly.

Remember overview records are around 340 bytes, so there are only 3 per
1K disk block.  It is worth getting seek addresses where possible to cut
down on reads.
-- 
Brad Templeton, publisher, ClariNet Communications Corp.	 info@clari.net
The net's #1 E-Newspaper (1,300,000 paid sbscrbrs.)  http://www.clari.net/brad/

Re: cyclic news file system - two interesting quirks
#6560
Author: Brad Templeton
Date: Sun, 14 Apr 1996 00:00
33 lines
2281 bytes
In article <LOC.4ko3ql$n9e@bushwire.mira.net.au>,
Mark Delany  <markd@mira.net.au> wrote:
>Second when the reader has the article number for a particular group,
>it strikes me that the reader is most likely to have the article
>number after it has done a GROUP command to nnrpd - sure they can get
>it other ways, but this has to be the 99.9% most common sequence.
>
>Thus if an nnrpd server minimally caches the details of the last NOV
>data for the group it has read, then it has all the info it needs to
>seek directly to the article location as the NOV (News OverView)
>record for an article includes the seek address.
>
>In the rare event that a reader requests an article number "out of the
>blue", then the NOV will have to be read first to gain the seek
>address.

This depends.  If you are doing a web based newsreader, as I have been
doing, you want the fastest coordinate access to the articles that is
safe to provide.  If that's article number, then you want that to
be efficient.   Message-id usually requires a database lookup that
may involved several seeks and reads in a large index database, and
a raw access can be more efficient.

However, one could -- if one had total control on the system, have the
web URLs contain the raw access coordinates -- seek address and file location --
as long as you could be sure they would not change.   So perhaps this works
ok.

-- 
Brad Templeton, publisher, ClariNet Communications Corp.	 info@clari.net
The net's #1 E-Newspaper (1,300,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