Python multiprocessing.starmap Process Count & Speed -


i have genetic algorithm fitness function cumbersome simulation environment. code absolutely cpu-bound, runs on 64bit python 3.3, have implemented multiprocessing.starmap_async parallelize.

and works well, large increases in efficiency on serial. on processor,intel i7 cpu @ 2.40 ghz (with 16gb ram): notice run-times of 8 9 seconds 4 processes (and slower 2 processes, , slower serial).

however, utilizes 65 73% of processor.
increasing process count 6 utilizes 95% 100% of processor, runtime of 11 seconds. memory still sitting around 20%

increase count 8 , processor sits @ 100%, runtime 12 seconds. memory fine.

i can't post everything, below multiprocessing call (with arguments removed). there can utilize more of processor without slow-down? i'd appreciate understanding why phenomena occurring.

multiprocessing call:

        step = np.int8(pop_size/4)         pol = pool(processes=4)          res = pol.starmap_async(simworker, ((i, i+step,pop,"a bunch of other arguments") in range(0, pop_size, step)))         fitnessdict = res.get()         fitnessdict = np.asarray(fitnessdict)         in range(0,pop_size,step):             p in range(i,i+step):                 fitness[p] = fitnessdict[i/step,p] 

simworker:

def simworker(start, stop, pop, "a bunch of other arguments"):     """     run batch of sims     """      p in range(start, stop):         fitness[p] = sim_t(pop[p],"a bunch of other arguments")     return(fitness) 


Comments

Popular posts from this blog

How to mention the localhost in android -

php - Calling a template part from a post -

c# - String.format() DateTime With Arabic culture -