🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: news.software.nntp
Article #64529

Re: Newsreader programming - sorting one million lines ?

#64529
From: Juergen Helbing
Date: Wed, 26 Mar 2003 06:38
138 lines
6265 bytes
Heiko Studt <UsenetBecky@goldpool.org> wrote:

>Now, on screen, you want to show a new line: You load the complete XOvers of
>those lines you show and those which have the same sorting-10-chars. Now you
>can sort *these* in a complete way (subject, Date, else) and save the sorting
>to the .idx-file. 

Sorting while display is done seems to be an attractive method.
Unfortunately it fails if someone wants to 'seek forward'...
(Skip to next unread message.... Find text, ....)
Then the sorting is done in the background and the desktop
does not update for a long time.


>Why? You *only* need to get for every XOver the sort-string. This has to be
>done in *any* algorithmic as best as this would be. 

The problem of sorting huge files is locality:
If sorting is done chunks and the file is read sequentially, then
sorting can be very fast (the old 'tape-sorting' methods are using
this approach).
But as soon as it comes to "random access" to a one gig file
then the access-time of the harddisk is the bottleneck.
And even very fast harddisks need 3-5 mSecs (or more)
to read a small block which is 10 tracks ahead.


>No.
>You get the XOver line by line. In *any* case.
>Now you can parse this line to get the things you need for sorting (10 chars).

This seems to be a kind of "hashing" - the hash is the first N chars of
the sort-item. This wakes my curiosity:
If a sorting job cannot be done in memory (too large) 
- and not on harddisk (too slow) - then using a "mix method"
which reserves just the memory for the hash could be a solution
to _max_out_ the performance of the sort.
It would be even possible to vary the size of the hash depending
on available memory....

>> used 1e6 times....  Having a fast disk with 1 mSec 
>> access to every item would still need 1000 seconds....
>
>A fast disc should AFAIK even be faster... ;-P

AFAIK it would be even slower.

>But you didn't understand me. I want to sort *while* loading the XOvers. BTW:
>You have anyway the problem of loading the XOvers out of disk. This can't be
>prevented in any kind you want to try.

If I understand you correctly then I'm reading the Xover file sequentially.
I'm extracting the first N chars of the sort item (as hash) and keep them 
sorted in memory. Sounds all very good.
If I find an item with an identical hash now then it is necessary to 
reload all the items with the identical hash and compare then fully
to the current item to sort.
Now the problem: This could be a lot in the newsgroups: 
Many Subject - or From lines have identical first 10 chars.

If the actual read Subject would be:  Startrek Enterprise - ......
and a video multipart post (usually 1000-2000 headers) was
done one week ago (headers 1000-3000) and now again
(headers 560.000 - 562.000) then it would be necessary
to compare 2000 times a string with older strings from the harddisk.

The problem is then that the 'old strings' (with identical hash)
must be accessed 2000 times _again_and_again !

Of course it would be possible that the 'old strings' are still
in the disk-cache - but if a few posts are overlapped then
this will result in a lot of disk-accesses.

It seems to be necessary to implement a test.


Please understand me right:
I'm not saying that your method is bad. It sounds really good.
Therefor I'm trying to discuss it with you in depth.

>Do you want to save the real XOver to disc afterwards or not? 

No - the Xover file is on the harddisk because I need it for delivery
to clients. (MyNews is a server which delivers the full header-list
to clients - even if no articles are available yet).

Until today I am _not_ keeping sort-indices for the XOVER file.
Of course this is a problem of incremental design: MyNews was
never designed to handle one million headers in one group.

And now I'm trying to find a solution how to implement this new
requirement: Either I'm finding better sorting methods - or I need
to create (and maintain - and expire) sorting indices - which would
be even more work (and slower than everything else)....


>Perhaps I didn't understand. 

Your understanding is very good.


>As this complete discussion is OT, I set a F'up2:Poster. 

Computer scientists in an 'algorithm' newsgroup would believe
that I'm completely mad. Their default answer would be to use 
a database. Such people who are regularily dealing with huge
databases have no idea about Usenet and the special requirements
for downloading enormous amounts of new data all the time,
sorting and presenting them on the users desktop - and (mostly
important) to expire them.....

Our problems when we are writing news-readers and new-servers
are so specific (and demanding) that news.software.nntp would be
the only newsgroup where things are really understood.

And be sure - earlier or later all NNTP software programmers
are having the same problems. Then they can google for the
solution :-)
  
If any of the elders or admins believes that the discussion of
my question would belong to another newsgroup, then please
let me know. 

>Perhaps a
>German-Mailcontact would be less misunderstandable

If I'm going to implement a test-version of your approach 
and have problems with it, then I'll contact you directly.
But because also other interesting answers were posted
I believe that we can stay here for the next two levels.


Thanks for sharing your experience with me.

-- 
Juergen

Technical Details
Message-ID: <11387.q33208@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-03!sn-xit-01!sn-xit-08!supernews.com!news.alt.net!usenet
References: <4540d.o33203@archiver.winews.net> <b5pkd8.1kg.1@Heiko.Studt.dialin.t-online.de>

Show Full Headers
Complete Article Headers
Message-ID: <11387.q33208@archiver.winews.net>
Subject: Re: Newsreader programming - sorting one million lines ?
Date: Wed, 26 Mar 2003 06:38:11 +0000
From: archiver@i3w.com (Juergen Helbing)
References: <4540d.o33203@archiver.winews.net> <b5pkd8.1kg.1@Heiko.Studt.dialin.t-online.de>
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-03!sn-xit-01!sn-xit-08!supernews.com!news.alt.net!usenet
Newsgroups: news.software.nntp
Organization: Altopia Corp. - Usenet Access - http://www.altopia.com
Lines: 137
X-Newsreader: MyNews