哪里是.NET JIT编译code缓存? [英] Where is the .NET JIT-compiled code cached?

查看:219
本文介绍了哪里是.NET JIT编译code缓存?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

一个.NET程序首先被编译成MSIL code。当它被执行时,JIT编译器将其编译为本地机器code。

A .NET program is first compiled into MSIL code. When it is executed, the JIT compiler will compile it into native machine code.

我想知道:

在哪里这些JIT编译机code存储?是它仅存储在进程的地址空间?但由于该计划的第二个启动比第一次更快,我觉得这个本土code必须被存储在磁盘上的某个地方,即使执行完毕。但是,在哪里?

Where is these JIT-compiled machine code stored? Is it only stored in address space of the process? But since the second startup of the program is much faster than the first time, I think this native code must have been stored on disk somewhere even after the execution has finished. But where?

推荐答案

内存。它的可以的缓存,这是ngen.exe的工作。它生成组件的.ni.dll版本,包含机器code和存储在GAC。它会自动被加载后,绕过JIT的一步。

Memory. It can be cached, that's the job of ngen.exe. It generates a .ni.dll version of the assembly, containing machine code and stored in the GAC. Which automatically gets loaded afterward, bypassing the JIT step.

但是,这并没有多大关系,为什么你的程序启动更快的第二次。在第一时间,你有一个所谓的冷启动。这是完全由花在查找DLL文件在硬盘上的时间占主导地位。你已经有了一个温暖的开始第二次,将DLL已经在文件系统缓存中可用。

But that has little to do with why your program starts faster the 2nd time. The 1st time you have a so-called "cold start". Which is completely dominated by the time spent on finding the DLLs on the hard drive. The second time you've got a warm start, the DLLs are already available in the file system cache.

磁盘是缓慢的。固态硬盘是一个明显的修复。

Disks are slow. An SSD is an obvious fix.

FWIW:这不是一个问题,这就是独家管理code。有大量的DLL大非托管程序有它。两个典型的例子,在大多数开发机器present是Microsoft Office和Acrobat Reader软件。他们作弊。安装的时候,他们把一个优化,在运行注册表项或启动文件夹中。所有这些优化做的是加载所有的主要程序使用,然后退出的DLL文件。这个素数文件系统缓存中,当用户随后使用该程序时,它会快速启动,因为它的热启动速度快。

Fwiw: this is not a problem that's exclusive to managed code. Large unmanaged programs with lots of DLLs have it too. Two canonical examples, present on most dev machines are Microsoft Office and Acrobat Reader. They cheat. When installed, they put an "optimizer" in the Run registry key or the Startup folder. All that these optimizers do is load all the DLLs that the main program uses, then exit. This primes the file system cache, when the user subsequently uses the program, it will start up quickly since its warm start is fast.

就个人而言,我觉得这是非常恼人。因为他们的真正的做的是慢下来,我可能要开始登录后的任何其他程序。这是很少的Office或Adobe Acrobat。我使它成为一个点,如果需要删除这些优化,多次当炸开更新放回去。

Personally, I find this extraordinarily annoying. Because what they really do is slow down any other program that I may want to start after logging in. Which is rarely Office or Acrobat. I make it a point to delete these optimizers, repeatedly if necessary when a blasted update puts it back.

您可以使用这一招过,但用它负责吧。

You can use this trick too, but use it responsibly please.

这篇关于哪里是.NET JIT编译code缓存?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆