This project has moved and is read-only. For the latest updates, please go here.

techie problem/challenge - x64 Performance and AppDomains

Feb 18, 2009 at 11:29 PM
I'm sure there's a better forum for posting this as I guess it's not really directly MEF related, and if anyone has a suggestion for a better Microsoft forum, please let me know.

That said....

In my MEF based app, I am doing some spawning of AppDomains in order to perform isolated discovery of new addins within a running application.

I also perform this addin discovery (in an isolated appdomain) on startup of the app.

And, what I've found is that there is a *huge* difference in startup performance on 64 bit systems (Intel x64 with 64 bit Vista installed) between .NET assemblies built for any CPU (which therefore will JIT compile to x64) and the same assemblies running on the same system but marked for x86 (JIT compile to 32 bit).  When using the assemblies marked for 32 bit, the application starts WAAAAAAAAY faster!!!!!.  I'm talking about a difference of a sluggish ten seconds or so to start vs a snappy almost instant startup (o.k. maybe a second to start).

I initially put down the performance issues to not having taken care of a few issues - but I made sure that the app domain was marked to use LoaderOptimization.MultiDomainHost so that system assemblies are not JIT compiled multiple times.  I also made sure that 'Enable the Visual Studio hosting process' was unchecked so it wouldn't interfere with the initial Appdomain.

So, anyone know why this might be the case?

I'm reluctant to force JIT compilation to x86 but the startup time borders on unacceptable otherwise.  If I had to guess, I'd guess that the JIT compilation to x64 is less efficient than compilation to x86, making startup time take much longer.  Of course, I imagine the actually x64 code created is probably just as fast once you've paid the initial hit in compilation, but it's a really significant hit never the less.

Opinions?  Advice?