If a .pdb (program debug) file is included with a .dll then line numbers appear in the stack trace of any exception thrown. Does this affect the performance of the application?
如果.dll中包含.pdb(程序调试)文件,则会在抛出的任何异常的堆栈跟踪中显示行号。这会影响应用程序的性能吗?
This question is not about release vs. debug, i.e. optimisations. It is about the performance implications of having .pdb files. Are the .pdb files read every time an exception is thrown? Is the information cached in some way when the assemblies are loaded? Or is it cached the first time a relevant exception is thrown? How much difference does it make?
这个问题不是关于发布与调试,即优化。它是关于拥有.pdb文件的性能影响。每次抛出异常时都会读取.pdb文件吗?加载程序集时,信息是否以某种方式缓存?或者它是在第一次抛出相关异常时缓存的?它有多大区别?
2 个解决方案
#1
14
John Robbins wrote about this in his article Do PDB Files Affect Performance?. The simple answer is no (if you compile your release build with both the /optimize+ and /debug switches):
John Robbins在他的文章“PDB文件是否会影响性能?”中写到这一点。简单的答案是否定的(如果使用/ optimize +和/ debug开关编译发布版本):
That might be true on other operating systems, but not Windows. If you think they do, then why does Microsoft build every single product they ship with PDB files turned on for both debug and release builds? They wrote the compiler, they wrote the linker, and they wrote the operating system so they know exactly what the effects are. Microsoft has more people focused on performance than any other software company in the world. If there were any performance impact at all, they wouldn't do it. Period. Performance isn't the only thing at Microsoft, it's everything.
在其他操作系统上可能也是如此,但Windows不是这样。如果你认为他们这样做了,那么为什么微软会为他们提供的每个产品构建PDB文件以进行调试和发布版本?他们编写了编译器,编写了链接器,然后编写了操作系统,以便确切了解效果。与世界上任何其他软件公司相比,微软更关注性能。如果有任何性能影响,他们就不会这样做。期。性能不是微软的唯一功能,它就是一切。
Additionally:
When built /optimize+ and a /debug switch, a DebuggingMode.IgnoreSequencePoints is passed to the DebuggableAttribute to tell the JIT compiler that it doesn't need to load the PDB file in order to correctly JIT the IL.
当构建/ optimize +和/ debug开关时,DebuggingMode.IgnoreSequencePoints被传递给DebuggableAttribute以告诉JIT编译器它不需要加载PDB文件以便正确地JIT IL。
He also has another article entitled PDB Files: What Every Developer Must Know that is also a good read.
他还有另一篇题为PDB文件的文章:每个开发者必须知道的内容也是一本很好的读物。
#2
6
Not normally. PDBs and optimizations are orthogonal. One can be enabled regardless of the value of the other option. However, it might reduce performance if you want to actually use the information contained in PDB, like when you are accessing the StackTrace
of an exception and it needs to get line numbers from PDB or when you call new StackTrace(true)
.
不正常。 PDB和优化是正交的。无论其他选项的值如何,都可以启用一个。但是,如果要实际使用PDB中包含的信息,可能会降低性能,例如当您访问异常的StackTrace并且需要从PDB获取行号或者调用新的StackTrace时(true)。
By the way, Eric Lippert has a related blog entry about compiler optimizations.
顺便说一句,Eric Lippert有一篇关于编译器优化的相关博客文章。
#1
14
John Robbins wrote about this in his article Do PDB Files Affect Performance?. The simple answer is no (if you compile your release build with both the /optimize+ and /debug switches):
John Robbins在他的文章“PDB文件是否会影响性能?”中写到这一点。简单的答案是否定的(如果使用/ optimize +和/ debug开关编译发布版本):
That might be true on other operating systems, but not Windows. If you think they do, then why does Microsoft build every single product they ship with PDB files turned on for both debug and release builds? They wrote the compiler, they wrote the linker, and they wrote the operating system so they know exactly what the effects are. Microsoft has more people focused on performance than any other software company in the world. If there were any performance impact at all, they wouldn't do it. Period. Performance isn't the only thing at Microsoft, it's everything.
在其他操作系统上可能也是如此,但Windows不是这样。如果你认为他们这样做了,那么为什么微软会为他们提供的每个产品构建PDB文件以进行调试和发布版本?他们编写了编译器,编写了链接器,然后编写了操作系统,以便确切了解效果。与世界上任何其他软件公司相比,微软更关注性能。如果有任何性能影响,他们就不会这样做。期。性能不是微软的唯一功能,它就是一切。
Additionally:
When built /optimize+ and a /debug switch, a DebuggingMode.IgnoreSequencePoints is passed to the DebuggableAttribute to tell the JIT compiler that it doesn't need to load the PDB file in order to correctly JIT the IL.
当构建/ optimize +和/ debug开关时,DebuggingMode.IgnoreSequencePoints被传递给DebuggableAttribute以告诉JIT编译器它不需要加载PDB文件以便正确地JIT IL。
He also has another article entitled PDB Files: What Every Developer Must Know that is also a good read.
他还有另一篇题为PDB文件的文章:每个开发者必须知道的内容也是一本很好的读物。
#2
6
Not normally. PDBs and optimizations are orthogonal. One can be enabled regardless of the value of the other option. However, it might reduce performance if you want to actually use the information contained in PDB, like when you are accessing the StackTrace
of an exception and it needs to get line numbers from PDB or when you call new StackTrace(true)
.
不正常。 PDB和优化是正交的。无论其他选项的值如何,都可以启用一个。但是,如果要实际使用PDB中包含的信息,可能会降低性能,例如当您访问异常的StackTrace并且需要从PDB获取行号或者调用新的StackTrace时(true)。
By the way, Eric Lippert has a related blog entry about compiler optimizations.
顺便说一句,Eric Lippert有一篇关于编译器优化的相关博客文章。