Skip to content

Commit

Permalink
Merge pull request #11706 from JuliaLang/amitm/async_doc
Browse files Browse the repository at this point in the history
add tips to optimize parallel execution. [ci skip]
  • Loading branch information
ViralBShah committed Jun 14, 2015
2 parents 21be6ab + d14f7d3 commit 1356899
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions doc/manual/performance-tips.rst
Original file line number Diff line number Diff line change
Expand Up @@ -533,6 +533,32 @@ versus::
println(file, f(a), f(b))


Optimize network I/O during parallel execution
----------------------------------------------

When executing a remote function in parallel::

responses = cell(nworkers())
@sync begin
for (idx, pid) in enumerate(workers())
@async responses[idx] = remotecall_fetch(pid, foo, args...)
end
end

is faster than::

refs = cell(nworkers())
for (idx, pid) in enumerate(workers())
refs[idx] = @spawnat pid foo(args...)
end
responses = [fetch(r) for r in refs]

The former results in a single network round-trip to every worker, while the
latter results in two network calls - first by the ``@spawnat`` and the
second due to the ``fetch`` (or even a ``wait``). The ``fetch``/``wait``
is also being executed serially resulting in an overall poorer performance.


Fix deprecation warnings
------------------------

Expand Down

0 comments on commit 1356899

Please sign in to comment.