FreeCAD and multicores - multithreads

Have some feature requests, feedback, cool stuff to share, or want to know where FreeCAD is going? This is the place.
Forum rules
Be nice to others! Read the FreeCAD code of conduct!
jmaustpc
Veteran
Posts: 11207
Joined: Tue Jul 26, 2011 6:28 am
Location: Australia

Re: FreeCAD and multicores - multithreads

Post by jmaustpc »

easyw-fc wrote: Sun Jul 07, 2019 1:17 pm
jmaustpc wrote: Sat Jul 06, 2019 4:28 am I just tried opening your engine stp file here in FreeCAD daily on my old dual core laptop. Both cpu cores seem to be being used and are at times both simultaneously at 100%. That is one big slow to open file! :)
Have you tested the multicores trigger with htop or similar tools?
ATM I haven't found anyone having multicores triggered on linux during file loading...
I ran FreeCAD daily loading your large step file, and looked a htop, once again both cpus jumped up and down in usage amount, but sometimes both were up at the same time.

OS: Ubuntu 18.04.2 LTS (KDE/plasma)
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.19.
Build type: Release
Python version: 3.6.8
Qt version: 5.9.5
Coin version: 4.0.0a
OCC version: 7.3.0
Locale: English/Australia (en_AU)

Screenshot_20190708_204041.png
Screenshot_20190708_204041.png (85.41 KiB) Viewed 1664 times
User avatar
easyw-fc
Veteran
Posts: 3633
Joined: Thu Jul 09, 2015 9:34 am

Re: FreeCAD and multicores - multithreads

Post by easyw-fc »

jmaustpc wrote: Mon Jul 08, 2019 10:57 am I ran FreeCAD daily loading your large step file, and looked a htop, once again both cpus jumped up and down in usage amount, but sometimes both were up at the same time.

OS: Ubuntu 18.04.2 LTS (KDE/plasma)
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.19.
Build type: Release
Python version: 3.6.8
Qt version: 5.9.5
Coin version: 4.0.0a
OCC version: 7.3.0
Locale: English/Australia (en_AU)
Hi @jmaustpc
thanks for your detailed feedback.
From your htop screenshot only CPU1 is triggered to 94.1%...
what we noticed is that the process jumps randomly from a CPU to an other, but always triggering a single CPU at time.. and from your screenshot it seems it is exactly the same on your pc.
On Win and OSX instead, all CPUs get triggered simultaneously at about 25-45%
realthunder
Veteran
Posts: 2190
Joined: Tue Jan 03, 2017 10:55 am

Re: FreeCAD and multicores - multithreads

Post by realthunder »

easyw-fc wrote: Sun Jul 07, 2019 1:51 pm Ok, I'm going to ask some tips to @realthunder, who helped in developing the FC Appimage and improved OpenGL for his A3 branch...
You can use the ProcessExplorer to get a better view of CPU usage per thread. Open the process explorer, find the process, right click and choose 'Properties', and finally select the 'Threads' tab.

There are two distinct phases of STEP import in FC, the first phase (which shows the progress bar) happens entirely in OCCT. It reads the file and build all the shapes. The second phase is for FC to fetch those shapes and create objects and constructing 3D representations. What I found out is that OCCT runs only single threaded in the first phase. It does use multithreading in the second phase, for meshing I believe. I did a quick search around OCCT source code. There are actually only very few places that can run in parallel, one is in BOP tools, and the other is for meshing, and maybe some others I've missed.
Try Assembly3 with my custom build of FreeCAD at here.
And if you'd like to show your support, you can donate through patreon, liberapay, or paypal
wmayer
Founder
Posts: 20317
Joined: Thu Feb 19, 2009 10:32 am
Contact:

Re: FreeCAD and multicores - multithreads

Post by wmayer »

Here an interesting post of Roman Lygin's blog: https://opencascade.blogspot.com/2009/0 ... reams.html
But note this is now 10 years old and I don't know what is still true today.

I wonder if someone has a license for CADExchanger who could try the 200MB file because AFAIR this SW uses an optimized version of OCC's STEP reader.
jmaustpc
Veteran
Posts: 11207
Joined: Tue Jul 26, 2011 6:28 am
Location: Australia

Re: FreeCAD and multicores - multithreads

Post by jmaustpc »

realthunder wrote: Wed Jul 10, 2019 7:50 am You can use the ProcessExplorer to get a better view of CPU usage per thread. Open the process explorer, find the process, right click and choose 'Properties', and finally select the 'Threads' tab.
ProcessExplorer is a Windows program,

Do you know how to do something similar in Kubuntu 18.04?
User avatar
easyw-fc
Veteran
Posts: 3633
Joined: Thu Jul 09, 2015 9:34 am

Re: FreeCAD and multicores - multithreads

Post by easyw-fc »

realthunder wrote: Wed Jul 10, 2019 7:50 am You can use the ProcessExplorer to get a better view of CPU usage per thread. Open the process explorer, find the process, right click and choose 'Properties', and finally select the 'Threads' tab.

There are two distinct phases of STEP import in FC, the first phase (which shows the progress bar) happens entirely in OCCT. It reads the file and build all the shapes. The second phase is for FC to fetch those shapes and create objects and constructing 3D representations. What I found out is that OCCT runs only single threaded in the first phase. It does use multithreading in the second phase, for meshing I believe. I did a quick search around OCCT source code. There are actually only very few places that can run in parallel, one is in BOP tools, and the other is for meshing, and maybe some others I've missed.
Hi @realthunder,
thanks for coming in....
What I'm spotting here is that FC is loading the example STEP file using multicores both on Win and OSX, but instead uses only one core at time on Linux (jumping through the cores randomly).

This is quite strange and also disappointing because on Linux I acknowledge a worst performance, a less responsive pc during the loading and a higher CPU temperature.

Could you please to have a look using the STEP model and testing your A3 Appimage?
I made a simple comparison on my Linux PC and I noticed a similar behavior between your A3 and the main branch build.
Both behave similar under linux, without triggering the multicores, as instead it happens on win and osx.
Thx again
Maurice.
realthunder
Veteran
Posts: 2190
Joined: Tue Jan 03, 2017 10:55 am

Re: FreeCAD and multicores - multithreads

Post by realthunder »

easyw-fc wrote: Wed Jul 10, 2019 6:28 pm Could you please to have a look using the STEP model and testing your A3 Appimage?
I made a simple comparison on my Linux PC and I noticed a similar behavior between your A3 and the main branch build.
Both behave similar under linux, without triggering the multicores, as instead it happens on win and osx.
I tested on both mine and upstream images. They behave about the same. And yes on Linux it behave just like you described. But I observed the same on my Windows laptop, which is a quite old machine, so its even slower. Can you please download the process explorer in my previous post and test it on your Windows machine?
Try Assembly3 with my custom build of FreeCAD at here.
And if you'd like to show your support, you can donate through patreon, liberapay, or paypal
User avatar
easyw-fc
Veteran
Posts: 3633
Joined: Thu Jul 09, 2015 9:34 am

Re: FreeCAD and multicores - multithreads

Post by easyw-fc »

wmayer wrote: Wed Jul 10, 2019 9:22 am Here an interesting post of Roman Lygin's blog: https://opencascade.blogspot.com/2009/0 ... reams.html
But note this is now 10 years old and I don't know what is still true today.

I wonder if someone has a license for CADExchanger who could try the 200MB file because AFAIR this SW uses an optimized version of OCC's STEP reader.
@freecad-heini-1 would you please have a try?
freecad-heini-1 wrote: Thu Jul 11, 2019 8:10 am Ich habe mir den CAD-Exchanger gekauft.
https://cadexchanger.com/
PS to test the multicore / multithread, it is enough to open the linked STEP file (I just used a script to calculate also the loading time).
The STEP file is downloadable at this dropbox link (it is possible to download it without the need to register, clicking on 'No thanks, continue to view').
freecad-heini-1
Veteran
Posts: 7791
Joined: Tue Jan 07, 2014 11:10 am
Contact:

Re: FreeCAD and multicores - multithreads

Post by freecad-heini-1 »

easyw-fc wrote: Thu Jul 11, 2019 8:35 am
wmayer wrote: Wed Jul 10, 2019 9:22 am Here an interesting post of Roman Lygin's blog: https://opencascade.blogspot.com/2009/0 ... reams.html
But note this is now 10 years old and I don't know what is still true today.

I wonder if someone has a license for CADExchanger who could try the 200MB file because AFAIR this SW uses an optimized version of OCC's STEP reader.
@freecad-heini-1 would you please have a try?
freecad-heini-1 wrote: Thu Jul 11, 2019 8:10 am Ich habe mir den CAD-Exchanger gekauft.
https://cadexchanger.com/
Hello, Maurice,
of course I'm happy to help - and as best I can.
But I am still on holiday in beautiful Bulgaria until next week Wednesday included.
Here I have only an older weak notebook with me, without a CAD-Exchanger license.

Many greetings from the Black Sea coast

Wilfried
User avatar
easyw-fc
Veteran
Posts: 3633
Joined: Thu Jul 09, 2015 9:34 am

Re: FreeCAD and multicores - multithreads

Post by easyw-fc »

realthunder wrote: Wed Jul 10, 2019 11:46 pm Can you please download the process explorer in my previous post and test it on your Windows machine?
It seems it is working in parallel on multicores:
-
loading-file-cores.png
loading-file-cores.png (138.17 KiB) Viewed 1440 times
Post Reply