Re: Why is C# 450% slower than C++ on nested loops ??
- From: "Peter Olcott" <olcott@xxxxxxx>
- Date: Fri, 30 Dec 2005 10:40:02 -0600
Here is an interesting article on the optimizations of the new 2005 compiler.
http://msdn.microsoft.com/msdnmag/issues/04/05/VisualC2005/
"Christoph Nahr" <christoph.nahr@xxxxxxxxxxxxx> wrote in message
news:vdo9r1dnpqt7rmfsr939d2411jhs0md8v8@xxxxxxxxxx
> On Thu, 29 Dec 2005 22:31:53 +0100, "Willy Denoyette [MVP]"
> <willy.denoyette@xxxxxxxxxx> wrote:
>
>>Sorry, above is not completely true, the C# IL may differ as I only compared
>>the IL of both: C++ /clr and C++ /clr:safe, and despite they are identical
>>(only for the loop part), the results are quite different (100%).
>>That means that even with identical IL the perf. level may differ, and
>>different IL may produce equal results. The secret (especially in this
>>case!) lays in the metadata which 'tells' the JIT that one is verifiable
>>code while the other is not, so it's allowed to generate different machine
>>code for the same IL.
>
> That's an interesting idea but it must be something else (see below).
>
> The unsafe method modifier allows the C# compiler to generate
> unverifiable code, too, but a quick test showed absolutely no
> difference between two benchmark runs -- one unchanged, one with the
> "unsafe" modifier on the nested loop test. So apparently the machine
> code generated for either flag is identical.
>
>>Marcus code posted in this thread is wrong,he changed:
>>
>> x+=a+b+c+d+e+f;
>>into:
>> x++;
>>, please re-read his post and the follow-up,
>
> Right, I saw his post now.
>
>>PS. find the IL for both in attachment.
>
> You've lost me again. I've compared both IL sequences, and they are
> quite different! The unverifiable version has a different calling
> convention, a smaller local stack, calls to C++ library methods, and
> overall a smaller IL instruction count.
>
> My diff program can't find the identical loop part that you claim
> exists because the two IL sequences are so different. Evidently the
> /clr:safe switch causes the C++ compiler to generate different IL, not
> just to set a different JIT flag.
> --
> http://www.kynosarges.de
.
- References:
- Why is C# 450% slower than C++ on nested loops ??
- From: Peter Olcott
- Re: Why is C# 450% slower than C++ on nested loops ??
- From: Willy Denoyette [MVP]
- Re: Why is C# 450% slower than C++ on nested loops ??
- From: Christoph Nahr
- Re: Why is C# 450% slower than C++ on nested loops ??
- From: Willy Denoyette [MVP]
- Re: Why is C# 450% slower than C++ on nested loops ??
- From: Christoph Nahr
- Re: Why is C# 450% slower than C++ on nested loops ??
- From: Willy Denoyette [MVP]
- Re: Why is C# 450% slower than C++ on nested loops ??
- From: Christoph Nahr
- Why is C# 450% slower than C++ on nested loops ??
- Prev by Date: Re: Embedded SQL in C#
- Next by Date: Re: Is there LabelArray (VB6) in C#?
- Previous by thread: Re: Why is C# 450% slower than C++ on nested loops ??
- Next by thread: Re: Why is C# 450% slower than C++ on nested loops ??
- Index(es):
Relevant Pages
|