Skip to content

foreach takes foreever?

3 messages · andre zege, R. Michael Weylandt, Steve Lianoglou

#
You're probably being killed by the overhead of parallelization which
is, in this case, far more than actual computation time. I've not dug
through foreach() in a while, but I think this winds up spawning many
many subprocesses which isn't cheap in Windows.

MW
On Mon, Jan 21, 2013 at 3:59 PM, Andre Zege <azege at yahoo.com> wrote:
#
Hi,
On Mon, Jan 21, 2013 at 10:59 AM, Andre Zege <azege at yahoo.com> wrote:
You should keep reading that vignette you are working from :-)
"""
... But for the kinds of quick running operations that we?ve been
doing, there wouldn?t be much point to executing them in parallel.
Running many tiny tasks in parallel will usually take more time to
execute than running them sequentially, and if it already runs fast,
there?s no motivation to make it run faster anyway. But if the
operation that we?re executing in parallel takes a minute or longer,
there starts to be some motivation.
"""

The task you are parallelizing is too trivial. The time to coordinate
the data splitting + forking + etc. is more than just running sqrt.

When the specific task you are running within each iteration is more
involved, the benefit of parallelization will become more clear.

-steve