Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #41061

Re: Advice regarding multiprocessing module

Date 2013-03-11 07:27 -0400
From Dave Angel <davea@davea.name>
Subject Re: Advice regarding multiprocessing module
References <513D6FEB.9040706@uci.edu> <513D725D.307@uci.edu>
Newsgroups comp.lang.python
Message-ID <mailman.3181.1363001273.2939.python-list@python.org> (permalink)

Show all headers | View raw


On 03/11/2013 01:57 AM, Abhinav M Kulkarni wrote:
>
>
>   <SNIP>
>   * My laptop has quad-core Intel i5 processor, so I thought using
>     multiprocessing module I can parallelize my code (basically
>     calculate gradient in parallel on multiple cores simultaneously).
    <SNIP>
>   * As a result I end up creating a process for each data point (instead
>     of a thread that I would ideally like to do, so as to avoid process
>     creation overhead).

Seems you only need 4 processes, as you have 4 cores.  Instead of 
creating a new one each time, reuse the same 4 processes, letting each 
do a quarter of the data.

It's not the process creation that's particularly slow, but all the 
initialization of starting another instance of Python.  If you're on 
Linux, you might be able to speed that up by using fork, but I don't 
specifically know.



-- 
DaveA

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

Re: Advice regarding multiprocessing module Dave Angel <davea@davea.name> - 2013-03-11 07:27 -0400

csiph-web