Christian Biere wrote:
> Lloyd Bryant wrote:
> > If somebody has an exceptionally large number of 
> > files, then the sort could potentially add a substantial amount of time to 
> > the total required for a rescan (note: on my headless box, which is an 
> > obsolete P2-300, processing 7600 files, having this option active adds 
> > about 15 seconds to the time required for a rescan.  Not too bad....)

Well, I tried it with ~25000 files, both GLib 1.2 and GLib 2.0 but couldn't
reproduce such a bad performance. Sorting took ~40 ms. I think GLib uses
something that resembles merge sort.
 
> Please try to map the list onto an array, use qsort and convert it back to a
> list. Maybe we don't need that list anyway.

I tried this and was almost embarrassed to ever suggest this because it's
significantly slower as it takes about a second to sort. However, I replaced
qsort() with mergesort() and this resulted in ~9ms time for sorting. So
with mergesort() is actually faster despite all the overhead. I guess the
reason for this is that list is already almost sorted by timestamps in which
case mergesort() will be faster than qsort(). That's probably not uncommon
when you consider how files are stored and ordered. Though mergesort() isn't
a standard function, so we'd have to ship it with gtk-gnutella. As 
g_slist_sort()
looks sufficiently fast and we're not using it anywhere that's probably not
worth it.

Could you maybe try this yourself? sort_gslist_with_qsort() is in SVN, just
replace g_slist_sort() with it and see whether it's any faster or whether it's
even slower. It's possible that your files do not come in ordered which
could explain the difference. I'll try with random timestamps.

-- 
Christian

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Gtk-gnutella-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/gtk-gnutella-devel

Reply via email to