使用 NGEN 有帮助吗?

发布于 2024-07-10 07:15:25 字数 428 浏览 9 评论 0原文

当我们知道 ASP.NET 应用程序不会发生太大变化时,使用 NGEN 是否更好? 或者 JIT 是否足够好?

我问的唯一原因是因为 Jeffrey Richter 在 2002 年发表的这篇文章说:

当然,Microsoft 正在努力改进 CLR 及其 JIT 编译器,使其运行速度更快,生成更优化的结果 代码,并更有效地使用内存。 这些改进将需要 时间。 对于迫不及待的开发人员来说,.NET Framework Redistributable 包含一个名为 NGen.exe 的实用程序。

Is it better to use NGEN an ASP.NET application when we know it is not going to change much? Or is the JIT good enough?

The only reason I asked was because this article by Jeffrey Richter in 2002 says :

And, of course, Microsoft is working quite hard at improving the CLR
and its JIT compiler so that it runs faster, produces more optimized
code, and uses memory more efficiently. These improvements will take
time. For developers that can't wait, the .NET Framework
redistributable includes a utility called NGen.exe.

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

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

发布评论

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

评论(5

这样的小城市 2024-07-17 07:15:25

NGen 只会缩短启动时间 - 它不会使代码的执行速度比 JITting 后的速度快。 事实上,我相信有些优化是 NGen 不会做的,但 JIT 却做了。

所以,主要问题是:启动时间有问题吗? 我不知道 ASP.NET 应用程序的启动时间与其他成本相比有多少是 JIT 成本,顺便说一句...您可能应该查看 JIT 的性能管理器图表,以告诉您它真正花费了您多少时间。

(就可用性而言,拥有多个服务器以便您可以进行滚动重启,这比使用 NGENed Web 应用程序的单个服务器带来更多好处。)

NGen will only help startup time - it doesn't make the code execute any faster than it would after JITting. Indeed, I believe there are some optimizations which NGen doesn't do but the JIT does.

So, the main question is: do you have an issue with startup time? I don't know how much of an ASP.NET application's start-up time will be JITting vs other costs, btw... you should probably look at the Performance Manager graphs for the JIT to tell you how much time it's really costing you.

(In terms of availability, having multiple servers so you can do rolling restarts is going to give you much more benefit than a single server with an NGENed web app.)

我做我的改变 2024-07-17 07:15:25

NGen 不是 ASP.NET 的最佳选择——在 bin 文件夹中创建 .dll 并不是最后一步——它们会通过应用于 的 web/maching.config 设置再次进行编译C:\Windows\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files 文件夹。 要减少初始加载时间,请使用发布网站工具或 aspnet_compiler.exe,而不是 NGen

NGen isn't the way to go for ASP.NET -- the creation of the .dlls in the bin folder isn't the final step -- they are compiled again with the web/maching.config settings applied into your C:\Windows\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files folder. Instead of NGen, to decrease initial load-time, use the Publish Website Tool or aspnet_compiler.exe

暮凉 2024-07-17 07:15:25

我不确定 NGEN 的主要好处是否在于启动时间 - 如果应用程序的“% Time in JIT”很长,这被列为潜在的补救措施:
http://msdn.microsoft.com/en-us /library/dd264972(VS.100).aspx

该讨论与关于如何 JIT 的不同问题密切相关'd 机器代码被缓存并重新使用?

I'm not sure that NGEN's primary benefit is to start-up time alone - if the application's suffering from a high '% Time in JIT', this is listed as a potential remedy:
http://msdn.microsoft.com/en-us/library/dd264972(VS.100).aspx.

The discussion is closely related to a different question on how JIT'd machine code is cached and re-used?

风渺 2024-07-17 07:15:25

今晚我正在研究这个问题,发现了以下问题:

公共语言运行时无法将您使用 NGEN 创建的图像加载到共享应用程序域中。 由于 ASP.NET 标准程序集是共享的,然后会加载到共享应用程序域中,因此您无法使用 Ngen.exe 将它们安装到本地计算机上的本机图像缓存中。
http://support.microsoft.com/kb/331979

不确定这是否只是指从 ASP.net 应用程序或应用程序本身引用的程序集?

I was looking into this tonight and came across the following:

The common language runtime cannot load images that you create with NGEN into the shared application domain. Because ASP.NET standard assemblies are shared and are then loaded into a shared application domain, you cannot use Ngen.exe to install them into the native image cache on the local computer.
http://support.microsoft.com/kb/331979

Not sure if this just refers to assemblies referenced from ASP.net app or the app itself?

浮华 2024-07-17 07:15:25

NGen 有助于缩短启动时间。 例如,实体框架文档介绍了运行 NGen 的好处:

经验观察表明,EF 运行时程序集的本机映像可以将应用程序启动时间缩短 1 到 3 秒。

上下文只是实体框架程序集。 生成其他程序集将提供额外的加速。

NGen helps startup time. For example, the Entity Framework documentation says this about the benefit of running NGen:

Empirical observations show that native images of the EF runtime assemblies can cut between 1 and 3 seconds of application startup time.

The context is just the Entity Framework assemblies. NGenning other assemblies would provide additional speedup.

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