Why in the following Julia code the parallel implementation runs slower than the serial?
using Distributed
@everywhere function ext(i::Int64)
callmop = `awk '{ sum += $1 } END { print sum }' infile_$(i)`
run(callmop)
end
function fpar()
@sync @distributed for i = 1:10
ext(i)
end
end
function fnopar()
for i = 1:10
ext(i)
end
end
val, t_par, bytes, gctime, memallocs = @timed fpar()
val, t_nopar, bytes, gctime, memallocs = @timed fnopar()
println("Parallel: $(t_par) s. Serial: $(t_nopar) s")
# Parallel: 0.448290379 s. Serial: 0.028704802 s
The files infile_$(i)
contain a single column of real numbers. After some research I bumped into this post and this other post) that deal with similar problems. They seem a bit dated though, if one considers the speed at which Julia is been developed. Is there any way to improve this parallel section? Thank you very much in advance.