Article View: news.software.nntp
Article #64612Re: Newsreader programming - sorting one million lines ?
From: Juergen Helbing
Date: Mon, 31 Mar 2003 09:40
Date: Mon, 31 Mar 2003 09:40
163 lines
7646 bytes
7646 bytes
curt@kcwc.com (Curt Welch) wrote: >I've never had to solve that problem with my newsreaders, but I can throw >out a few things for you to think about. Your feedback is always highly appreciated. >With all interactive software, pure software speed isn't important. Don't >get lost focusing on algorithms. What's important is the responsivness of >the application. This has as much to do with UI design as it does with >optimizing performance of algorithms. Most good applications work not >because they simply "are" fast, but because they "seem" fast. Most the >time, it's just a magic trick, and illusion. <vbg>.... We are playing in the same league. Of course my newsreader is doing already a lot of work while it displays lines... or in the background. >Your problem is not that it >takes 60 seconds to sort 1.5M records, your problem is that the user is >being forced to wait 60 seconds doing nothing after they click a button >asking for the list to be resorted. This is correct for 'normal' displays. And this is the reason why I'm here in n.s.nntp: If a newsreader offers a function to "skip to next unread thread" then searching begins..... Especially if a single keystroke permit to switch display between 'all msgs' and 'hide specified lines'... I am already keeping a lot of info in 'additional indexes' - but they are still related (a part of) to the individual header lines. I am myself switching often display modes: "Sort by author" - to see if that guy posted other things. "Sort by subject" - for regular scanning binary groups "Sort by date" - for reading threads and older msgs. "Sort by filename" - for finding missing and reposted segments.... >So, many times, the best soltion is >not to make the sort run in 10 seconds instead of 60, the solution is to >find a way that the user is not forced to set their waiting at all. One >option for example, is to remove the button. Don't laugh. :) Please apologize - I could not resist: <vvvvbbbbbgggg> >An >interactive application that takes 60 seconds to respond to a direct >request is unuseable. It is almost always better to leave the feature out >of the application than to put one in which is unusable. This is right - and my "sorting times" are now close to 10-30 secs (with a progress indicator) - and before the app becomes unusable I'm looking for solutions... >The idea of "trust the vm system" is probably stupid. Yes - I can confirm this. >YOu never want to user to have to wait 10 seconds for the vm to swap the IU >code back in before the application responds to you hitting an abort >button. Unfortunately exactly this happened (for me) when a 300 Meg file is decoded and written to disk. The fclose() then flushes the file and it takes sometimes endlessly until the fclose() is done. (Of course flushing every 10 Megs is also no big fun - but a bit better :-) >The first and probably most useful trick is do the work at some other time >instead of waiting until they hit the "sort" button. For a newsreader, the >data you are talking about is header data, and all header data has to be >downloaded. Good point. Of course I am already doing 'filtering' while headers are coming in - and duplicate detection (multihost readers need this) and xpost detection.... With a good DSL line there are 300 headers/second coming in. And already filtering with 30 rules - and a msgid database of 250 Megs is slower (on my 400 Mhz PC with very fast harddisks) than the incoming data. :-( And of course I am myself starting to read newsgroups while headers are still fetched (sorting, filename analysis, ...). As I said in another answer: Newsreaders are a very demanding job for a PC when it comes to binaries. >So, do you re-sort the entire batch (causing >you to re-read the entire set of data from the disk), or can you store it >some clever way to prevent you from having to do all that work every time >you download new headers? Right now I am reading the full header file (Xover cache) - and while reading from disk I am doing some filtering (cancelled msgs, killed authors, specific filters). This is pretty fast as long as the headers are still fitting into memory. Of course I could store them presorted - or maintain index files. But updating 4 index files with each 500.000 items from a 250 meg data file at a rate of 300 headers/second seems to be impossible with current disk subsystems (on user PCs). So the header download would be throttled. Or the update is done "later" - or in an asynchronous way after the headers came in (this is what I'm doing alternatively). My problem is that already the filtering and necessary sorting and inserting (msgids) I'm doing maxes out my PCs. I'm simply afraid that adding workload at that time would make the software less attractively.... (There are people paying for online-time - even with DSL :-) >Then, when you want to disply the headers, you read and sort the A file to >get the first records. Once you have done that, you can display all the >"A" authors even though you haven't sorted the rest of the files. Depnding >on how the rest of the UI works, you may not even need to sort the rest >yet. You might be able to put off the sort until they scroll down in the >list and try to look at other records. Good approach. Unfortunately 'sorting' a header-list is always combined with threading..... (Of course I permit to sort by six ways - and still permit threading on/off) - which is also very useful (the feature I've most in nearly all newsreaders ;-). >So, this idea has issues, but the point of the example is trying to get you >to realize that there are a lot of tricks you can used based on the needs >of the application to do the work at different times so the user never has >to wait for the application to sort the entire 1.5M records. Yes - and you've initialized a new idea: I could maintain my existing method - and store the sorted indexes to disk. As soon as "new headers" arrived it would be only necessary to sort the "new headers" into the existing list. If a users reads his groups daily, then it might be only necessary to sort 5.000 new headers. If he reads just once a week - well: Then things take simply longer. >So, maybe you didn't want to hear all this, and it's no simple answer for >how to huge amounts of article data quickly, but it may give you some >things to think about that will help you solve your problem.... Thanks for your feedback. It is necessary to expand the disk-usage. But I'm getting closer. The feedback from the other gentle guys is still necessary to to do the incremental "sorting" - and I'm already afraid of "expiry". But there's new light ahead. CU -- Juergen
Technical Details
Message-ID:
<5940b.v33203@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!sn-xit-02!sn-xit-06!sn-xit-08!supernews.com!news.alt.net!usenetReferences:
<4540d.o33203@archiver.winews.net> <20030328194656.482$xw@newsreader.com>Show Full Headers
Complete Article Headers
Message-ID: <5940b.v33203@archiver.winews.net> Subject: Re: Newsreader programming - sorting one million lines ? Date: Mon, 31 Mar 2003 09:40:59 +0000 From: archiver@i3w.com (Juergen Helbing) References: <4540d.o33203@archiver.winews.net> <20030328194656.482$xw@newsreader.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!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-06!sn-xit-08!supernews.com!news.alt.net!usenet Newsgroups: news.software.nntp Organization: Altopia Corp. - Usenet Access - http://www.altopia.com Lines: 162 X-Newsreader: MyNews