Hi Asad
I’ve made a simple console app that exhibits some of the performance issues I’m encountering but not to the full extent of my app, but I think the cause is the same Monitor.Enter
mentioned in the thread.
Please see the onedrive link with the zipped dotnet project:
https://1drv.ms/u/s!ArCE2vd0EvhJhW58cnDF84DOGaVm?e=KzadFe
You will need to fix up the Aspose3D license file.
The console app should be able to run without any console args and will default to 1 worker. If you add --parallel 12
to the args, it will increase the worker count. The app also loads the target file and stores the bytes in memory to rule out IO.
Here are the results for my work pc (16 core 32 thread AMD Ryzen 9 3950x) without attaching the debugger:
1 thread:
Total average over 1 workers was 1.0 seconds from 12 samples
From this we can establish that the file takes about a second to load…
2 threads - roughly 5% CPU
Worker 0 average scene open time: 1.5 seconds for 12 samples
Worker 1 average scene open time: 1.5 seconds for 12 samples
Total average over 2 workers was 1.5 seconds from 24 samples
6 threads
Worker 0 average scene open time: 3.7 seconds for 12 samples
Worker 1 average scene open time: 3.7 seconds for 12 samples
Worker 2 average scene open time: 3.8 seconds for 12 samples
Worker 3 average scene open time: 3.6 seconds for 12 samples
Worker 4 average scene open time: 3.7 seconds for 12 samples
Worker 5 average scene open time: 3.6 seconds for 12 samples
Total average over 6 workers was 3.7 seconds from 72 samples
12 threads:
Worker 0 average scene open time: 11.2 seconds for 12 samples
Worker 1 average scene open time: 10.7 seconds for 12 samples
Worker 2 average scene open time: 11.3 seconds for 12 samples
Worker 3 average scene open time: 11.3 seconds for 12 samples
Worker 4 average scene open time: 11.2 seconds for 12 samples
Worker 5 average scene open time: 11.2 seconds for 12 samples
Worker 6 average scene open time: 11.3 seconds for 12 samples
Worker 7 average scene open time: 10.7 seconds for 12 samples
Worker 8 average scene open time: 11.3 seconds for 12 samples
Worker 9 average scene open time: 11.3 seconds for 12 samples
Worker 10 average scene open time: 11.3 seconds for 12 samples
Worker 11 average scene open time: 11.3 seconds for 12 samples
Total average over 12 workers was 11.2 seconds from 144 samples
16 threads
Total average over 16 workers was 12.2 seconds from 192 samples
32 threads - overall cpu usage ranges between 13-22%, hard to get a good reading
Total average over 32 workers was 32.3 seconds from 384 samples
image.png (31.3 KB)
As you can see, the same file ends up taking longer and longer for each additional thread running. This does not appear to be limited to fbx files, as a glb file also increased in time.
Pause the debugger with 16 workers. The following image is of “Parallel Stacks” and shows 15 threads stuck on the Monitor.Enter
image.png (292.1 KB)
This has become an issue for me recently because I’m working on reducing memory from massive cad files by breaking them up into lots of smaller files. This way areas can be stored on disk and loaded when they are needed, instead of keeping the entire thing in memory. However this has reduced performance to a crawl.
With 16 threads jetbrains dotTrace is showing 81% of time is lock contention:
image.png (28.9 KB)