.NET - Single Threaded vs Multi-Threaded - Not seeing significant performance improvment in multi-threaded environment


I’m running multiple XPS to PDF conversions in my application and I’ve attempted to speed it up by running in parallel, however, I’m not seeing any performance improvements. In fact, the multi-threaded version is often slower than single threaded.

I’ve tried using Parallel.For, ThreadPool threads and managing my own threads, and all have similar results.

I’ve set up tests in benchmarkdotnet that confirm this is the case outside of my application.

I’m testing on Windows 10 i7-10700@2.9GHz (16 logical processors)processors
Should I expect that XPS to PDF conversion should be able to run in parallel with performance benefits, or is there some shared resource contention that limits multi-threaded performance?

Note, when I run the benchmarkdotnet ThreadingDiagnoser, it indicates many lock contentions when running in multi-threaded mode.

Is there anything I can do to get the benefits of multiple threads? If the answer is no, what if I spawned each conversion in it’s own asynchronous process? Would that have benefits? Or is the lock contention at a system level?

Thank you for your help


Can you please share some sample files along with the sample code snippet that you have been using? We will test the scenario in our environment and address it accordingly.