Bug introduced in 10.0 or earlier and fixed in 11.2

Consider the following function

slowNorm[x_?(Length[#] == 3 && VectorQ[#, IntegerQ] &)] :=
  (Pause[1]; Norm[x])

An equivalent implementation is

latticePoint3DQ = (Length[#] == 3 && VectorQ[#, IntegerQ] &);
slowNormAlt[x_?latticePoint3DQ] := (Pause[1]; Norm[x])

However, only the first function can be parallelized efficiently (in both cases all subkernels are already running):

In[1]:= ParallelTable[
          slowNorm[{i, 0, 0}], {i, 1, 5}] // AbsoluteTiming

Out[1]= {2.01148, {1, 2, 3, 4, 5}}

In[2]:= ParallelTable[
          slowNormAlt[{i, 0, 0}], {i, 1, 5}] // AbsoluteTiming

Out[2]= {5.00941, {1, 2, 3, 4, 5}}

Using Condition instead of PatternTest does result in the same behavior.

Is there a way to check arguments using latticePoint3DQ without losing the ability to parallelize?

Edit: I am using Version of MMA and the Platform is Linux x86 (64-bit)

  • $\begingroup$ I am not able to reproduce this. Can you specify your M version and give even mores pecific, step by step instructions? (E.g. the above does not show when the parallel kernels are launched, which takes a considerable time.) $\endgroup$
    – Szabolcs
    Commented Apr 9, 2019 at 12:04
  • $\begingroup$ @Szabolcs Thanks, I've edited the post, I don't know if I can add anymore step by step instrucitons. $\endgroup$
    – kalix
    Commented Apr 9, 2019 at 12:10
  • $\begingroup$ I asked for step by step because I wanted to make sure that you were not timing the subkernel startup. It's irrelevant now because I can easily reproduce this in 11.1. $\endgroup$
    – Szabolcs
    Commented Apr 9, 2019 at 12:15

1 Answer 1


I can reproduce this in 11.1.1 but not in 11.2 or later. I believe that the problem is that the definitions of latticePoint3DQ are not automatically distributed (probably because symbols in PatternTest and Condition are not being considered), thus slowNormAlt effectively ends up being evaluated on the main kernel.

The fix is simple:


Update: This is very likely a problem with Language`ExtendedFullDefinition, discussed in this QA:

  • $\begingroup$ If DistributeDefinitions uses ExtendedFullDefinition then this is it: mathematica.stackexchange.com/questions/148207/… $\endgroup$
    – Kuba
    Commented Apr 9, 2019 at 12:18
  • $\begingroup$ @Kuba Very likely it's the same but I won't read the code to confirm. I suggest you mark one as duplicate of the other. $\endgroup$
    – Szabolcs
    Commented Apr 9, 2019 at 12:20
  • $\begingroup$ No need to: PrintDefinitions @ Parallel`Protected`DistDefs $\endgroup$
    – Kuba
    Commented Apr 9, 2019 at 12:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.