# Overhead in passing data to worker processes

**URL:** https://discourse.julialang.org/t/overhead-in-passing-data-to-worker-processes/11566
**Category:** General Usage
**Tags:** parallel
**Created:** [June 10, 2018, 5:39pm UTC](https://discourse.julialang.org/t/overhead-in-passing-data-to-worker-processes/11566 "2018-06-10T17:39:58Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![tk3369](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tk3369/32/2824_2.png) [@tk3369](https://discourse.julialang.org/u/tk3369)
#### Post date: [June 10, 2018, 5:39pm UTC](https://discourse.julialang.org/t/overhead-in-passing-data-to-worker-processes/11566/1 "2018-06-10T17:39:58Z")

</div>

I have several large objects that need to be passed to worker processes. Currently, I am just using a simple `@parallel` for loop without any reducer. Since the objects are quite large, it takes 5 seconds before a worker process actually starts doing the work.

However, it appears that each worker process is taking this hit sequentially. So, the first worker takes 5 seconds, then the second worker takes another 5 seconds, so on and so forth. While I have many worker processes (24), the later one progressively take a longer time to even start doing work.

Is there any way to avoid that? Perhaps using something other than `@parallel`? I’ll work out a MWE if needed. Thanks

---

<div class="post-metadata">

### Author: ![Elrod](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/elrod/32/22461_2.png) [@Elrod](https://discourse.julialang.org/u/Elrod)
#### Post date: [June 10, 2018, 5:55pm UTC](https://discourse.julialang.org/t/overhead-in-passing-data-to-worker-processes/11566/2 "2018-06-10T17:55:25Z")

</div>

Any chance you can construct the objects, or load the necessary data, on those workers (ie, rather than on the main process)?  
That’d be the simplest solution, if possible.

If you aren’t on a distributed memory system, you could use threads instead.

---

<div class="post-metadata">

### Author: ![tk3369](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tk3369/32/2824_2.png) [@tk3369](https://discourse.julialang.org/u/tk3369)
#### Post date: [June 10, 2018, 6:51pm UTC](https://discourse.julialang.org/t/overhead-in-passing-data-to-worker-processes/11566/3 "2018-06-10T18:51:29Z")

</div>

Let me try to use JLD2 to save to a SSD and ask the workers to load the data in parallel. I’m unsure if my code is thread-safe… can try that next. Thanks for the ideas.

---

<div class="post-metadata">

### Author: ![tk3369](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tk3369/32/2824_2.png) [@tk3369](https://discourse.julialang.org/u/tk3369)
#### Post date: [June 11, 2018, 12:56am UTC](https://discourse.julialang.org/t/overhead-in-passing-data-to-worker-processes/11566/4 "2018-06-11T00:56:25Z")

</div>

JLD2+SSD worked well.

Multi-threading failed in BLAS. I have 96 threads running on a server with 144 vCPU’s and tons of memory.

```julia
Error thrown in threaded loop on thread 47: Base.KeyError(key=1111826)BLAS : Program is Terminated. Because you tried to allocate too many memory regions.
BLAS : Program is Terminated. Because you tried to allocate too many memory regions.
BLAS : Program is Terminated. Because you tried to allocate too many memory regions.
BLAS : Program is Terminated. Because you tried to allocate too many memory regions.

signal (11): Segmentation fault
while loading no file, in expression starting on line 0

signal (11): Segmentation fault
while loading no file, in expression starting on line 0
unknown function (ip: 0x7fa6871343a8)
dgemv_t_HASWELL at /opt/julia/bin/../lib/julia/libopenblas64_.so (unknown line)

signal (11): Segmentation fault
while loading no file, in expression starting on line 0
unknown function (ip: 0x7fa6871343a8)
unknown function (ip: 0x7fa685bbe23b)
dgemv_t_HASWELL at /opt/julia/bin/../lib/julia/libopenblas64_.so (unknown line)
unknown function (ip: 0x7fa6871343a8)
exec_blas at /opt/julia/bin/../lib/julia/libopenblas64_.so (unknown line)
unknown function (ip: 0x7fa685bbe23b)

```

---

<div class="post-metadata">

### Author: ![johnh](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/johnh/32/3615_2.png) [@johnh](https://discourse.julialang.org/u/johnh)
#### Post date: [June 11, 2018, 1:05pm UTC](https://discourse.julialang.org/t/overhead-in-passing-data-to-worker-processes/11566/5 "2018-06-11T13:05:22Z")

</div>

> [@tk3369](#):
>
> BLAS : Program is Terminated. Because you tried to allocate too many memory regions.

Google shows me this issue. I guess you have more that 128 vCPUs

> <https://github.com/conda-forge/openblas-feedstock/issues/26>
>
> .. otherwise the value is determined from the build machine instead and you'll f…ail to exploit high performance systems.

A grown-up will be along in a minute, but surely this limit should be configureable by an environment variable?
