# Use of CachingPool's for a pmap that will be run many times

**URL:** https://discourse.julialang.org/t/use-of-cachingpools-for-a-pmap-that-will-be-run-many-times/69462
**Category:** General Usage
**Tags:** distributed, pmap
**Created:** [October 9, 2021, 4:12am UTC](https://discourse.julialang.org/t/use-of-cachingpools-for-a-pmap-that-will-be-run-many-times/69462 "2021-10-09T04:12:06Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![tictaccat](https://avatars.discourse-cdn.com/v4/letter/t/9f8e36/32.png) [@tictaccat](https://discourse.julialang.org/u/tictaccat)
#### Post date: [October 9, 2021, 4:12am UTC](https://discourse.julialang.org/t/use-of-cachingpools-for-a-pmap-that-will-be-run-many-times/69462/1 "2021-10-09T04:12:06Z")

</div>

Hi! I’m writing a custom linear map using `LinearMaps.jl` whose matrix-vector product I would like to embarassingly parallelize. The point is that this linear map will be used tens of thousands of times during an iterative solver, so I would like to speed-up each matrix-vector product.

I’ve read that `CachingPool` can be very useful for speeding up `pmap`, as using the default `WorkerPool` can lead to a lot of overhead. See, for example, this thread: [https://github.com/JuliaLang/julia/pull/33892](https://github.com/JuliaLang/julia/pull/33892). However, my question is: since the `pmap` used in my matrix-vector product will itself be run tens of thousands of times, does this mean it would be highly beneficial to use the same CachingPool across all of these `pmap`s, rather than creating a new `CachingPool` each time I run `pmap`? I could maybe do this by including a `CachingPool` as part of the state of my linear operator. I’m a bit cautious of this because I don’t know if it will lead to any performance improvement (I don’t really understand Julia distributed), and it also makes the code a decent amount more complicated as I have to manage the state of a pool. What are your thoughts?
