Why does DistributeDefinitions
take so long to distribute variables that are 100-300 Mb in size?
I am setting up ParallelTable
to compute values with a very high precision on a dual-core machine with 16 GB RAM. The precision range in the table is variable so I pass to the Kernels, constants like Log[2]
and Log[10]
with the upper range of precision, 100 million for example, and then just SetPrecision
to the desired (lower) working precision to reduce execution time. I'm surprised this takes so long to distribute the definitions considering this is being done in RAM. Below is a sample of what I'm trying to do. The constants myLog2=Log[2]
and myLog10=Log[10]
are first computed to 100 million digits of precision.
I was wondering if I'm not setting up the kernels correctly or if there is a way to speed up the process. Note if I do not use DistributeDefinitions
, the kernels seem to do this automatically and take just as long and I need to distribute more than just the two in the example below.
LaunchKernels[]; $KernelCount
AbsoluteTiming[
DistributeDefinitions[myLog2, myLog10];
]
2
{218.259, Null}
Now ParallelTable
executes quickly:
(*
time using DistriburteDefinitions[myLog2, myLog10]
*)
AbsoluteTiming[theTable = ParallelTable[
val1 = SetPrecision[myLog2, 5000000];
val2 = SetPrecision[myLog10, 5000000];
val3 = val1 val2;
val3,
{n, 1, 2}];]
{2.91649, Null}