I use mclapply for all my "embarassingly parallel" computations. I find it clean and easy to use, and when arguments mc.cores = 1
and mc.preschedule = TRUE
I can insert browser()
in the function inside mclapply
and debug line by line just like in regular R. This is a huge help in getting code to production quicker.
What does foreach
offer that mclapply
does not? Is there a reason I should consider writing foreach code going forward?
If I understand correctly, both can use the multicore
approach to parallel computations (permitting forking) which I like to use for performance reasons.
I have seen foreach
being used in various packages, and have read the basics of it, but frankly I don't find it as easy to use. I also am unable to figure out how to get the browser()
to work in foreach
function calls. (yes I have read this thread browser mode with foreach %dopar% but didn't help me to get the browser to work right).