Skip to content

Commit

Permalink
add tips to optimize parallel execution. [ci skip]
Browse files Browse the repository at this point in the history
  • Loading branch information
amitmurthy committed Jun 14, 2015
1 parent d8e5d6f commit d14f7d3
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 d14f7d3

Please sign in to comment.