[Mono-list] Speed difference Windows - Linux

Juraj Skripsky js at hotfeet.ch
Fri Jan 4 10:10:02 EST 2008


I've found one potential problem in Array.Sort<T> (called by
List<T>.Sort) that could account for quite some slowdown.

All of the following "Sort<T>" method overloads call a "Sort<TKey,
TValue>" overload with null as the values/items array to get their work
done:

public static void Sort<T> (T [] array)
public static void Sort<T> (T [] array, IComparer<T> comparer)
public static void Sort<T> (T [] array, int index, int length)
public static void Sort<T> (T [] array, int index, int length,
IComparer<T> comparer)

This is suboptimal as those methods in turn use the swap<K, V> method
which needs to check (and then ignore) the values/items array.

So we're push popping a lot of unnecessary nulls on and off the stack
and checking them. And as swap<T> is a lot smaller than swap<K, V> its
chances for being inlined by the JIT compiler are much higher.

- Juraj


On Fri, 2008-01-04 at 13:07 +0000, Alan McGovern wrote:
> He sent it attached to his last email, but it's about 4MB so it may
> get bounced from some email services. For lack of a better place to
> put it, i uploaded to megaupload:
> 
> http://www.megaupload.com/?d=D5NFRPEB
> 
> Hope that helps,
> Alan.
> 
> On Jan 4, 2008 12:44 PM, Juraj Skripsky <js at hotfeet.ch> wrote:
>         Hi Ventsislav,
>         
>         Could you post the source of your test case to the mailing
>         list
>         (assuming it's just a few KBs)?
>         
>         - Juraj
>         
>         
>         _______________________________________________ 
>         Mono-list maillist  -  Mono-list at lists.ximian.com
>         http://lists.ximian.com/mailman/listinfo/mono-list
>         
> 
> _______________________________________________
> Mono-list maillist  -  Mono-list at lists.ximian.com
> http://lists.ximian.com/mailman/listinfo/mono-list



More information about the Mono-list mailing list