not only [Sketch] - FC becomes unresponsive while performing calculations

Here's the place for discussion related to coding in FreeCAD, C++ or Python. Design, interfaces and structures.
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
User avatar
uwestoehr
Veteran
Posts: 4961
Joined: Sun Jan 27, 2019 3:21 am
Location: Germany
Contact:

not only [Sketch] - FC becomes unresponsive while performing calculations

Post by uwestoehr »

Abdullah requested me to test the new sketch annotation hide/show feature with a real-life example. Here is one:

Sketch-performance-test.FCStd
(27.05 KiB) Downloaded 47 times

This is just an array of rectangles and I cannot work with this in practice since FC freezes quickly and then Windows steps in because FC is no longer responding. So I this topic affects not only sketcher but FC in general.

When you open the sketch and press the "Hide all" button, FC becomes immediately unresponsive. I see that only once CPU core is working on full duty while the RAM consumption does not increase.

Question one is, can you reproduce this also on Linux?
Next question: is there a way to distribute the CPU calculations to several CPU cores?
Third question only regarding sketcher: you proposed a way to have different annotation "virtual spaces", would this increase the performance?

Besides the annotation showing/hiding, I get the same immediate unresponsiveness when I change the dimensional constraint 468.
User avatar
Chris_G
Veteran
Posts: 2598
Joined: Tue Dec 31, 2013 4:10 pm
Location: France
Contact:

Re: not only [Sketch] - FC becomes unresponsive while performing calculations

Post by Chris_G »

Confirmed. One CPU core working. Had to kill FC.

Code: Select all

OS: Manjaro Linux (KDE/plasma)
Word size of FreeCAD: 64-bit
Version: 0.20.25844 (Git)
Build type: Release
Branch: master
Hash: 1b20118dfa3fb9f127f0e4fb122701f7fcdaa9fc
Python version: 3.9.7
Qt version: 5.15.2
Coin version: 4.0.1
OCC version: 7.5.0
Locale: French/France (fr_FR)
User avatar
uwestoehr
Veteran
Posts: 4961
Joined: Sun Jan 27, 2019 3:21 am
Location: Germany
Contact:

Re: not only [Sketch] - FC becomes unresponsive while performing calculations

Post by uwestoehr »

Forgot to notify Adullah
abdullah wrote: .
abdullah
Veteran
Posts: 4935
Joined: Sun May 04, 2014 3:16 pm
Contact:

Re: not only [Sketch] - FC becomes unresponsive while performing calculations

Post by abdullah »

uwestoehr wrote: Mon Sep 27, 2021 5:43 pm Forgot to notify Adullah
abdullah wrote: .
It takes the Sketcher around 7 minutes in my Debug version to hide around 700 constraints.

This is way much more than I expected.

The only way to know what is happening there is to profile it. I will try to do this in the following days.

It also took 50 seconds to run the QR Decomposition (Debug version). There are algorithms for QR decomposition using more than one core, but they are GPL (not LGPL). However, I doubt this is responsible for the 7 minutes.
openBrain
Veteran
Posts: 9041
Joined: Fri Nov 09, 2018 5:38 pm
Contact:

Re: not only [Sketch] - FC becomes unresponsive while performing calculations

Post by openBrain »

abdullah wrote: Mon Sep 27, 2021 6:04 pm It also took 50 seconds to run the QR Decomposition (Debug version). There are algorithms for QR decomposition using more than one core, but they are GPL (not LGPL). However, I doubt this is responsible for the 7 minutes.
I had a quick look and suspected all the intermediate updating done at each value change to be responsible for the big delay.
Especially https://github.com/FreeCAD/FreeCAD/blob ... e.cpp#L794

I made a dirty test by commenting out the following lines :
https://github.com/FreeCAD/FreeCAD/blob ... t.cpp#L192
https://github.com/FreeCAD/FreeCAD/blob ... t.cpp#L194

After this moving the 700 constraints from one virtual space is a matter of seconds. Of course because of the dirty comments, a manual recompute is then needed, but it basically lasts the same time as opening the sketch for edition.

So I guess if we can block intermediate updating and do only a final one, this will go down from 7 minutes to something like 30 seconds (this is an order of magnitude, of course depends on your hardware and other things).
abdullah
Veteran
Posts: 4935
Joined: Sun May 04, 2014 3:16 pm
Contact:

Re: not only [Sketch] - FC becomes unresponsive while performing calculations

Post by abdullah »

openBrain wrote: Tue Sep 28, 2021 10:11 am So I guess if we can block intermediate updating and do only a final one, this will go down from 7 minutes to something like 30 seconds (this is an order of magnitude, of course depends on your hardware and other things).
It makes a lot of sense. This can easily be done by extending the command to update the virtual space to take an array of indices and overloading the corresponding function. Then the request should pass the list of indices and problem solved. I will do.

Thanks a lot! :)
openBrain
Veteran
Posts: 9041
Joined: Fri Nov 09, 2018 5:38 pm
Contact:

Re: not only [Sketch] - FC becomes unresponsive while performing calculations

Post by openBrain »

abdullah wrote: Tue Sep 28, 2021 12:34 pm It makes a lot of sense. This can easily be done by extending the command to update the virtual space to take an array of indices and overloading the corresponding function. Then the request should pass the list of indices and problem solved. I will do.

Thanks a lot! :)
I had run out of time to think about a solution, but yours sounds very good to me. :D
abdullah
Veteran
Posts: 4935
Joined: Sun May 04, 2014 3:16 pm
Contact:

Re: not only [Sketch] - FC becomes unresponsive while performing calculations

Post by abdullah »

openBrain wrote: Tue Sep 28, 2021 12:39 pm
abdullah wrote: Tue Sep 28, 2021 12:34 pm It makes a lot of sense. This can easily be done by extending the command to update the virtual space to take an array of indices and overloading the corresponding function. Then the request should pass the list of indices and problem solved. I will do.

Thanks a lot! :)
I had run out of time to think about a solution, but yours sounds very good to me. :D
That is the true meaning of collaboration... :D
openBrain
Veteran
Posts: 9041
Joined: Fri Nov 09, 2018 5:38 pm
Contact:

Re: not only [Sketch] - FC becomes unresponsive while performing calculations

Post by openBrain »

abdullah wrote: Tue Sep 28, 2021 12:54 pm That is the true meaning of collaboration... :D
We could even pretend it is an FTS one. :) We should include an Australian or Chinese fellow to cover the full 24h. :lol:
abdullah
Veteran
Posts: 4935
Joined: Sun May 04, 2014 3:16 pm
Contact:

Re: not only [Sketch] - FC becomes unresponsive while performing calculations

Post by abdullah »

git commit aa7d8001a238a0bc97acc74b055b4b26eed35f93
Post Reply