[Mono-list] Speed difference Windows - Linux

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


I've filed a bug report for this:
https://bugzilla.novell.com/show_bug.cgi?id=351638

- Juraj

On Fri, 2008-01-04 at 16:10 +0100, Juraj Skripsky wrote:
> 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




More information about the Mono-list mailing list