What are the things vbc.exe does when /optimize switch is used?
-
Tuesday, March 06, 2012 3:28 PM
vbc.exe has something called /optimize switch right. If I enable that what are the optimizations the compiler can do for me? The MSDN documentation just curtly says 'does various compiler optimizations'. Where can I find the complete quantified view of the different optimizations that actually goes into.
Here is the thing I am pursuing this route. One of the code blocks in a module I am leading has a lot of delimited array manipulations. I believe this is going to be a heck costly in terms of string memory handling. I am looking to see if I can retire them by way of simple properties or methods so that the compiler can internally do something like our c++ inline functions making a best win-win offer in terms of both memory and processing time. I admit when the compiler translates them as inline function, the JITed code might be big in size right?
All Replies
-
Tuesday, March 06, 2012 3:49 PM
Some general optimizations are...... Well, I don't elaborate on this because it's not specific to the JIT-compiler:
http://en.wikipedia.org/wiki/Compiler_optimization
For example, I made a performance test that contained the line
i += j
i += j
i += j
i += j
....
100 times. The compiler changed it to i += j * 100A little story:
I once wrote simple Bitmap processing code in VB.Net. It wasn't made for speed, so I've used GetPixel/SetPixel, which is the slowest version you can write. I've optimized the code by using Bitmap.LockBits/UnlockBits. The next version was written in C# with unsafe code blocks. Another version was written in unmanaged C++, and one more I wrote in pure assembler code. Surprisingly the optimized C# version was the quickest one, even faster than the optimized C++ version.
Armin
- Edited by Armin Zingler Tuesday, March 06, 2012 3:50 PM
- Marked As Answer by Mike FengMicrosoft Contingent Staff, Moderator Friday, March 16, 2012 3:05 AM
-
Tuesday, March 06, 2012 3:53 PM
@Armin,
That was really a brief but wonderful description about the proposed optimizations. Do these apply to vbc.exe as well?
-
Tuesday, March 06, 2012 4:03 PM
@Armin,
That was really a brief but wonderful description about the proposed optimizations. Do these apply to vbc.exe as well?
I don't know. Personally I don't care because I can't change it anyway. For debugging, they are disabled, otherwise enabled.
Anyway they are done by the JIT-compiler, not by Vbc.exe.
Here are some articles about it (but I can also only google like you can):
http://blogs.msdn.com/b/davidnotario/archive/2004/10/28/248953.aspx
http://blogs.msdn.com/b/davidnotario/archive/2004/11/01/250398.aspx
http://www.codeproject.com/Articles/25801/JIT-Optimizations
Armin
- Marked As Answer by Mike FengMicrosoft Contingent Staff, Moderator Friday, March 16, 2012 3:05 AM
-
Wednesday, March 07, 2012 8:35 AMModerator
Hi Deepak,
Welcome to the MSDN Forum.
Add to the others, please take a look at this blog: http://blogs.msdn.com/b/ericlippert/archive/2009/06/11/what-does-the-optimize-switch-do.aspx
Best regards,
Mike Feng
MSDN Community Support | Feedback to us
Please remember to mark the replies as answers if they help and unmark them if they provide no help.
- Marked As Answer by Mike FengMicrosoft Contingent Staff, Moderator Friday, March 16, 2012 3:05 AM
-
Wednesday, March 14, 2012 1:23 PMModerator
Hi Deepak,
We don't hear from you a couple of days.
Do you have any update?
How about your issue now?
Best regards,
Mike Feng
MSDN Community Support | Feedback to us
Please remember to mark the replies as answers if they help and unmark them if they provide no help.
-
Thursday, March 15, 2012 11:54 AM
Dear Mike,
Both Wiki and other MSDN blog URLs were informative.
Thanks and Regards,
Deepak
-
Thursday, March 15, 2012 7:18 PM
I didn't see in those interesting articles linked to in the other replies any direct mention of optimising Select Case statements, but the compiler can also use branch tables.
--
Andrew

