Performance issue in `DArray` creation when `myid()` holds a chunk
還沒有人認領這個 Issue。
評估
- 難度
- 4/5
- 預估耗時
- 3-5 天
- 新手友好度
- 35/100
- Issue 類型
- 缺陷
- 描述清晰度
- 描述清楚
- 活躍度
- 停滯
- 技術堆疊
- julia
研究方向
從 DistributedArrays.DArray 建構函式開始,使用包含 addprocs 和 init 函式的 Julia 範例重現報告中的耗時。檢查 myid() 包含在 pids 中時工作的派送方式;完成的標準是本機程序不會阻塞向其他 pids 的派送,且 benchmark 不再顯示報告中的效能下降。
由索引模型根據 Issue 內容生成。
描述
Hello,
If the pid trying to create a DArray has to do enough work, we see a slow down. The work interferes with the asynchronous dispatch of work to the other pids.
using Distributed
addprocs(2)
using DistributedArrays
# a lot of work...
@everywhere function init(I)
rr=rand(map(length,I)...)
ss=0.
for _ in 1:10
ss+=sum(rr.^2)
end
exp.(ss*exp.(rr).^3)
end
n=2000
@btime d1=DArray(init,(n,n),workers()[1:2])
@btime d1=DArray(init,(n,n),procs()[1:2])
@btime d1=DArray(init,(n,n),procs()[2:-1:1]);
126.553 ms (290 allocations: 22.45 KiB)
156.219 ms (253 allocations: 213.64 MiB)
112.563 ms (249 allocations: 213.64 MiB)
Note that in the last experiment, the same pids are included, but the pid==1 is last and the slowdown disappears (it dispatches the work to others before doing its own). Which suggests the easy fix:
@everywhere @eval DistributedArrays function DistributedArrays.DArray(id, init, dims, pids, idxs, cuts)
localtypes = Vector{DataType}(undef,length(pids))
pids=copy(pids)
ind=findfirst(isequal(myid()),pids)
if ind != nothing
pids[end],pids[ind]=pids[ind],pids[end]
end
@sync begin
for i = 1:length(pids)
@async begin
local typA
if isa(init, Function)
typA = remotecall_fetch(construct_localparts, pids[i], init, id, dims, pids, idxs, cuts)
else
# constructing from an array of remote refs.
typA = remotecall_fetch(construct_localparts, pids[i], init[i], id, dims, pids, idxs, cuts)
end
localtypes[i] = typA
end
end
end
if length(unique(localtypes)) != 1
@sync for p in pids
@async remotecall_fetch(release_localpart, p, id)
end
throw(ErrorException("Constructed localparts have different `eltype`: $(localtypes)"))
end
A = first(localtypes)
if myid() in pids
d = registry[id]
d = isa(d, WeakRef) ? d.value : d
else
T = eltype(A)
N = length(dims)
d = DArray{T,N,A}(id, dims, pids, idxs, cuts, empty_localpart(T,N,A))
end
d
end
And after the fix:
@btime d1=DArray(init,(n,n),workers()[1:2])
@btime d1=DArray(init,(n,n),procs()[1:2])
@btime d1=DArray(init,(n,n),procs()[2:-1:1]);
79.150 ms (296 allocations: 22.64 KiB)
111.481 ms (258 allocations: 213.64 MiB)
111.870 ms (258 allocations: 213.64 MiB)
Will submit a PR with the fix promptly :)
Cheers!
- 主要語言
- Julia
- 星號
- 205
- 分支
- 34
- PR 合併指標
- 30 天內沒有已合併 PR
環境準備
這個專案沒有提供開發容器、Dockerfile 或貢獻指南,環境需要你自己搭建:先看它的 README,通用步驟見我們的新手貢獻指南。
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
JuliaParallel/DistributedArrays.jl 的其他 Issue
-
難度 4/5 3-5 天 新手友好度 35/100
JuliaParallel/DistributedArrays.jl#255 · 1 個 reaction ·
-
難度 3/5 1-2 天 新手友好度 45/100
JuliaParallel/DistributedArrays.jl#239 · 1 個 reaction ·
-
難度 3/5 1-2 天 新手友好度 45/100
JuliaParallel/DistributedArrays.jl#238 · 1 則留言 ·
-
難度 4/5 3-5 天 新手友好度 35/100
-
難度 4/5 3-5 天 新手友好度 30/100
查看 JuliaParallel/DistributedArrays.jl 的全部 Issue
相似的 Issue
-
path: splitext treats directory references and leading dots as extensions可能已有人在做 @Hiten0305l 今天認領。 未關閉
難度 2/5 半天 新手友好度 72/100
維護者通常 1 天內回覆
-
難度 2/5 1-3 小時 新手友好度 72/100
JuliaParallel/Hwloc.jl#93 ·
-
難度 2/5 1-3 小時 新手友好度 74/100
維護者通常 1 天內回覆
-
難度 2/5 1-3 小時 新手友好度 68/100
SciML/SciMLBenchmarks.jl#1996 ·
維護者通常 1 天內回覆
-
Affine transformations of `JohnsonSU` could return a `JohnsonSU`可能已有人在做 @devmotion 今天認領。 未關閉
難度 2/5 1-3 小時 新手友好度 72/100
JuliaStats/Distributions.jl#2117 ·
維護者通常 2 天內回覆