🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: news.software.nntp
Article #64518

Re: Newsreader programming - sorting one million lines ?

#64518
From: Klaas
Date: Tue, 25 Mar 2003 08:40
30 lines
2522 bytes
After careful consideration, Jeffrey M. Vinocur muttered:

> I wonder if the reason you're having problems is that your sort
> algorithm has poor locality, causing a lot of swapping.
> 
> I just poked at the source for GNU sort(1) from the textutils
> package, and it seems to be using mergesort, which surely would
> have better cache locality than quicksort.  You might try that,
> before resorting to drastic measures.  Actually, you can even
> estimate the time you'll need for the memory-access at least:
> take N headers you can hold in memory (say, 1,000,000 of them)
> and do a linear traversal of all of them, and multiply by
> log_2(N) (here, about 20).  If that's acceptable, it's probably
> worth implementing mergesort.

It'd be interesting to see if the improved locality of mergesort helps 
considering its memory requirements (roughly double quicksort), which 
will also cause a lot of swapping.  I'd keep quicksort around for use 
with the smaller groups.

Also, radix sort would work well for sorting by artno (O(n)), although 
it's likely that you'd save the articles in that order anyway.

I definately agree that you should do the multipart combining _first_.  
In large binary groups, that should reduce your problem by 1/20 or so, 
and the articles should already be roughly in the order necessary to 
create the multipart index.

-Mike
Technical Details
Message-ID: <Xns93492FF0660DBnothing@209.98.50.131>
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!archiver1.google.com!news1.google.com!newsfeed.stanford.edu!lios!news.gweep.ca!nntp.cs.ubc.ca!nntp-relay.ihug.net!ihug.co.nz!west.cox.net!cox.net!news-out.visi.com!hermes.visi.com!green.readfreenews.net!news.readfreenews.net!authen.yellow.readfreenews.net.POSTED!not-for-mail
References: <4540d.o33203@archiver.winews.net> <b5ob7g$akq$1@puck.litech.org>

Show Full Headers
Complete Article Headers
Message-ID: <Xns93492FF0660DBnothing@209.98.50.131>
Subject: Re: Newsreader programming - sorting one million lines ?
Date: Tue, 25 Mar 2003 08:40:41 +0000
From: Klaas <spamhole@klaas.ca>
References: <4540d.o33203@archiver.winews.net> <b5ob7g$akq$1@puck.litech.org>
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!archiver1.google.com!news1.google.com!newsfeed.stanford.edu!lios!news.gweep.ca!nntp.cs.ubc.ca!nntp-relay.ihug.net!ihug.co.nz!west.cox.net!cox.net!news-out.visi.com!hermes.visi.com!green.readfreenews.net!news.readfreenews.net!authen.yellow.readfreenews.net.POSTED!not-for-mail
Newsgroups: news.software.nntp
Organization: This is a valid email address
User-Agent: Xnews/5.04.25
Lines: 29
NNTP-Posting-Date: 25 Mar 2003 02:40:41 CST
NNTP-Posting-Host: 29f2d70c.authen.yellow.readfreenews.net
X-Trace: DXC=\OhS3<NK5_Fj=]gTF94TmDbQ9W<K20`3BO6Gh9bA988N_T==;2R[<CB4E?RHcOQk;EY0]T72P?cgLK?4;`6aSj4D
X-Complaints-To: abuse@readfreenews.com