Grasshopper

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.

Views: 4737

Attachments:

Replies to This Discussion

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...

Great news. But learning Rhinocommon opens up a lot more command options like tolerance and what about the old problem that node-in-code can only access the default mode of a component that has options for several in its little tag along the component bottom?

One aspect to parallel I had to appreciate was having to add an index entry paired to my input data that survived the parallel function reordering of an input list, so I could re-sort the output to correspond to the input list.

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

RSS

About

Translate

Search

Photos

  • Add Photos
  • View All

Videos

  • Add Videos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service