# SharedArrays. Stability

**URL:** <https://discourse.julialang.org/t/sharedarrays-stability/19304>\
**Category:** Performance\
**Created:** [January 5, 2019, 1:35pm UTC](https://discourse.julialang.org/t/sharedarrays-stability/19304 "2019-01-05T13:35:33Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![xanfus](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/xanfus/32/5813_2.png) [@xanfus](https://discourse.julialang.org/u/xanfus)\
**Post date:** [January 5, 2019, 1:35pm UTC](https://discourse.julialang.org/t/sharedarrays-stability/19304/1 "2019-01-05T13:35:33Z")

</div>

I’ve conducted package upgrade from official repositories on 21 Dec. I ran Julia v0.7.0 and i’d noticed one of my SharedArray’s had returned `procs(S)=Int64[0]`. I’d migrated to Julia v1.0.3. Same thing.

I’d put @info’s along the initialization part of the outermost calling function, where SharedArray of interest is created, and observed, `procs(S) = Int64[0]` happens at random line, right from the beginning or doesn’t at all, like random event, with higher probability the more **lines** are executed in the same local scope. I created those shared arrays by specifying _pids_ kwarg with Array{Int64,1}. When i’ve changed _pids_ type to UnitRange{Int64}, bug had never been observed since.

```julia
using SharedArrays
function o102e(jstart::Int,jend::Int,tJn::Int;NN1::Int64=32000,NN2::Int64=126000,pids=2:13)
    NN=NN1+NN2
    zut=SharedArray{Float64}(NN, init = S -> S[localindices(S)] .= 0.0,pids=pids)
    w =SharedArray{Float64}(NN, init = S -> S[localindices(S)] .= 0.0,pids=pids)
    si =SharedArray{Float64}(NN, init = S -> S[localindices(S)] .= 0.0,pids=pids)
    dsi =SharedArray{Float64}(NN, init = S -> S[localindices(S)] .= 0.0,pids=pids)
    @info string("344 zut ",length(procs(zut)))
    u = SharedArray{Float64}(NN1, init = S -> S[localindices(S)] .= 0.0,pids=pids)
    @info string("352 zut ",length(procs(zut)))
    siu =SharedArray{Float64}(NN1, init = S -> S[localindices(S)] .= 0.0,pids=pids)
    dsiu=SharedArray{Float64}(NN1, init = S -> S[localindices(S)] .= 0.0,pids=pids)
    @info string("365 zut ",length(procs(zut)))
    epso =SharedArray{Float64}(NN , init = S -> S[localindices(S)] .= 0.0,pids=pids)
    tuwa =SharedArray{Float64}(NN1, init = S -> S[localindices(S)] .= 0.0,pids=pids)
    dtuwa=SharedArray{Float64}(NN1, init = S -> S[localindices(S)] .= 0.0,pids=pids)
    Tchi =SharedArray{Float64}(NN1, init = S -> S[localindices(S)] .= 0.0,pids=pids)
    sichi2=SharedArray{Float64}(NN1, init = S -> S[localindices(S)] .= 0.0,pids=pids)
    chis =SharedArray{Float64}(NN1, init = S -> S[localindices(S)] .= 0.0,pids=pids)
    @info string("379 zut ",length(procs(zut)))
    # return length(procs(zut)),procs(zut)
end
begin
    @info "alpha!"
    for k=1:20
        o102e(260001,262001,260000,pids=collect(2:13))
    end
end
begin
    @info "omega!"
    for k=1:20
        o102e(260001,262001,260000,pids=2:13)
    end
end

Julia Version 1.0.3
Commit 04330c0 (2018-12-16 21:23 UTC)
Platform Info:
  OS: Linux (x86_64-linux-gnu)
  CPU: Intel(R) Xeon(R) CPU E5-2630 0 @ 2.30GHz
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-6.0.0 (ORCJIT, sandybridge)

```

---

<div class="post-metadata">

**Author:** ![jpsamaroo](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jpsamaroo/32/46804_2.png) [@jpsamaroo](https://discourse.julialang.org/u/jpsamaroo)\
**Post date:** [January 5, 2019, 1:58pm UTC](https://discourse.julialang.org/t/sharedarrays-stability/19304/2 "2019-01-05T13:58:16Z")

</div>

A MWE of your problem would help people understand exactly what you’re trying to do, and how we can help:

> [@Please read: make it easier to help you](https://discourse.julialang.org/t/psa-make-it-easier-to-help-you/14757):
>
> Welcome to the Julia Discourse! We are enthusiastic about helping Julia programmers, both beginner and experienced. This public service announcement (PSA) outlines best practices when asking for help. Following these points makes it easier for us to help you and more likely you’ll get a prompt, useful answer. Keywords are highlighted to make it easier to refer to specific points. Choose a descriptive title that captures the key part of your question, eg “plots with multiple axes” instead of …

---

<div class="post-metadata">

**Author:** ![xanfus](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/xanfus/32/5813_2.png) [@xanfus](https://discourse.julialang.org/u/xanfus)\
**Post date:** [January 5, 2019, 2:39pm UTC](https://discourse.julialang.org/t/sharedarrays-stability/19304/3 "2019-01-05T14:39:09Z")

</div>

I’ve just updated.

```julia
Resolving package versions...
 Installed CodeTools ââ v0.6.4
 Installed Atom âââââââ v0.7.12
 Installed Tokenize âââ v0.5.3
 Installed WebSockets â v1.2.0
 Installed IJulia âââââ v1.15.1
 Installed DataFrames â v0.16.0
  Updating `~/.julia/environments/v1.0/Project.toml`
  [c52e3926] â Atom v0.7.11 â v0.7.12
  [a93c6f00] â DataFrames v0.15.2 â v0.16.0
  [7073ff75] â IJulia v1.14.1 â v1.15.1
  Updating `~/.julia/environments/v1.0/Manifest.toml`
  [c52e3926] â Atom v0.7.11 â v0.7.12
  [53a63b46] â CodeTools v0.6.3 â v0.6.4
  [a93c6f00] â DataFrames v0.15.2 â v0.16.0
  [7073ff75] â IJulia v1.14.1 â v1.15.1
  [0796e94c] â Tokenize v0.5.2 â v0.5.3
  [104b5d7c] â WebSockets v1.1.1 â v1.2.0
  Building IJulia â `~/.julia/packages/IJulia/3k6Fz/deps/build.log`

[ Info: alpha!
[ Info: alpha!
[ Info: alpha!
[ Info: 344 zut 12
[ Info: 352 zut 12
[ Info: 365 zut 12
[ Info: 379 zut 0
[ Info: 344 zut 12
[ Info: 352 zut 12
[ Info: 365 zut 12
[ Info: 379 zut 12
[ Info: 344 zut 12
[ Info: 352 zut 12

```

And there are no more zeros happening except this one. Consequent runs return ‘12’.
