# Maintaining structures across workers

**URL:** <https://discourse.julialang.org/t/maintaining-structures-across-workers/112820>\
**Category:** New to Julia\
**Tags:** question, parallel, syntax, distributed\
**Created:** [April 11, 2024, 7:50am UTC](https://discourse.julialang.org/t/maintaining-structures-across-workers/112820 "2024-04-11T07:50:56Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Utkarsh\_Sharma](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/utkarsh_sharma/32/208410_2.png) [@Utkarsh\_Sharma](https://discourse.julialang.org/u/Utkarsh_Sharma)\
**Post date:** [April 11, 2024, 7:50am UTC](https://discourse.julialang.org/t/maintaining-structures-across-workers/112820/1 "2024-04-11T07:50:56Z")

</div>

I created a struct params to be used across different workers as -

```julia
@everywhere params = parameters(Int64[], ...)

```

I initialise params.mapping\_ping as

```julia
params.mapping_ping = rand(1:params.q_datacenters, dimensions.num_func_K)
println("init length of params.mapping_ping = ", length(params.mapping_ping))

#output- init length of params.mapping_ping = 100

```

However, when I run `local task = @spawnat :any custom_prox(..)` which calls

```julia
@everywhere function ProximalOperators.prox!(y, f::HingeDot, x, gamma)
    println("length of params.mapping_ping is ", length(params.mapping_ping))
    datacenter_index = params.mapping_ping[f.k]

```

I get the output  
`From worker 3: length of params.mapping_ping is 0.`  
Why is the length zero here and how can I fix it. I am newer to Julia and I tried reading the documentation but I didn’t know where to begin searching for this issue.

---

<div class="post-metadata">

**Author:** ![Jeff\_Emanuel](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jeff_emanuel/32/15440_2.png) [@Jeff\_Emanuel](https://discourse.julialang.org/u/Jeff_Emanuel)\
**Post date:** [April 12, 2024, 4:07pm UTC](https://discourse.julialang.org/t/maintaining-structures-across-workers/112820/2 "2024-04-12T16:07:29Z")

</div>

> [@Utkarsh\_Sharma](#):
>
> Why is the length zero here

Each process has its own `params`. You are updating the `params` only in the master process.

> [@Utkarsh\_Sharma](#):
>
> how can I fix it

Try adding `@everywhere` to the code setting `mapping_ping`.

[https://docs.julialang.org/en/v1/stdlib/Distributed/#Distributed.@everywhere](https://docs.julialang.org/en/v1/stdlib/Distributed/#Distributed.@everywhere)

> Execute an expression under `Main` on all `procs` .
