When the function is parallaxed, the speed drops


#1

How can I speed this code up?

function scalar_mult(k::BigInt)
....
end

function twofor(n)
    @sync @parallel for i in 1000:n for j in 10:115

                 scalar_mult(BigInt(j * ^(10,3)+i))

                 end
                 end
end

n = 9999

#compile
twofor(1020)
#run 
twofor(n)
423.467542 seconds (1.07 G allocations: 57.729 GiB, 14.20% gc time)

Will be very long,
although the scalar_mult function without a loop executes for 0.004 s

Architecture: x86_64
CPU op-mode(s): 32-bit, 64-bit
Byte Order: Little Endian
CPU(s): 2


#2

help me :pray:


#3

Providing a self-contained MWE would help (we don’t know what scalar_mult may be).

Also, please use standard indentation.