It is a well-documented fact that the System.Xml.dll assembly experiences significant performance issues when running in 64-bit mode. This is primarily caused by Microsoft’s JIT (Just-In-Time) compiler, as explained by Microsoft in the following comments:
“The root of the problem is related to two things: First, the x64 JIT compiler has a few algorithms that are quadratically scaling. One of them is the debug info generator, unfortunately. So for very large methods, it really gets out of control.”
and
“some algorithms in the 64 Bit JIT that have polynomial scaling. We’re actually working on porting the 32 bit JIT compiler to x64, but that won’t see the light of day until the next side-by-side release of the runtime (as in “2.0 & 4.0 run side-by-side, but 3.0/3.5/3.5SP1 were ‘in-place’ releases). I’ve switched this over to a ‘suggestion’ so I can keep it attached to the JIT-throughput work item to make sure this is fixed when the newly ported JIT is ready to ship.”
If you are running your project as a 64-bit application and encounter this issue, there are several workarounds to address it:
- Run your application as a 32-bit application
The JIT compiler’s performance issues are specific to the 64-bit environment. By running your application in 32-bit mode, you can avoid these problems entirely. - Generate native images of your application’s assemblies
This approach is simple and highly effective. Use the Ngen.exe (Native Image Generator) tool to pre-compile your assemblies into native machine code. This can boost the performance of your 64-bit application by up to 100 times. To do this, execute the following command:
ngen install <path to your application exe>