9

I know that setting COMPLUS_ZapDisable=1 will "disable debugging optimizations in Visual Studio," but I can't seem to find any references that tell me what that actually means.

  • What features/functionality are actually disabled by this setting?
  • What are the ramifications of always using this setting?
  • If the cost is that "[debugging] runs a bit slower," can we try to elaborate a bit? Is the difference significant? Does that difference scale with project size? Is it unbearable on larger projects? Etc.
    • I know this one is a bit more vague, but explanation is really what I'm after
  • Is there an actual known reason why this isn't set by default?
    • While opinions are welcomed, I'm really wondering about if there is a factual, known issue that disabling this setting by default addresses
johnnyRose
  • 7,310
  • 17
  • 40
  • 61
Zachary Kniebel
  • 4,686
  • 3
  • 29
  • 53
  • 2
    Did you see this? http://blogs.msdn.com/b/sburke/archive/2008/01/29/how-to-disable-optimizations-when-debugging-reference-source.aspx Zap appears to be the code name for NGEN. – usr Feb 18 '16 at 16:21
  • @usr - I did read that article, but I missed the part where it said Zap was the code name for NGEN. Now that I re-read it, I see that it was somewhat implicit. I will try to research a little more from that angle. Thanks for clarifying that! – Zachary Kniebel Feb 18 '16 at 16:25
  • 2
    Single-stepping through .NET framework source code is pretty painful, it is optimized code and that prevents inspecting local variables and makes the execution order of the statements rather random. Sure, you'll make your program slower when you do this. Doesn't matter much, your own code is slower as well so you can generally only effectively debug with small data sets. A default makes no sense, you always want framework code to run as fast as possible. Only do this when you have to. – Hans Passant Feb 18 '16 at 16:27
  • Thanks, @HansPassant. That clears things up a lot. – Zachary Kniebel Feb 18 '16 at 16:30

2 Answers2

10

Setting the environment variable COMPlus_ZapDisable=1 disables the use of all NGEN images (*.ni.dll). It can also be set in the registry, but that is not recommended as it would affect all .NET applications. You would normally only use this when debugging the application to get better call stacks. For better performance you can disable the use of NGEN images for only some assemblies with the environment variable COMPlus_DisableNativeImageLoadList (64bit only and needs .NET 4.6+).

For an extensive description see: https://github.com/Microsoft/dotnet/blob/master/Documentation/testing-with-ryujit.md

(In the current CoreCLR it seems DisableNativeImageLoadList has been removed.)

riQQ
  • 9,878
  • 7
  • 49
  • 66
WebDancer
  • 333
  • 3
  • 8
4

This environment variable disables optimizations in the JITter.

The JITter automatically disables optimizations for debug builds, so this is only relevant if you want to debug through a non-debug build (eg, framework assemblies).

SLaks
  • 868,454
  • 176
  • 1,908
  • 1,964