🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: news.software.nntp
Article #92889

Re: inn scalability improvements

#92889
From: Kevin Bowling
Date: Thu, 25 Jun 2026 04:15
109 lines
7148 bytes
On 6/23/26 15:14, InterLinked wrote:
> On 5/9/2026 7:26 PM, Kevin Bowling wrote:
>> Hi,
>>
>> I've been looking at inn as I run it:  tradspool/ovsqlite on 
>> FreeBSD+ZFS with unlimited retention and trying to fix some scaling 
>> issues.
>>
>> ovsqlite: Add direct reader mode for nnrpd with WAL
>> https://github.com/InterNetNews/inn/pull/338
>>
>> expireover: Add bloom filter for fast history existence checks
>> https://github.com/InterNetNews/inn/pull/339
>>
>> expire: skip per-article SMretrieve via cancel tombstone log
>> https://github.com/InterNetNews/inn/pull/340
>>
>> The first two have been running on csiph.com for a few days without 
>> issue.  I haven't yet deployed the last one yet but will publish 
>> results in the PR when I do.
>>
>> The general theme of all three is to reduce random or sync I/O.  In 
>> the case of expireover and expire, the general problem is somewhat 
>> similar but the root cause and fix are fairly different.
>>
>> expireover checks history for every article and this turns into a very 
>> slow and random serial I/O for every article in the history DB.  The 
>> new option is to use a bloom filter with a configurable false positive 
>> rate, chosen for some acceptable RAM vs accuracy tradeoff by the admin 
>> and their spool size.  The bloom filter is created with a much more 
>> efficient streaming read of the entire history file.  In the case of a 
>> false positive (bloom claims article in history, but expire removed 
>> it), it gets cleaned up on the next expireover run (entropy introduced 
>> by hash churn make this probabilistic reality).  On my system this is 
>> a 1100x improvement, 2 weeks down to 18 minutes.
>>
>> expire is a bit more involved.  We don't want the same bloom tradeoff, 
>> exactness trades a bit of RAM (pending deletes) for totally 
>> eliminating unnecessary disk I/O for verification.  If we keep a 
>> tombstone log of articles expireover deletes, and any cancels, and we 
>> trust the state of the spool, we can eliminate all speculative work 
>> and only deal with the actual history cleanup needed.  On my system 
>> this will net a 2800x improvement, 2 days down to sub minute.
> 
> I've been thinking about this recently as part of some of other work I 
> have been doing and so in the past few days, have had a renewed interest 
> in your optimizations.
> 
> A week or two ago, I was trying to figure out how to suck articles in a 
> manner that preserves their ordering across all groups in which an 
> article appears. In the end, I think there is really only one solution. 
> Save all the message IDs + date header + Xref header for the articles 
> you want to suck, sort them by Xref header with a fallback to Date, and 
> then suck the articles in that order. (This is quite a bit slower than 
> just going group by group, since you need to change the GROUP quite 
> often, though I suspect faster (and nicer) to the server being sucked 
> from than requesting by Message ID.) This won't work if there are a lot 
> of articles being sucked by a wimpy machine, but fortunately I'm not 
> operating at the scale.
> 
> I've been doing this in two passes, first saving the Message-IDs to a 
> file and then sucking those, so that operations can be resumed and are 
> idempotent. I check if an article was already in history to avoid asking 
> for it again. I was surprised that even with a few hundred thousand 
> articles, when resuming a partial suck, just weeding out all the 
> duplicates would take many minutes, due to all the history traversals. 
> Naturally, this made me think of using a Bloom filter (and I was 
> reminded of the optimization you did here and its encouraging results) 
> and indeed, that did speed that up quite a bit. I chose to retain 
> accuracy in that case, so if the bloom filter answers yes, I check 
> history anyways to confirm, but if there are a lot of negative matches 
> then it goes much faster.
> 
> Although I added a Bloom filter for just this one operation, I'm now 
> toying with the concept of having one in the background to use for all 
> operations. For example, for IHAVE/CHECK/TAKETHIS, at the moment I check 
> history to see if the Message-ID is present. I don't see why I can't 
> just create a Bloom filter at startup, adding new articles to it as 
> received, and recreating the filter on expire operations, and in the 
> case of accepting an article we don't have, then a history scan is no 
> longer necessary, even with a small Bloom filter (somewhat mediocre 
> false positive rate).
> 
> As I understand it, only recently with your change does INN use Bloom 
> filters at all, but I'm curious if you have any thoughts about adopting 
> them for other purposes like this (either in INN, or news software in 
> general). I'm thinking a lot of history related operations could benefit 
> from them, but maybe there is something too good to be true here...

It is in lib/, depending on the usage it may need to be tweaked slightly 
to accept a comparator (different than the MD5-optimization) or offer 
different function signatures for different uses.

You may find the benchmarks in 
https://github.com/InterNetNews/inn/pull/349#issuecomment-4760898620 
interesting.  With that I wouldn't assume history read path is a big 
bottleneck in most cases without seeing some evidence.

Keep in mind hiscache sits in front of CHECK, which is a HASH variant of 
what you might be suggesting.

Lookup might benefit from a cache, but remember it is done by nnrpd so 
it scales by processes (and inversely makes cache sharing harder).

I would default to HASH style of implementation (and windowing, like 
LRU, to implement small bounded caches) without a good overriding 
reason; the Bloom filter is a specific optimization where space 
efficiency and totality (in one direction, as you noticed) are both 
required.
Technical Details
Message-ID: <111ia15$1cbq$1@csiph.com>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!weretis.net!feeder9.news.weretis.net!csiph.com!.POSTED.172.83.103.228!not-for-mail
References: <10tofqn$edc$1@csiph.com> <111f0g2$2jdd3$1@dont-email.me>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!weretis.net!feeder9.news.weretis.net!csiph.com!.POSTED.172.83.103.228!not-for-mail
From: Kevin Bowling <kevin.bowling@kev009.com>
Newsgroups: news.software.nntp
Subject: Re: inn scalability improvements
Date: Wed, 24 Jun 2026 21:15:33 -0700
Organization: csiph.com Internet News Service
Message-ID: <111ia15$1cbq$1@csiph.com>
References: <10tofqn$edc$1@csiph.com> <111f0g2$2jdd3$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Thu, 25 Jun 2026 04:15:33 -0000 (UTC)
Injection-Info: csiph.com; posting-host="172.83.103.228";
	logging-data="45434"; mail-complaints-to="admin@kev009.com"
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:3g2h+6YsSidNWJlaqsOoNdos8XQ= sha256:Gi7Wq+31vh3HfQ4dqP4KI82Lk7wrCDpUOeoegNhXwT0=
	sha1:z1QUn8ImusMNrCqmM3BZ/YoGRTs= sha256:XX7Z3LnqYUoQgEsCzqD5oynx1uy2y0+ozOmiDicf3v8=
Content-Language: en-US
In-Reply-To: <111f0g2$2jdd3$1@dont-email.me>