# Pmap slowdown in Julia 0.5?

**URL:** <https://discourse.julialang.org/t/pmap-slowdown-in-julia-0-5/4314>\
**Category:** General Usage\
**Tags:** parallel\
**Created:** [June 16, 2017, 6:48pm UTC](https://discourse.julialang.org/t/pmap-slowdown-in-julia-0-5/4314 "2017-06-16T18:48:43Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![pearlzli](https://avatars.discourse-cdn.com/v4/letter/p/76d3ee/32.png) [@pearlzli](https://discourse.julialang.org/u/pearlzli)\
**Post date:** [June 16, 2017, 6:48pm UTC](https://discourse.julialang.org/t/pmap-slowdown-in-julia-0-5/4314/1 "2017-06-16T18:48:43Z")

</div>

I’m having an issue where parallel code works as intended in Julia 0.4, but in Julia 0.5 appears to slow down over time. Specifically, we have a function `forecast_one` which does computations in blocks. In Julia 0.4, the time per block remains constant after precompiling. After moving to Julia 0.5, the time per block appears to increase linearly as more blocks are computed.

For context, we’re running this function using 10 worker processes on a Linux-based cluster. From watching `top` on a given compute node, we’ve observed the following:

- Memory usage is constant and very low over processes and nodes over time, as expected
- In the beginning, the originator process is relatively not busy, while the worker processes are busy nearly 100% of the time
- Over time, the worker processes’ CPU usage declines while the master process’s increases, in conjunction with the observed slowdown
- Asymptotically, the worker processes are completely idle

I understand that `pmap` was refactored quite a bit between Julia 0.4 and 0.5, and I’m wondering if any of those changes are contributing to the worsening performance for us now in Julia 0.5. Besides making small necessary changes to make our code 0.5-compatible, nothing else is different between the versions of our code run in 0.4 and 0.5.

Unfortunately, I’ve so far been unable to produce a minimal working example illustrating this issue.

Some pseudo-code for `forecast_one` is below (the actual code is [here](https://github.com/FRBNY-DSGE/DSGE.jl/blob/master/src/forecast/drivers.jl)):

```julia
function forecast_one(model, ...)
    for block = 1:nblocks
        # Read from HDF5 file
        parameter_draws = load_draws(model, block)

        # Call pmap
        forecast_output = pmap(param -> forecast_one_draw(model, param, ...), parameter_draws)
        gc()

        # Write to JLD file
        write_forecast_output(forecast_output)
    end
end

```

The function being `pmap`ped over, `forecast_one_draw`, basically does a lot of matrix multiplication and linear algebra (but doesn’t involve any IO). It returns a `Dict{Symbol, Array{Float64}}` where the arrays are large-ish (max 84 x 229 x 24).

cc: @abhig94 @emoszkowski

---

<div class="post-metadata">

**Author:** ![Christopher\_Fisher](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/christopher_fisher/32/26132_2.png) [@Christopher\_Fisher](https://discourse.julialang.org/u/Christopher_Fisher)\
**Post date:** [June 17, 2017, 8:18pm UTC](https://discourse.julialang.org/t/pmap-slowdown-in-julia-0-5/4314/2 "2017-06-17T20:18:35Z")

</div>

I encountered a similar issue one time with Julia .4. In my case, the problem seemed to be a memory leak or failure of garbage collection. The issue seemed to resolve itself when I upgraded to .5. Does your memory usage max out?

---

<div class="post-metadata">

**Author:** ![pearlzli](https://avatars.discourse-cdn.com/v4/letter/p/76d3ee/32.png) [@pearlzli](https://discourse.julialang.org/u/pearlzli)\
**Post date:** [June 19, 2017, 1:50pm UTC](https://discourse.julialang.org/t/pmap-slowdown-in-julia-0-5/4314/3 "2017-06-19T13:50:33Z")

</div>

No, unfortunately, the memory usage seems to be low and constant over time.
