We have a .net WPF .dll which is being loaded into a Delphi Hydra host in hcdNewAppDomain.
In an attempt to improve the performance of the plugin load we have used ngen to pre-compile the IL.
shows the assemblies we expect to see in the cache.
When profiling the load of the plugin using dotTrace we see the JIT reduced when the first instance of the plugin is loaded
Closing the plugin and re-opening we see a large JIT time as the compile is being performed, the same as before the ngen cache was built
I believe this can be accounted for by the statement from the MSDN article
“When an assembly with an NGen image is loaded into an AppDomain as domain-specific, the NGen image can only be used the first time the assembly is loaded. Subsequent attempts to load the same assembly into different AppDomains will result in code being JIT-compiled. This happens because when the NGen image is loaded as domain-specific, the loader initializes data structures in the NGen image resulting in the image being hardwired to that AppDomain. Once that happens, the code essentially becomes nonshareable.”
The odd thing is that if the plugin is closed and re-opened again for a third time we see the load time back to that of the first load, and the JIT time back down to milliseconds in dotTrace.
Repeating the open/close/open/close of the plugin sees the timings reliably flip between fast/slow/fast/slow and the dotTrace profiler shows ngen/JIT/ngen/JIT
Have you any ideas why are seeing this behaviour