Article View: news.software.nntp
Article #92890Re: inn scalability improvements
From: InterLinked
Date: Thu, 25 Jun 2026 14:33
Date: Thu, 25 Jun 2026 14:33
170 lines
10529 bytes
10529 bytes
On 6/25/2026 12:15 AM, Kevin Bowling wrote: > 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. At the moment, I'm only thinking about them for Message-IDs / history, since that's probably the biggest bottleneck in regular usage I can think of. > 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. Yeah, that is interesting. It looks like hisv6 is sort of a flat file from what I can see although it hashes the Message-IDs, which I do not. IIRC, an earlier history implementation in INN didn't hash Message-IDs. I would guess without hashing, the performance speedup for random lookups would be even greater. > Keep in mind hiscache sits in front of CHECK, which is a HASH variant of > what you might be suggesting. Hmm, yeah, that probably would be even better for that particular case, given you probably only care about the most recent articles. At some point though, you will need to check if the Message ID exists in history at all, and a cache can't do that, but a Bloom filter can, at least if the answer is "no" there you don't need to scan history at all. So having it as a stopgap method still seems helpful - check the cache, then the Bloom filter, then scan history. I will certainly add a small cache for "recent" articles as well, that would help even more. The use case I mentioned before here was one where not all the Message IDs were recent and so a cache would not have been sufficient. It was basically checking an arbitrarily long list of Message IDs to see if they were in history or not. A Bloom filter sped this up by about 6x in a test I did, even when I still checked history anyways when the answer was 'yes', which was good enough for me. (For the edge case if all the articles are in history, there is no speedup, but that was somewhat unlikely here.) > Lookup might benefit from a cache, but remember it is done by nnrpd so > it scales by processes (and inversely makes cache sharing harder). Ah, yeah that makes sense then. My news software is a single multi-threaded process (actually just one part of one), so I think in-memory structures like Bloom filters or hash tables would both work a lot better for me since I can keep the filter up to date easily. > 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. I like Bloom filters for "does this article exist in the entirety of history at all"? I don't think there is any other way to do that. Certainly there are other cases where that may not be the most appropriate question to ask upfront. Similar to your hash suggestion, the next bottleneck I've stumbled upon is when doing NEWNEWS, a client gets a bunch of Message-IDs, and then probably will use OVER or the like to get more details on those articles. I found on some systems, that was quite slow, even for a small number of articles, since, again, it ended up scanning history for every article to find it from the Message-ID. Obviously I should already be caching the most recent articles in some way so I don't need to scan history for them. This is similar enough to the CHECK cache use case so probably the same thing could be used for both of them. I'm thinking maybe a fixed size ring buffer with hashes of the most recent articles, with offsets into the history file. It would seem to me both for CHECK and NEWNEWS + OVER patterns, a FIFO style ring buffer makes sense - are you suggesting an LRU policy from traffic analysis of article requests, in addition to, or instead of, just caching the N most recent articles?
Technical Details
Message-ID:
<111je8o$3rg18$1@dont-email.me>Path:
mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!eternal-september.org!feeder.eternal-september.org!nntp.eternal-september.org!.POSTED!not-for-mailReferences:
<10tofqn$edc$1@csiph.com> <111f0g2$2jdd3$1@dont-email.me> <111ia15$1cbq$1@csiph.com>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!eternal-september.org!feeder.eternal-september.org!nntp.eternal-september.org!.POSTED!not-for-mail From: InterLinked <nntp@phreaknet.org> Newsgroups: news.software.nntp Subject: Re: inn scalability improvements Date: Thu, 25 Jun 2026 10:33:59 -0400 Organization: A noiseless patient Spider Lines: 170 Message-ID: <111je8o$3rg18$1@dont-email.me> References: <10tofqn$edc$1@csiph.com> <111f0g2$2jdd3$1@dont-email.me> <111ia15$1cbq$1@csiph.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Injection-Date: Thu, 25 Jun 2026 14:34:02 +0000 (UTC) Injection-Info: dont-email.me; logging-data="4046888"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX187IUcbySRmgrHL8l0Yzhk/FNz7j2J4xT0="; posting-host="e81aa6575a8e568ee87a6f01c326b4d9" Cancel-Lock: sha1:tCc5AjJITKKoSh0NihnJM4/5VxE= sha256:vwmhn297VofOZ1+BEs9W3tlnRIaDU6fj3fy6prnyG+4= sha1:cAMS4FEcuds3b9CZcxmi2aWm380= Content-Language: en-US X-Mailer: MailNews/52.9.9224a1 In-Reply-To: <111ia15$1cbq$1@csiph.com>