🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: news.software.nntp
Article #41202

History (was: Re: NoCeM & INN2.3)

#41202
From: Andrew
Date: Sun, 31 Oct 1999 00:00
63 lines
4262 bytes
In article <yl7lk3llie.fsf@windlord.stanford.edu>, Russ Allbery wrote:
>A couple nights ago, I spent four or five hours going through the existing
>dbz and history code in INN and figuring out how it worked.  Currently,
>lib/dbz.c really needs to be split into two files, one for tagged hash and
>one for normal history, and a common API stuck in front of them.  There's
>way too much ifdef stuff going on inside there.

Too right. I did something similar recently, and I was finding Emacs'
hideif-mode extremely useful :-)

>I'm also seriously considering a binary history file format, now that the
>contents are basically identical for each line and are all fixed-width
>fields.  For one thing, it would reduce the amount of data INN has to
>write out for the history file by a factor of three (helping both
>performance and some of the large file limits that people are already
>running into), and for another it would let the offsets stored in the
>index hashes be by record rather than by byte, which gives another four or
>five bits at the top of the offset to play with, which means that one
>could potentially do tagged hash even smaller than it is now.  But I
>haven't looked at that very much.

The other huge win you can get, with a little cunning, is to get rid
of the need to rebuild the hash table during expire, and do a true
cyclic history. That reduces the peak memory requirements by half.
Also, using a cyclic scheme means that you can preallocate the hash tables
at the optimum size and junk the apparently bug-ridden overflow code.

My design is based loosely on dbz, inspired more by the tagged-hash version
than the newer format, and is designed to scale up to hundreds of millions
of entires, or beyond, without excessive resource usage. It even behaves
tolerably well without using mmap, though this doesn't really reduce the
real memory requirements.

>While I was at it, I think it would be a good idea to roll the history
>cache from INN into the API as something you can optionally request when
>you initialize the API.  It's chummy enough with the history file already,
>and that would provide a few additional interesting benefits.  Like, for
>example, it's then only one step further to integrate the WIP cache in
>with the history cache, which would reduce the number of queries one has
>to do for incoming articles and let them all go through a standard API....

I didn't go quite this far; what I'm doing in my new code is to
effectively layer the history cache on top of the base history
API. There are a bunch of tools where the cache doesn't make sense,
whereas the main code doesn't really need to see anything _other_
than the cache API.

>And while I'm at it, I can make sure the lot of it can be easily made
>thread-safe.  History should actually support simultaneous readers without
>much trouble at all, although I think writes will still have to be
>serialized.

There are ways to get around this too; my dbz-derivative can actually
allow multiple concurrent writes from different processes or threads
(though I'm not actually doing that at the moment because of the locking
overheads). But even without that, there's still a rather obvious
approach to allow more concurrency on write operations.

-- 
Andrew, Supernews
http://www.supernews.com - UK and US individual and corporate NNTP services

Technical Details
Message-ID: <slrn81p29o.f2s.andrew+news@uk21.supernews.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: <3819A774.9C57FDCA@boerde.de> <7vei02$1n3@bigred.inka.de> <ylu2n8cokb.fsf@windlord.stanford.edu> <7vhcis$oq9@bigred.inka.de> <yl7lk3llie.fsf@windlord.stanford.edu>

Show Full Headers
Complete Article Headers
Message-ID: <slrn81p29o.f2s.andrew+news@uk21.supernews.com>
Subject: History (was: Re: NoCeM & INN2.3)
Date: Sun, 31 Oct 1999 00:00:00 +0000
From: andrew+news@supernews.com (Andrew)
References: <3819A774.9C57FDCA@boerde.de> <7vei02$1n3@bigred.inka.de> <ylu2n8cokb.fsf@windlord.stanford.edu> <7vhcis$oq9@bigred.inka.de> <yl7lk3llie.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: 542802001
X-Complaints-To: newsabuse@remarq.com
X-Trace: 941394235 .MYBPHMNN00017F00C uk21.supernews.com
Organization: RemarQ http://www.remarQ.com
User-Agent: slrn/0.9.5.4 (UNIX)
Reply-To: andrew@supernews.com
Newsgroups: news.software.nntp