[Mono-devel-list] Patch for String.Equals

Andreas Nahr ClassDevelopment at A-SoftTech.com
Mon Apr 5 18:16:05 EDT 2004


Hi,

I haven't too much (any?) knowledge about any alignments and similar things.
However I can tell that on my platform (which is a Athlon x86 2GHz the long
compares are NOTABLY faster than int compares (And don't ask me why - I have
NO clue).

Here are some example timings from my microbenchmark for a string which
differs at char 90 (case to demonstrate loop speed):
Original (current mono): 29853ms
Suggested patch modified to use only int compares: 20089ms
Suggested patch modified to use only int compares (alternative
implementation): 20039ms
Suggested patch using long (on x86 32bit!): 15963ms

So even on x86 the long compare seems to be a LOT faster. On 64bit machines
the margin should probably get even bigger.
The question is if it will RUN on all plattforms (somebody suggested it
might not even work on other architectures).

----- Original Message ----- 
From: "Ben Maurer" <05mauben at hawken.edu>
To: <mono-devel-list at lists.ximian.com>; <malekith at pld-linux.org>
Sent: Monday, April 05, 2004 4:31 PM
Subject: Re: [Mono-devel-list] Patch for String.Equals


> oops, sorry it is sizeof (char)/sizeof (void*)
>
> The problem with long ops is that we cant optimize as much for them. The
> burg rules are simply not there. the benefit seen from this may actually
> be from unrolling the loop. It is possible that better performance (on
> the 32 bit) would be obtained by just doing two integer compares.
>
> I can take a look at the code we are generating later...
>
> >>> Michal Moskal <malekith at pld-linux.org> 04/05/04 10:27 AM >>>
> On Mon, Apr 05, 2004 at 07:43:07AM -0400, Ben Maurer wrote:
> > To optimize for both platforms, the native integer size should be
> used.
> > You can do this by casting the char* to a void**, and using
> > string.Length * sizeof (char*) / sizeof (void**).
>
> As far as I can tell sizeof(char*)==sizeof(void**), at least in C on all
> sane platforms. So the code above isn't very helpful.
>
> Anyway if the long compares doesn't hurt performance on x86, why avoid
> it?
>
> -- 
> : Michal Moskal :: http://www.kernel.pl/~malekith :: GCS !tv h e>+++ b++
> : When in doubt, use brute force. -- Ken Thompson :: UL++++$ C++ E--- a?
> _______________________________________________
> Mono-devel-list mailing list
> Mono-devel-list at lists.ximian.com
> http://lists.ximian.com/mailman/listinfo/mono-devel-list
>
> _______________________________________________
> Mono-devel-list mailing list
> Mono-devel-list at lists.ximian.com
> http://lists.ximian.com/mailman/listinfo/mono-devel-list
>




More information about the Mono-devel-list mailing list