473,326 Members | 2,061 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

C# Compiler Optimization Info, e.g., White Paper

Where can one find a discussion of the current and future optimizations that the C# compilers do? When I see things like the following I question my faith in csc being good at optimizing. The same kind of thing shows up in cordbg when looking at the JIT code for a similar example

% cat y.c

using System

class A
bool On { get { return true; }
public void Print()
if (On)
Console.WriteLine("On")


class ConditionalTest
static void Main(

A a = new A()
a.Print()

% csc /optimize+ y.c

Microsoft (R) Visual C# .NET Compiler version 7.10.3052.
for Microsoft (R) .NET Framework version 1.1.432
Copyright (C) Microsoft Corporation 2001-2002. All rights reserved

% ildasm y.ex

..method public hidebysig instance void Print() cil manage

// Code size 19 (0x13
..maxstack
IL_0000: ldarg.
IL_0001: call instance bool A::get_On(
IL_0006: brfalse.s IL_001
IL_0008: ldstr "On
IL_000d: call void [mscorlib]System.Console::WriteLine(string
IL_0012: re
} // end of method A::Prin

At least the compiler eliminates the "if" test when "On" is replaced with "true" in the test

Jul 21 '05 #1
3 1687
Andrew,
Where can one find a discussion of the current and future optimizations that the C# compilers do?


http://msdn.microsoft.com/vcsharp/te...aspx#optimizer

The short answer is that it doesn't do much. Most optimizations are
left to the JIT compiler.

Mattias

--
Mattias Sjögren [MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.
Jul 21 '05 #2
Thanks. I'd seen that link before; it doesn't look very authoritative and it certainly doesn't provide much insight for current or future plans with the optimizer. It just lists a few optimizations without comment

As I said, the JIT compiler didn't seem to be doing so well either, at least for a very similar example that I looked at. That is why I am looking for information about what is actually done, and what's planned in the future. Without this information I have no reason to think that much of anything is being optimized, and some reason to think that it's not.
Jul 21 '05 #3
I'd seen that link before; it doesn't look very authoritative
It's a FAQ on Microsoft's developer website, written by C# team
members. In what way could it be any more authoritative?

and it certainly doesn't provide much insight for current or future plans with the optimizer. It just lists a few optimizations without comment.
What kind of comments are you looking for? There isn't much to say
about the current optimizations because there simply are so few of
them.

I don't know what the plans for the future are. You may have to wait
for a public beta to find out.

As I said, the JIT compiler didn't seem to be doing so well either, at least for a very similar example that I looked at.


How did you check that. Many people that don't use the debugger
correctly end up looking at unoptimized debug code and make incorrect
conclusions about the JIT abilities.

If you want more details on JIT optimizations, I suggest you visit the
group microsoft.public.dotnet.framework.performance. There are also
some good articles on this up on MSDN.

Mattias

--
Mattias Sjögren [MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.
Jul 21 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: VM | last post by:
Hello, I'm looking for information on C# compiler optimization or compilation for an engineering short paper I want to write. Any sites with some technical info on the new advances of C#...
5
by: Hari | last post by:
Guys please help me to solve this strange problem what Iam getting as follows.. Trying to instantiate a global instance of a template class as follows :- when i build this code with debug and...
3
by: Andrew | last post by:
Where can one find a discussion of the current and future optimizations that the C# compilers do? When I see things like the following I question my faith in csc being good at optimizing. The same...
5
by: wkaras | last post by:
I've compiled this code: const int x0 = 10; const int x1 = 20; const int x2 = 30; int x = { x2, x0, x1 }; struct Y {
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.