Recompute time making it hard to work with spreadsheet

Post here for help on using FreeCAD's graphical user interface (GUI).
Forum rules
and Helpful information
IMPORTANT: Please click here and read this first, before asking for help

Also, be nice to others! Read the FreeCAD code of conduct!
kenjo
Posts: 2
Joined: Thu Aug 15, 2019 3:09 pm

Recompute time making it hard to work with spreadsheet

Post by kenjo »

So I'm trying to use the spreadsheet to collect all the important variables in one place but now whenever I change anything even just entering a new number in a cell that is not used by anything the recompute starts and it is taking 15-20 seconds making it unusable. I do not think its the stuff in the spreadsheet that takes time but the fact that other objects is using the spreadsheet values.

I did find the skip recompute option but it also turns off any updates inside the spreadsheet. Is there any way to make the spreadsheet the only thing updating until I'm done changing it??

I do not know the internal of freecad maybe its had to make is so that only the spreadsheet is recomputing but maybe it could be possible to add something like "copy write replace" that is I make a copy of the spreadsheet play with that until I have what I need then simply replace the old one with the copy so the other part of the document can be updated. I did test and if I create a new spreadsheet that one do not trigger any recompute since its not exporting any values that is used.

something needs to change as this is not really useful, I now create the formula in an unused spreadsheet and then manual copy that cell by cell into the active one. not super efficient.

-------------------------------------
OS: Ubuntu 19.04 (ubuntu:GNOME/ubuntu)
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.19.17500 (Git)
Build type: Debug
Branch: master
Hash: b013624ba82e0c138facbda176c3dc7b948276a1
Python version: 2.7.16
Qt version: 4.8.7
Coin version: 4.0.0a
OCC version: 6.9.1.oce-0.18
Locale: English/UnitedStates (en_US)
Last edited by kenjo on Thu Aug 15, 2019 6:32 pm, edited 1 time in total.
TheMarkster
Veteran
Posts: 5508
Joined: Thu Apr 05, 2018 1:53 am

Re: Recompute time making it hard to work with spreadcheet

Post by TheMarkster »

Yes, this behavior was noticed recently, and pointed out by FreeCAD's lead developer in another forum topic.

The changes are remembered in the spreadsheet, they are just not shown until the recompute. All the changes you make will get updated. The inconvenience is you have to remember in your head what changes you have made and to which cells, which in a complex spreadsheet can be difficult.
kenjo
Posts: 2
Joined: Thu Aug 15, 2019 3:09 pm

Re: Recompute time making it hard to work with spreadsheet

Post by kenjo »

Do you have a link to the other topic ?
User avatar
uwestoehr
Veteran
Posts: 4961
Joined: Sun Jan 27, 2019 3:21 am
Location: Germany
Contact:

Re: Recompute time making it hard to work with spreadsheet

Post by uwestoehr »

Hi Hyarion and realthunder,
as spin-off from https://github.com/FreeCAD/FreeCAD/pull ... -774932229 and the existing bug report https://tracker.freecadweb.org/view.php?id=4024
let's discuss this here in the forum.

The problem is that for more complex designs a complete recomputation can take a long time. In many cases a change on a spreadsheet cell has no effect on the design and thus no recomputation is necessary.

There is a huge pending PR regarding the Spreadsheet functionality: https://github.com/FreeCAD/FreeCAD/pull/2862

Therefore I don't know how and if it is possible to improve the situation to fix https://tracker.freecadweb.org/view.php?id=4024
What is your opinion?

hyarion wrote: .
realthunder wrote: .
realthunder
Veteran
Posts: 2190
Joined: Tue Jan 03, 2017 10:55 am

Re: Recompute time making it hard to work with spreadsheet

Post by realthunder »

Yes, I have a working solution for this, but it is not included in that PR, as it is not related. However, the solution has potential deep impact because of some core changes on recomputation.

My solution is to add new API Property::isSame() that can be overridden by derived properties for checking if the new input value is the same. If so, do not mark the property as touched. Each DocumentObject maintains an internal 'version', that will only be increased if there is at least one property is marked as touched after recomputation. There is a slow default implementation Property::isSameContent()' that can work on all types of properties, but most property implement its own quicker version.

Apart from isSame(), Property::isTouched() has also been change to virtual, and overridden in PropertyLink derived properties to check if the linked object's version has been changed.

When a Spreadsheet is edited and marked as touched, all its dependent object's expression engine will be asked to evaluate their bound properties, and mark for recomputation if and only if there is actual change in any property. The 'isSame()' API benefits not only the Spreadsheet, but any other objects that are slow to recompute, e.g. Sketch. However, it may also break some existing code that relies on setting property value to touch the object without making sure it is a new value.

For anyone interested, you can try my branch to test. It is probably not the best time for a PR now, since this would be another big one, and also that there are other interfering PRs of mine pending.
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
M4x
Veteran
Posts: 1480
Joined: Sat Mar 11, 2017 9:23 am
Location: Germany

Re: Recompute time making it hard to work with spreadsheet

Post by M4x »

I've a workaround. I create the spreadsheet in another document and link to it. This way, you're able to edit it without the downsides of turning off recompute. A "better" explanation with examples is onmy to do list. Where would be a good place to put it? Spreadsheet wiki?
Attachments
4ae9e02b03deef6f.png
4ae9e02b03deef6f.png (36.18 KiB) Viewed 1787 times
User avatar
uwestoehr
Veteran
Posts: 4961
Joined: Sun Jan 27, 2019 3:21 am
Location: Germany
Contact:

Re: Recompute time making it hard to work with spreadsheet

Post by uwestoehr »

M4x wrote: Mon Jun 21, 2021 5:42 am I've a workaround. I create the spreadsheet in another document and link to it. This way, you're able to edit it without the downsides of turning off recompute. A "better" explanation with examples is on my to do list. Where would be a good place to put it? Spreadsheet wiki?
Yes, a new section in https://wiki.freecadweb.org/Spreadsheet_Workbench would be a good place.
User avatar
M4x
Veteran
Posts: 1480
Joined: Sat Mar 11, 2017 9:23 am
Location: Germany

Re: Recompute time making it hard to work with spreadsheet

Post by M4x »

Thank you very much! I'm on holidays now, therefore I should finally find the time to explain my workaround in detail in the wiki :D
User avatar
Roy_043
Veteran
Posts: 8538
Joined: Thu Dec 27, 2018 12:28 pm

Re: Recompute time making it hard to work with spreadsheet

Post by Roy_043 »

M4x wrote: Mon Jun 21, 2021 5:42 am I've a workaround.
Seems to me that it is a variant of a solution that is already explained:
Spreadsheet_Workbench#Complex_models_and_recomputes
User avatar
M4x
Veteran
Posts: 1480
Joined: Sat Mar 11, 2017 9:23 am
Location: Germany

Re: Recompute time making it hard to work with spreadsheet

Post by M4x »

You're right but this looks more complicated than it has to be to me.
Post Reply