Hello, I am very annoyed by a problem I have when running a certain script multiple times in a row. As you can see in the attached image, the script slows down dramatically on subsequent runs.
The idea behind it was to optimize the SurfaceSplit command when you input multiple surfaces to only call the component when the surfaces actually intersect. It uses a SurfaceClosestPoint to check if they intersect and if so performs the split.
I can't understand why each subsequent component runs slower than the former. I get the same behaviour if I turn the same component on and off in succession.
Could it be because of a memory problem which the script should handle? Or maybe the rhino (sr7) or grasshopper version (0.9.0068)?
I've also attached the script. Thank you for any ideas you could share.
Andrew Heumann
You are not alone. This has been happening to me too... mentioned here: http://discourse.mcneel.com/t/new-ghpython-issues-crashing-multithr...
quote:
I am concerned that some sort of memory leak is occurring. I have now noticed several times that every time a complex, multithreaded python script runs, its execution time is significantly slower than the previous time, even with identical data. In the attached definition, when I enable the python component the first time, it calculates in 8.4 seconds. If I repeatedly reconnect one of the inputs, it goes up to 13.8, then 24.8, then upwards of 2 minutes. See the attached video for one example of such a run cycle. I have edited the video for speed but you can clearly see the difference.
Jan 28, 2014
Andrew Heumann
It's my opinion that it is a problem with ghpythonlib.components... if I avoid this and only use sdk functions the problem goes away.
Jan 28, 2014
trevor.patt
I have a similar problem happening when I edit the code inside a ghPython module multiple times.
Every solution takes longer than the previous, even when changes are made to speed up the processing. For example, I had a bit of code which ran in ~45s according to the profiler. After a series of edits, it ballooned to ~60 minutes(!), but when I closed Rhino and reopened Grasshopper, it now ran in ~40s, a slight improvement.
This makes it pretty much impossible to evaluate improvements without completely closing the program and reloading everything in between every edit and also makes it difficult to follow the good practice of frequently making/checking small edits to code.
Are there any recommendations for avoiding this phenomenon? It seems the standard python tips for speed/performance optimization don't always translate to ghPython.
May 2, 2014