.NET程序集缓存/ NGEN / JIT图像的热身和冷却行为缓存、图像、行为、程序

2023-09-03 23:25:52 作者:不及你温暖话语

我已经与C#.net 2.0 DLL通过C ++ / CLI的输入法(IME)的程序。由于一个IME总是连接到另一个应用程序时,C#.NET的DLL似乎无法避免图像地址垫底。

I have an Input Method (IME) program built with C#.NET 2.0 DLL through C++/CLI. Since an IME is always attaching to another application, the C#.NET DLL seems not able to avoid image address rebasing.

虽然我已经申请NGEN创建C#.net 2.0 DLL的本机映像,并安装它变成全局程序集缓存,它并没有多大改善,约12秒。到9秒。在一个缓慢的PIII级PC。

Although I have applied ngen to create a native image of that C#.NET 2.0 DLL and installed it into Global Assembly Cache, it didn't improved much, approximately 12 sec. down to 9 sec. on a slow PIII level PC.

所以我使用了一个小的应用程序,它加载所有的C#.NET的DLL在开机时引用的成分,热身该DLL的原始图像。它工作正常加载时间加快到0.5秒。

Therefore I uses a small application, which loads all the components referenced by the C#.NET DLL at the boot up time, to "warm up" the native image of that DLL. It works fine to speed up the loading time to 0.5 sec.

但是,它仅工作了一段时间。约30分钟。后来,它似乎降温了。

However, it only worked for a while. About 30 min. later, it seems to "cool down" again.

有什么办法来控制GAC或本机映像的行为始终热?难道这完全是一个图片地址衍合的问题?

Is there any way to control the behavior of GAC or native image to be always "hot"? Is this exactly a image address rebasing problem?

感谢您precious时间。

Thank you for your precious time.

真诚的,

迈克

推荐答案

我觉得不亚于任何东西,它很可能是框架库和CLR本身在Windows缓存之中。

I think as much as anything it's likely to be the framework libraries and the CLR itself being in the Windows cache.

您可能会发现一个小应用程序,它只是坐在后台,也许写一个字节到一个文件中的每一分钟(或只提供了足够的活动其他一些没有意义的任务,让所有的缓存加载相关文件)会做足以让一切的温暖。

You may find that a tiny app which just sat in the background, maybe writing a byte to a file every minute (or some other pointless task which provided just enough activity to keep all the relevant files loaded in the cache) would do enough to keep things "warm."

这将至少是值得一试 - 它应该用不了多长时间写在所有

It would at least be worth a try - it shouldn't take long to write at all.