Something for the C#/JIT wishlist.

O

Olaf Baeyens

Something for the C#/JIT wishlist.

I am looking at the generated IL Assembler code and the generated real x86
code and I am facinated about the quality of the generated code. It comes to
near c++ generated code without optimizing. The same type of code that you
would have if you use the VC 2003 C++ standard edition, that has no code
optimizer.

I do understand that optimizing this code in the JIT would be possible but
would also slow down the loading iof the program, so a balance must be
chosen that has the right amount of optimizing and the right amount of
loading time.

Now, I propose to add one new keyword to C# that could tell that this
particular method might be optimized much further even though it takes more
time to load. This would be nice, since not all methods must me optimized,
but only a few of them.

In my case I am using OpenGl to render a scene using C#, since OpenGl is
doing the rendering stuff, it does not matter that the code is a little
slower. But one part must convert a bitmap to a texture using the unsafe
keyword. This is just a small loop swapping bytes and adding a alpha
channel, and this part could be optimized further by a JIT in my opinion.
 
D

Daniel O'Connell [C# MVP]

Olaf Baeyens said:
Something for the C#/JIT wishlist.

I am looking at the generated IL Assembler code and the generated real x86
code and I am facinated about the quality of the generated code. It comes
to
near c++ generated code without optimizing. The same type of code that you
would have if you use the VC 2003 C++ standard edition, that has no code
optimizer.

I do understand that optimizing this code in the JIT would be possible but
would also slow down the loading iof the program, so a balance must be
chosen that has the right amount of optimizing and the right amount of
loading time.

Now, I propose to add one new keyword to C# that could tell that this
particular method might be optimized much further even though it takes
more
time to load. This would be nice, since not all methods must me optimized,
but only a few of them.

This is an interesting idea, providing the JIT with suggestions about which
methods need the most attention, maybe even offering a set of levels to
specify if the method should always be optimized or if it should just be
given extra attention if possible or even that it should be JIT'd in the
background at full optimization, basically telling the JIT you aren't going
to be calling it for a little while. Of course that is predicated on the JIT
not boosting in capacity further before anyone ever gets around to this, ;).

However, I'd not use a keyword oas this wouldn't be an actual language
feature. This is a situation where you use attributes.

Even an API call would be nice, something like
JIT.PrepMethod(MethodInfo,OptimizationLevel) (assuming retrieving a
MethodInfo doesn't cause JIT compilation, I don't think so, but I can't
recall off hand).
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top