PyCAM goes 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.
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!