JuliaLang / JuliaLang/Distributed.jl

Showing SharedArray objects in a different host causes confusion.

Open
#55 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Julia
Stars
55
Forks
19
PR merge metrics
No merged PRs in 30d

Description

First, see the code below.

julia> pid = addprocs(["different_hostaddress_from_current"])[1]
julia> sa1 = @fetchfrom pid SharedArray( rand(4, 4) )
4×4 SharedArray{Float64,2}:
sa[ 0.588949  0.0481939  0.266658  0.542195
 0.162783  0.771512   0.812162  0.981772
 0.704765  0.325396   0.656134  0.469057
 0.326197  0.727144   0.696665  0.653014
julia> show(sa1)
[0.588949 0.0481939 0.266658 0.542195; 0.162783 0.771512 0.812162 0.981772; 0.704765 0.325396 0.656134 0.469057; 0.326197 0.727144 0.696665 0.653014]
julia> sa1[1,1]
0.0  # this is a trash value.
julia> sdata(sa)
0×0 Array{Float64,2}
# in reverse
julia> sa2 = SharedArray( (rand(4, 4) )
4×4 SharedArray{Float64,2}:
 0.913975  0.65263   0.388948  0.695337
 0.942663  0.251198  0.233023  0.376158
 0.539025  0.743089  0.612239  0.329394
 0.783334  0.425041  0.67182   0.381703
julia> @fetchfrom pid show(sa2)
julia> @fetchfrom pid println()
From worker 2:  [0.913975 0.65263 0.388948 0.695337; 0.942663 0.251198 0.233023 0.376158; 0.539025 0.743089 0.612239 0.329394; 0.783334 0.425041 0.67182 0.381703]
julia> @fetchfrom pid show(sa2[1,1])
julia> @fetchfrom pid println()
From worker 2:  0.0

I understood the intention.
show function is implemented as below
show(io, remotecall_fetch(sharr->sharr.s, S.pids[1], S))
This function actually shows the values in the different computer.
But, users may make a mistake that the variable sa in the current node has the values.

I think this should be documented or modified in a different way to avoid mistakes.
Because I suffered from this problem.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

The issue points to the SharedArray show implementation, which fetches data from sharr.s on S.pids[1]. Start there and reproduce the two cross-host examples to understand what local object state is available. Done should be a documented or changed display that clearly distinguishes remote values from local storage, with the examples no longer misleading.

Written by the indexing model from the issue text.

Assessment

Tech stack
julia
Domain
distributed-systems
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.