When <compilation debug="true"> (ie in debug mode), You will see bunch .cs, .dll, .pdb files in "Temporary ASP.NET Files" directory, and when an exception occurs, it will display the exact line number in razor view that cause the exception.
When <compilation debug="false"> (ie in release mode), in webform view engine, and previous version of mvc, it only have .dll files in "Temporary ASP.NET Files" directory. When an exception occurs, it does not show the exact line nmber that cause the exception.
I'm using ASP.NET MVC 3 RC, so it seems like razor view engine is always compile the code in debug mode. It does not matter the debug="true" or debug="false", you will see the same .cs, .dll, .pdb files in "Temporary ASP.NET Files", and when exception occurs,
it will display the exact line number that cause the exception.
When I test this I saw that compiler is emiting /D:DEBUG /debug+ in Razor view when web.config's debug value is true or false). While webform view is emiting /D:DEBUG /debug+ when debug is true and emiting
/debug- when debug is false. When dig into source I found that
"And whoever is removed away from the Fire and admitted to Paradise, he indeed is successful." (The Holy Quran)
Excellent Windows VPS Hosting Imran Baloch MVP, MVB, MCP, MCTS, MCPD
You are correct that Razor pages get compiled in debug mode. This was done mostly for the WebMatrix scenarios, and should not have happened for MVC. However, it is probably tool late to change for MVC3, since it is essentially harmless. Were you two seeing
this as being an issue, or more as a curiosity?
We should log a bug on this on the MVC side of things. Are ther performance implications of compiling into debug every time?
Definately, compiling with /debug+ results in bigger code which will increase the memory size.
code with /debug+ is slower than release code.
Also with /debug+, C#, IL and JIT Native Code is not optimized(AFAIK).
Benefit of method inlining by JIT compiler(i.e many methods inline to one method)
"And whoever is removed away from the Fire and admitted to Paradise, he indeed is successful." (The Holy Quran)
Excellent Windows VPS Hosting Imran Baloch MVP, MVB, MCP, MCTS, MCPD
Imran, that is often generally true, but have you measured that with Razor compilation? I was told that we ran perf tests and showed no noticeable difference *in the case of Razor view compilation*
Phil Haack (http://haacked.com/)
Senior Program Manager, Microsoft
This clearly shows that Razor performance is less than the Aspx.
"And whoever is removed away from the Fire and admitted to Paradise, he indeed is successful." (The Holy Quran)
Excellent Windows VPS Hosting Imran Baloch MVP, MVB, MCP, MCTS, MCPD
None
0 Points
5 Posts
Razor compilation
Nov 19, 2010 05:04 PM|duganzhang|LINK
The new razor view engine in MVC seems to ignore the <compilation debug="false"> in web.config
Reglarless the flag, the compiled code is the same in the "Temporary ASP.NET Files" directory.
Contributor
2127 Points
607 Posts
Microsoft
Re: Razor compilation
Nov 19, 2010 06:28 PM|marcind|LINK
Could you clarify the incorrect behavior that you are seeing and describe what you expect the system to do instead?
ASP.NET Team
@marcind
Blog
None
0 Points
5 Posts
Re: Razor compilation
Nov 19, 2010 07:18 PM|duganzhang|LINK
When <compilation debug="true"> (ie in debug mode), You will see bunch .cs, .dll, .pdb files in "Temporary ASP.NET Files" directory, and when an exception occurs, it will display the exact line number in razor view that cause the exception.
When <compilation debug="false"> (ie in release mode), in webform view engine, and previous version of mvc, it only have .dll files in "Temporary ASP.NET Files" directory. When an exception occurs, it does not show the exact line nmber that cause the exception.
I'm using ASP.NET MVC 3 RC, so it seems like razor view engine is always compile the code in debug mode. It does not matter the debug="true" or debug="false", you will see the same .cs, .dll, .pdb files in "Temporary ASP.NET Files", and when exception occurs, it will display the exact line number that cause the exception.
All-Star
33963 Points
8480 Posts
MVP
Re: Razor compilation
Nov 20, 2010 01:50 AM|imran_ku07|LINK
When I test this I saw that compiler is emiting /D:DEBUG /debug+ in Razor view when web.config's debug value is true or false). While webform view is emiting /D:DEBUG /debug+ when debug is true and emiting /debug- when debug is false. When dig into source I found that
private WebPageRazorHost() {
.....................................................................
DefaultDebugCompilation = true;
}
public override CompilerType CodeCompilerType {
...............................................................................................
if (_isFullTrust != false && Host.DefaultDebugCompilation) {
try {
SetIncludeDebugInfoFlag(compilerType);
........................................................................
private static void SetIncludeDebugInfoFlag(CompilerType compilerType) {
compilerType.CompilerParameters.IncludeDebugInformation = true;
}
Is this behivour is optimised?
Excellent Windows VPS Hosting
Imran Baloch MVP, MVB, MCP, MCTS, MCPD
None
0 Points
5 Posts
Re: Razor compilation
Dec 11, 2010 06:21 PM|duganzhang|LINK
This behavior still exists in ASP.NET MVC 3 RC2.
Contributor
3384 Points
1367 Posts
Re: Razor compilation
Dec 12, 2010 03:57 PM|davidebb|LINK
You are correct that Razor pages get compiled in debug mode. This was done mostly for the WebMatrix scenarios, and should not have happened for MVC. However, it is probably tool late to change for MVC3, since it is essentially harmless. Were you two seeing this as being an issue, or more as a curiosity?
Participant
808 Points
408 Posts
Re: Razor compilation
Mar 08, 2011 11:01 PM|Haacked|LINK
We should log a bug on this on the MVC side of things. Are ther performance implications of compiling into debug every time?
Senior Program Manager, Microsoft
What wouldn’t you do for a Klondike bar?
All-Star
33963 Points
8480 Posts
MVP
Re: Razor compilation
Mar 10, 2011 12:05 AM|imran_ku07|LINK
Definately, compiling with /debug+ results in bigger code which will increase the memory size.
code with /debug+ is slower than release code.
Also with /debug+, C#, IL and JIT Native Code is not optimized(AFAIK).
Benefit of method inlining by JIT compiler(i.e many methods inline to one method)
Excellent Windows VPS Hosting
Imran Baloch MVP, MVB, MCP, MCTS, MCPD
Participant
808 Points
408 Posts
Re: Razor compilation
Mar 10, 2011 12:09 PM|Haacked|LINK
Senior Program Manager, Microsoft
What wouldn’t you do for a Klondike bar?
All-Star
33963 Points
8480 Posts
MVP
Re: Razor compilation
Mar 10, 2011 12:47 PM|imran_ku07|LINK
I don't test my self but Marcin done a sample stress test at here,
http://blogs.msdn.com/b/marcinon/archive/2011/01/17/mvc-3-performance.aspx
This clearly shows that Razor performance is less than the Aspx.
Excellent Windows VPS Hosting
Imran Baloch MVP, MVB, MCP, MCTS, MCPD
None
0 Points
5 Posts
Re: Razor compilation
Jun 20, 2011 01:51 PM|GoranG|LINK
Hi,
Yes I have an issue with this, the first and major one being this is highly unexpected and inconsistent.
The practical issue being :
I have code like this to select the right jquery library during development and production
In webforms it works in Razor not.
Very unexpected and depending on what you put between #if #endif this could be very painfull.
Definitaly a bug.