PyCAM goes parallel!

Multiple PyCAM processes in parallel

As some of you may have noticed, PyCAM currently works with only one process – thus it does not use the full capabilities of modern multi-core CPUs.

Today I got tired of waiting many hours for a toolpath generation, thus I started to implement parallel processing based on Python’s [Bad Link] module. The implementation was much simpler than I thought, especially due to the well designed Pool class. Before I only used the threading module which is significantly more complicated.

For now the code still needs to protect the collision detection with a time-wasting lock, but this should be quite easy to fix. So maybe it will be done tomorrow :)

The multiprocessing ability will be used automatically if you your machine has more than one CPU core. The only additional requirement is the multiprocessing module, which is part of the base Python package since v2.6. Users of Python 2.5 or below need to install the backported multiprocessing package separately. For Debian/Ubuntu this is as easy as apt-get install python-processing.

By default all available cores of your CPU are used. But you can configure this via the commandline (e.g. --number-of-processes 0 disables multiprocessing).

Additionally I also added support for profiling. The nice small python module [Bad Link] creates a very good visualization of the profiling results. I guess, I managed to improve performance by at least 20% with some few code changes today.
Profiling visualization

As another small gem of today’s progress, Linux users can now enjoy a proper label for PyCAM’s processes. This will give you a better overview when listing the running processes of your system. Of course, killall pycam is now usable as well. The only requirement is the python module setproctitle (Debian: apt-get install python-setproctitle).

I hope, you will enjoy the new blazing performance of PyCAM!

Comments

No more locking ...

I just fixed the code that required a Lock before. The Lock was the bottleneck of the parallel calculation. Now the time required for running the default set of operations with the default model went down from 265s to 160s (on my testing system with 4 CPUs).
This is a nice performance boost of 65%!
As usual you need the up-to-date code from the subversion repository to enjoy this :)

Post new comment

  • You may embed videos from the following providers vimeo. Just add the video URL to your textarea in the place where you would like the video to appear, i.e. http://www.youtube.com/watch?v=pw0jmvdh.
  • Web page addresses and e-mail addresses turn into links automatically.
  • You may use [inline:xx] tags to display uploaded files or images inline.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd> <img><h2><h3<h4>
  • You can use Textile markup to format text.
  • Lines and paragraphs break automatically.
  • Freelinking helps you easily create HTML links. Links take the form of [[indicator:target|Title]]. By default (no indicator): Link to a local node by title
  • You can link nodes to other nodes using the following syntax:
    [node:node_id,title="val2"]
  • Enter node links as [1234:text] where 1234 is a node number and text is what should be displayed or $ to display the node's title.
  • Use [toc list: ol; title: Table of Contents; minlevel: 2; maxlevel: 3; attachments: yes;] to insert a mediawiki style collapsible table of contents. All the arguments are optional.

More information about formatting options

By submitting this form, you accept the Mollom privacy policy.