Skip to content

Commit 72c4440

Browse files
authored
Improve inference for a few Distributed operations (#37089)
1 parent cf21dc7 commit 72c4440

File tree

3 files changed

+14
-11
lines changed

3 files changed

+14
-11
lines changed

src/managers.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -268,6 +268,7 @@ end
268268

269269

270270
function manage(manager::SSHManager, id::Integer, config::WorkerConfig, op::Symbol)
271+
id = Int(id)
271272
if op === :interrupt
272273
ospid = config.ospid
273274
if ospid !== nothing

src/pmap.jl

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -213,15 +213,17 @@ function process_batch_errors!(p, f, results, on_error, retry_delays, retry_chec
213213
exceptions = [x.ex for x in errors]
214214
state = iterate(retry_delays)
215215
state !== nothing && (state = state[2])
216-
if (length(retry_delays) > 0) &&
217-
(retry_check === nothing || all([retry_check(state,ex)[2] for ex in exceptions]))
218-
# BatchProcessingError.data is a tuple of original args
219-
error_processed = pmap(x->f(x...), p, [x.data for x in errors];
220-
on_error = on_error, retry_delays = collect(retry_delays)[2:end], retry_check = retry_check)
221-
elseif on_error !== nothing
222-
error_processed = map(on_error, exceptions)
223-
else
224-
throw(CompositeException(exceptions))
216+
error_processed = let state=state
217+
if (length(retry_delays)::Int > 0) &&
218+
(retry_check === nothing || all([retry_check(state,ex)[2] for ex in exceptions]))
219+
# BatchProcessingError.data is a tuple of original args
220+
pmap(x->f(x...), p, [x.data for x in errors];
221+
on_error = on_error, retry_delays = collect(retry_delays)[2:end::Int], retry_check = retry_check)
222+
elseif on_error !== nothing
223+
map(on_error, exceptions)
224+
else
225+
throw(CompositeException(exceptions))
226+
end
225227
end
226228

227229
for (idx, v) in enumerate(error_processed)

src/workerpool.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,12 +130,12 @@ end
130130
# NOTE: remotecall_fetch does it automatically, but this will be more efficient as
131131
# it avoids the overhead associated with a local remotecall.
132132

133-
for func = (:length, :isready, :workers, :nworkers, :take!)
133+
for (func, rt) = ((:length, Int), (:isready, Bool), (:workers, Vector{Int}), (:nworkers, Int), (:take!, Int))
134134
func_local = Symbol(string("wp_local_", func))
135135
@eval begin
136136
function ($func)(pool::WorkerPool)
137137
if pool.ref.where != myid()
138-
return remotecall_fetch(ref->($func_local)(fetch(ref).value), pool.ref.where, pool.ref)
138+
return remotecall_fetch(ref->($func_local)(fetch(ref).value), pool.ref.where, pool.ref)::$rt
139139
else
140140
return ($func_local)(pool)
141141
end

0 commit comments

Comments
 (0)