Re: Why is C# 450% slower than C++ on nested loops ??

Tech-Archive recommends: Fix windows errors by optimizing your registry



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


.



Relevant Pages

  • Re: Why is C# 450% slower than C++ on nested loops ??
    ... >Sorry, above is not completely true, the C# IL may differ as I only compared ... >(only for the loop part), the results are quite different. ... exists because the two IL sequences are so different. ... just to set a different JIT flag. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Compiling in 32 vs 64 platform problem
    ... I use Intel Fortran compiler version 8.1. ... -|followed by linking of the different object files. ... -|go smoothly but the results obtained from the program differ from ... -|those that I get on 32 bit architecture machines. ...
    (comp.lang.fortran)
  • Re: tuples, index method, Pythons design
    ... Unless you want to introduce a character type into Python ... The properties of strings didn't force the developers to make those ... The same method could then eventually be used in other sequences ... properties where they differ from other sequences it no longer ...
    (comp.lang.python)
  • Re: What is Expressiveness in a Computer Language
    ... as much of the working fragments as I can, and I want a `safety net' to ... and staying where the compiler can prove I'll be ok. ... on the static/dynamic thing and see how the approaches differ. ...
    (comp.lang.functional)
  • Re: A (psossibly) fast, novel search table technique
    ... which e_i and e_j differ. ... the cost of function g is data dependent. ... instead compress the sequences and thus reduce the length of the ... they are a duplicate of any data item already present. ...
    (comp.programming)