Article View: news.software.nntp
Article #64513Re: Newsreader programming - sorting one million lines ?
From: Jeffrey M. Vinocur
Date: Tue, 25 Mar 2003 01:26
Date: Tue, 25 Mar 2003 01:26
33 lines
2321 bytes
2321 bytes
In article <4540d.o33203@archiver.winews.net>, Juergen Helbing <archiver@i3w.com> wrote: > >How do you sort your header-lists if they dont fit into memory ? Well, in principle a modern memory manager should take care of writing them to disk as needed. (That is, most of the time virtual memory will suffice, rather than you having to open a temporary file yourself.) 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. Otherwise, I'd say it's time to consult an algorithmicist. Either ask in an appropriate newsgroup, or find a textbook. (I just checked the Cormen/Leiserson/Rivest text and didn't see anything useful, perhaps Knuth would be an appropriate resource.) -- Jeffrey M. Vinocur jeff@litech.org
Technical Details
Message-ID:
<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!news.ems.psu.edu!news.litech.org!not-for-mailReferences:
<4540d.o33203@archiver.winews.net>Show Full Headers
Complete Article Headers
Message-ID: <b5ob7g$akq$1@puck.litech.org> Subject: Re: Newsreader programming - sorting one million lines ? Date: Tue, 25 Mar 2003 01:26:08 +0000 From: jeff@litech.org (Jeffrey M. Vinocur) References: <4540d.o33203@archiver.winews.net> 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!news.ems.psu.edu!news.litech.org!not-for-mail Newsgroups: news.software.nntp Organization: Litech Systems Design Lines: 32 Sender: jeff@litech.org NNTP-Posting-Host: 66.218.0.75 X-Trace: puck.litech.org 1048555568 10906 66.218.0.75 (25 Mar 2003 01:26:08 GMT) X-Complaints-To: usenet@litech.org NNTP-Posting-Date: Tue, 25 Mar 2003 01:26:08 +0000 (UTC) X-Newsreader: trn 4.0-test76 (Apr 2, 2001) Originator: jeff@litech.org (Jeffrey M. Vinocur)