如何防止 NGEN 对我的代码进行变基(对性能产生负面影响)?

发布于 2024-09-16 06:02:03 字数 546 浏览 9 评论 0原文

我只是想加快我的基于 .NET 的客户端应用程序的速度,并且正在考虑对代码进行 NGEN 处理。

Jeffery Richter 写了这个关于生成代码的警告:

•加载时间性能较差 (变基)。当 Windows 加载 NGend 文件,它检查是否 文件在其首选基地加载 地址。如果文件无法加载 首选基地址,然后是 Windows 重新定位文件,修复所有 内存地址引用。这是 非常耗时,因为 Windows 必须将整个文件加载到 内存并修改其中的各个字节 文件。欲了解更多信息 变基请参阅我的书: 为 Microsoft 编写应用程序 Windows,第四版(微软 按)。

由于我对此主题了解不多,因此在开始更改项目中的设置之前我应该​​了解什么,以及应该更改哪些设置?

I simply want to speed up my .NET-base client side app and am considering NGEN-ing the code.

Jeffery Richter wrote this warning about ngening code:

•Inferior Load-Time Performance
(Rebasing). When Windows loads an
NGend file, it checks to see if the
file loads at its preferred base
address. If the file cant load at its
preferred base address, then Windows
relocates the file, fixing-up all of
the memory address references. This is
extremely time consuming because
Windows must load the entire file into
memory and modify various bytes within
the file. For more information about
rebasing please see my book:
Programming Applications for Microsoft
Windows, 4th Edition (Microsoft
Press).

Since I don't know much about this topic, what should I know before I start changing settings within my project, and what settings should I change?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

够运 2024-09-23 06:02:03

根据 此 Microsoft 博客,“在 Vista+ 操作系统中设置基址可能会带来一些好处,但这些情况在很大程度上可以忽略不计。”因此,虽然使用 ngen 确实可以缩短启动时间,但不再需要设置基址,除非您支持 Vista 之前的操作系统。这是新的地址空间布局随机化安全功能的副作用。

According to this Microsoft blog, "There may be some marginal cases where setting base addresses in Vista+ OSes has a benefit, but these can be largely ignored." So, while using ngen does improve startup times, it is no longer necessary to set the base addresses unless you support pre-Vista OSes. This is a side-effect of the new Address Space Layout Randomization security feature.

春风十里 2024-09-23 06:02:03

DLL 的重定位仅在加载时发生,加载后,重定位过程不会进一步影响性能。当然,根据 DLL 的数量和大小(重定位的数量),加载时间可能会受到显着影响,这是一个问题,因为您的应用程序经常启动和停止。

重新调整 DLL 以缩短加载时间需要持续的监视和调整,如果在 DLL 加载位置之间没有留出足够的空间,那么随着 DLL 的增长或新的 DLL 添加到项目中,最终会发生冲突。

这是一篇 MSDN 文章,讨论了改进应用程序启动时间的方法。
http://msdn.microsoft.com/en-us/magazine/cc163655。 ASPX

The relocating of your DLLs only occurs at load time, once loaded there are no further performance hits due to the relocation process. Of course depending on the number and size of the DLLs (the number of relocations) the load time can be significantly impacted, which is a problem is your application is frequently started and stopped.

Rebasing DLLs to improve load times requires continous monitoring and tuning, if you have not left enough head room between DLL load locations you end up with collisions as the DLLs grow or new DLLs get added to the project.

Here is an MSDN article discussion ways to improve application startup time.
http://msdn.microsoft.com/en-us/magazine/cc163655.aspx

傻比既视感 2024-09-23 06:02:03

NGEN 允许您指定基地址(也在 VS 设置中公开)。如果您打算使用 NGEN,您基本上需要确保 DLL 之间没有任何重叠。如果存在重叠,那么 CLR 将在加载它们时强制对它们进行变基。

NGEN allows you to specify a base address (also exposed in VS settings). If you're going to NGEN, you basically want to ensure you don't have any overlap between DLLs. If you have overlap, then the CLR will be forced to rebase them when they're loaded.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文