简体   繁体   English

.NET JIT在可共享页面中的程序集

[英].NET JIT'ed assemblies in sharable pages

When running a .NET 2.0 WinForms app in a Terminal Services environment, I'm seeing some unexpected results that I can't quite explain. 在终端服务环境中运行.NET 2.0 WinForms应用程序时,我看到一些我无法解释的意外结果。 Everything I have read has indicated that JIT'ed assemblies (ie, not using NGen to create native images) result in all code space being stored in private pages, increasing working set size / memory pressure. 我读过的所有内容都表明JIT组装(即不使用NGen创建本机图像)会导致所有代码空间都存储在私有页面中,从而增加了工作集大小/内存压力。 However, actual results (verified using Process Explorer, VMMap, and WinDbg) show that even the JIT'ed assemblies are indeed being placed in shareable pages (and are indeed being shared when there are multiple instances of the app running, even under separate TS sessions/users). 但是,实际结果(使用Process Explorer,VMMap和WinDbg进行验证)表明,即使是JIT的程序集也确实被放置在可共享的页面中(并且在应用程序的多个实例运行时确实正在共享,即使在单独的TS下也是如此会话/用户)。

Can anyone explain why this might be? 任何人都可以解释为什么会这样吗? This is running in a W2K8 Server environment, so ASLR explains why a lack of specific base addresses for each assembly & the resulting rebasing isn't causing problems. 这是在W2K8服务器环境中运行的,因此ASLR解释了为什么缺少每个程序集的特定基址以及由此产生的变基不会导致问题。 Still, it seems the fact these aren't native PE images should result in the code for those assemblies being stored in private pages. 但是,似乎这些不是本机PE映像的事实应该导致这些程序集的代码存储在私有页面中。

This was discovered when we started investigating using NGen to cut down on memory pressure, but actually found it increased working set size - since the JIT'ed assemblies were already being shared. 这是在我们开始调查使用NGen来减少内存压力时发现的,但实际上发现它增加了工作集大小 - 因为JIT组装已经被共享了。

The most recent reference I've found is here, which again differs from our actual findings: 我发现的最新参考文献在这里,它与我们的实际发现有所不同:

http://blogs.msdn.com/morgan/archive/2009/03/07/developing-net-applications-for-deployment-on-terminal-services-or-citrix.aspx http://blogs.msdn.com/morgan/archive/2009/03/07/developing-net-applications-for-deployment-on-terminal-services-or-citrix.aspx

Edit: I should add that since first posting the question, more experiments on Windows Server 2003 test boxes are also apparently showing the JIT'ed assemblies being sharable between processes. 编辑:我应该补充一点,因为首次发布问题,Windows Server 2003测试框上的更多实验也显示JIT的程序集在进程之间可共享。 I'm still stumped as to why all advice I can find indicates NGen is required, but all the real-world evidence contradicts that. 我仍然难以理解为什么我能找到的所有建议都表明NGen是必需的,但所有现实世界的证据都与此相矛盾。 I'm really hoping the experts here can shed some light. 我真的希望这里的专家可以解释一下。

Thanks! 谢谢!

Edit: I've dusted off all my .NET / CLR books and am running out of ideas for search queries to try to solve this one; 编辑:我已经把我所有的.NET / CLR书都掉了下来,而且我的搜索查询已经用完了,试图解决这个问题。 who's going to make my day by helping eliminate that awful nagging feeling of "I don't understand what's going on"!?! 谁将通过帮助消除“我不明白发生了什么”这种可怕的唠叨感来结束我的一天!?! :) :)

I think you are looking directly at module pages. 我想你正在直接看模块页面。 When you JIT code, it won't show up under your DLL - it shows up in memory the runtime allocates. 当您使用JIT代码时,它不会显示在您的DLL下 - 它会显示在运行时分配的内存中。 The module pages you are looking at are mostly metadata and IL, which is why they are still sharable. 您正在查看的模块页面主要是元数据和IL,这就是它们仍然可共享的原因。

As an experiment, I wrote a small program that generates 30K static methods and calls them. 作为一个实验,我写了一个小程序,它生成30K静态方法并调用它们。 On my system, the JIT version of this program has 8.2 MB of private comitted memory, while the NGEN version has 3.8. 在我的系统上,这个程序的JIT版本有8.2 MB的私有内存,而NGEN版本有3.8。

Even within your module pages, however, NGEN does help with memory use. 但是,即使在模块页面中,NGEN也会帮助使用内存。 When the runtime is able to load an NGEN image, it doesn't have to read the metadata of your module in order to JIT the code. 当运行时能够加载NGEN映像时,它不必读取模块的元数据以便JIT代码。 The JIT version of my test application is using 2.3MB of working set. 我的测试应用程序的JIT版本使用2.3MB的工作集。 The NGEN version is using 32 kilobytes. NGEN版本使用32千字节。

NGEN should also help your startup time. NGEN也应该帮助你的启动时间。 Impact to warm startup time can be negligable, but the impact to cold startup time (saving reading all those pages off the disk) can be noticable. 对热启动时间的影响可以忽略不计,但是对冷启动时间的影响(保存从磁盘读取所有这些页面)可能是显而易见的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM