Article View: news.software.nntp
Article #21766News data storage model
From: Olaf Titz
Date: Sun, 21 Sep 1997 00:00
Date: Sun, 21 Sep 1997 00:00
114 lines
6545 bytes
6545 bytes
bill davidsen <davidsen@tmr.com> wrote:
> | A specialized efficient implementation on a raw device could
> | outperform the current method vastly. From the Un*x POV it doesn't
> | look elegant, but who cares?
> I buy outperform, but "vastly?" I've done some Oracle benchmarks on
> SCO UNIX and Unisys SVR4, and access into a large file using o/s
> caching is not a lot slower than access into a raw partition using
> your own caching. I saw something in the order of 5-10% (Note: for
I didn't mean the Oracle comparison - "own FS on top of a single huge
Un*x file vs. own FS on a raw partition". I thought of the comparison
"own FS vs. storing everything in Un*x files and using Un*x
directories for management".
> think that going to a conventional f/s using more articles per file
> will give us at least an order of magnitude improvement.
May well be, given the particular inefficiencies of the Un*x directory
system. (Just yesterday I had to eliminate a control.cancel directory
which had grown to >300,000 files. :-()
I think (never saw it) the CNFS approach works this way. Note that
this already does the important step: away from the Un*x filesystem
management, towards an own FS.
This could be done even more radically. I imagine the following model
for news data storage:
We need two different types of file here: Variable-length-record
indexed files for _newsgroup directories_ (in conventional terms:
overview database) and _article directory_ (i.e. history database).
And sequential files for the articles themselves. Nothing more.
An implementation for sequential files can be very simple and fast.
I'd follow the old model of internally linked block lists: write the
block# of the next block of a file into the block itself. The access
path to an article files is its first block#. This almost completely
eliminates any management data structures for these files (other than
a free block bitmap).
Now for the index files. We need an article directory holding an index
for each article on the system, combined with additional info
regarding that article, indexed by Message-ID. Perhaps the hash
structure we have now is good enough for that, but it would be nicer
to design a structure where you can do deletions as well.
And we need one group directory per group, holding the complete list
of that newsgroup. Just think about it: use an overview file for that,
and you have all necessary information. You just don't need the
conventional article directories at all. (*)
Of course this can be tuned better. The group directories should be
indexed by article# for fast lookup (ARTICLE n). The index should be
organized in a way that traversal of those indices is easy (LISTGROUP,
XOVER). The B+ tree comes to mind as the canonical useful structure
for such requirements, but we could perhaps even do this in a simpler
way exploiting the fact that insertions always are made at one end of
the index space (deletions are not - expire really complicates the
whole model).
The group directories should contain more info than just the overview
record, but that's easy. Add the block# of the articles for simple and
fast access to the article files (perhaps even add a pointer to the
start of the body for the BODY command), add arrival and (where
applicable) expire time.
Now how to store this on Un*x? First, the active, newsgroups etc files
may remain like now (esp. taking a memory mapped active file into
account). Then pack everything described above into a single structure
and run that on its own raw partition(s). Or simpler: put the
article storage on a (set of) raw partition(s), and put the indexed
files into Un*x files a la DBM.
Now the fine print: on all files, implement clean locking mechanisms
so that concurrent write access on all of them is possible. I really
like the idea that expire should be a continuously running daemon
which always just deletes the oldest files in a set of newsgroups,
until enough space is free. (**) I also like the idea that this daemon
would be able to clean up overview entries (even history too?) along.
Dito for NoCeM processing.
With a considerable amount of work, perhaps this all could even be
integrated into INN, even if the result wouldn't look much like INN
any more (but there is a solid code base). We'd just need some
mechanism of access to articles from external programs, to implement
things like channel feeds. An inelegant but working solution would be
a separate daemon that acts as a (read only) NFS server for that.
There are other possibilities as well.
(*) A minimalistic approach to a better article storage on the Un*x
filesystem: take a hash from the Message-ID as file name. Simply run
an MD5 on it, encode that in hex or base64, split the string at regular
intervals with slashes so directories don't get to full.
That's all. Example:
<foobarfrotz@bigred.inka.de>
=> 01e04eacbe69a317314943ed6ad790e0 (hex)
=> /var/spool/news/articles/01e0/4eac/be69/a317/3149/43ed/6ad7/90e0
Where exactly to split would warrant some careful analysis, taking
into account how many files or subdirectories the average directory
would get vs. the number of lookups required to get at one article.
I haven't done that.
(**) I have hacked up an old version of dexpire to run as a daemon.
Never got into trouble with full disks since. To be published soon.
olaf
--
___ Olaf.Titz@inka.de or @{stud,informatik}.uni-karlsruhe.de ____
__ o <URL:http://www.inka.de/~bigred/> <IRC:praetorius>
__/<_ >> Just as long as the wheels keep on turning round
_)>(_)______________ I will live for the groove 'til the sun goes down << ____
Technical Details
Message-ID:
<603943$rc2$1@bigred.inka.de>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-mailReferences:
<5vpddn$qlb$1@news5.ais.net> <5vta1f$gtd$1@ftel.ftel.co.uk> <5vtibt$7i4$1@bigred.inka.de> <5vua1g$vb8$1@newssvr03-int.news.prodigy.com>Show Full Headers
Complete Article Headers
Message-ID: <603943$rc2$1@bigred.inka.de> Subject: News data storage model Date: Sun, 21 Sep 1997 00:00:00 +0000 From: olaf@bigred.inka.de (Olaf Titz) References: <5vpddn$qlb$1@news5.ais.net> <5vta1f$gtd$1@ftel.ftel.co.uk> <5vtibt$7i4$1@bigred.inka.de> <5vua1g$vb8$1@newssvr03-int.news.prodigy.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 X-Deja-AN: 274321006 Keywords: filesystem optimization X-Complaints-To: newsmaster@bigred.inka.de X-Trace: bigred.inka.de 874850245 28035 olaf 127.0.0.1 Organization: private Linux site, southern Germany Newsgroups: news.software.nntp