algorithmic modeling for Rhino
Hello world...
Can anybody offer some advice regarding multithreading and using GH components with python? I read Steve Baer's post (here) and tested a few commands myself, *but* everything is slower when using the parallel function. And the interesting thing is that it gets slower with every run. As you can see in the attached screenshots - the first run takes a few seconds as compared to the native GH component which finishes in 224ms. After multiple runs the python component is taking 3.9 minutes to run while the native component is finishing within a millisecond of the original time. What gives? I'm running this on a PC with 8 cores.
Tags:
in my experience, ghpythonlib.components and ghpythonlib.parallel are NOT FRIENDS. You can pretty readily parallelize rhinocommon functions - but trying to parallelize the "virtual component" logic from a grasshopper component seems to cause some kind of memory leak, with progressively worse performance.
See also these posts:
http://discourse.mcneel.com/t/ghpython-parallel-component-slower-th...
http://discourse.mcneel.com/t/new-ghpython-issues-crashing-multithr...
Thanks for the reply and tips Andrew. I've wondered why there are not heaps of posts using .parallel. I've suspected that we may have to write our own ray intersect function to get this to work reasonably fast.
Yes, thank you for the links, Andrew, definitely helpful in explaining the behavior we were getting.
Good news! The library is now rewritten in Rhino WIP. http://discourse.mcneel.com/t/new-version-of-ghpythonlib-components...
Hi Nik
thanks for the feedback. RhinoCommon can be overwhelming, while ghcomponentlib is used a lot because it is structured exactly like Grasshopper. It is also the only way to access, say, Voronoi or any third-party add-on. The default is still what you are able to access. Is there a function in particular that is giving you grief?
Just something to watch for: we cannot use normal lists in parallel. It is not safe. Things might just not work. Also, sorting is non-threaded, so adding a sort afterwards (if elements are many) will be very expensive and on one thread, again.
Just some ideas,
Giulio
--
Giulio Piacentino
for Robert McNeel & Associates
giulio@mcneel.com
Welcome to
Grasshopper
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
© 2024 Created by Scott Davidson. Powered by