12

1

**Bug introduced in 10.4 and fixed in 11.0**

After updating to 10.4, many of my heavily numerical functions defined by `Compile`

takes a huge amount of time to compile to Wolfram Virtual Machine.

As an example, after running the definitions in this question to compute the dilogarithm function, observe how long it takes to compile the following function in *Mathematica* 10.4, and in previous versions (10.3 and earlier):

```
f = Compile[{{x, _Real}, {a, _Real}, {b, _Real}, {c, _Real}},
reLi2[((x - b^2 + a^2) (a^2 - c^2))/(x a^2 - (b^2 - a^2) (a^2 - c^2))] -
reLi2[-(((b^2 - a^2) (a^2 - c^2))/(x a^2 - (b^2 - a^2) (a^2 - c^2)))] +
reLi2[-(((b^2 - a^2) a^2)/(x a^2 - (b^2 - a^2) (a^2 - c^2)))] -
reLi2[-((a^2 a^2)/(x a^2 - (b^2 - a^2) (a^2 - c^2)))] +
reLi2[((x - a^2 + c^2) (c^2 - b^2))/(x c^2 - (a^2 - c^2) (c^2 - b^2))] -
reLi2[-(((a^2 - c^2) (c^2 - b^2))/(x c^2 - (a^2 - c^2) (c^2 - b^2)))] +
reLi2[-(((a^2 - c^2) c^2)/(x c^2 - (a^2 - c^2) (c^2 - b^2)))] -
reLi2[-((c^2 c^2)/(x c^2 - (a^2 - c^2) (c^2 - b^2)))] -
reLi2[((x - (a^2)^2 + (c^2)^2) ((c^2)^2 - (b^2)^2))/(x (c^2)^2 - ((a^2)^2 - (c^2)^2) ((c^2)^2 - (b^2)^2))] -
reLi2[-((((a^2)^2 - (c^2)^2) ((c^2)^2 - (b^2)^2))/(x (c^2)^2 - ((a^2)^2 - (c^2)^2) ((c^2)^2 - (b^2)^2)))] +
reLi2[-((((a^2)^2 - (c^2)^2) (c^2)^2)/(x (c^2)^2 - ((a^2)^2 - (c^2)^2) ((c^2)^2 - (b^2)^2)))] -
reLi2[-(((c^2)^2 (c^2)^2)/(x (c^2)^2 - ((a^2)^2 - (c^2)^2) ((c^2)^2 - (b^2)^2)))],
CompilationOptions -> {"InlineExternalDefinitions" -> True}]
```

My MacOS X 10.10$^†$ computer takes 3 seconds on Mathematica 10.4, and nearly instantaneous on Mathematica 9.0.1. The actual functions used in my code contains over 100 instances of `reLi2`

in the body of `Compile`

, and it takes over a minute just to compile on version 10.4.

Does anyone else observe this problem? Are there any workarounds? Setting option `"ExpressionOptimization"->False`

helps just a tad, but not nearly enough.

$^†$ *update:* I also observe the problem in Linux.

1Something spooky: when you put semicolon

`;`

at end of the command to "suppress the output" compilation goes quickly like in earlier versions. This semicolon trick does not work if this code is called from a package file. – QuantumDot – 2016-03-17T18:58:20.2771It looks like it's the typesetting that takes all the time. Try using

`SetSystemOptions["TypesetOptions" -> {"IconicElidedForms" -> False}]`

– Simon Woods – 2016-03-17T21:54:43.037@SimonWoods Thanks, this seems to solve some of the cases, but not all. In particular, if the body of the

`Compile`

is constructed using`With`

for code injection, it still performs much slower than earlier versions. – QuantumDot – 2016-03-18T08:18:25.693This problem has been reported [CASE:3559742]. – QuantumDot – 2016-03-18T21:01:22.100

Thank you for the bug report, the compilation (not the formatting) issue is under investigation. – ilian – 2016-03-18T22:32:32.237

@ilian It may not really be appropriate to ask this, but do you think you could suggest a workaround? The 90s wait for compiling a function is driving me crazy... thanks – QuantumDot – 2016-05-31T22:09:12.333

@QuantumDot Unfortunately there is no workaround for 10.4.x, however this has been fixed in version 11 (which is not too far away). Let me know if you would be interested in trying out a prerelease build. – ilian – 2016-06-01T00:58:31.670

@ilian Since I'm a package developer, I think it would be nice to get a preview of what's to come with a prerelease build. Thanks for the offer; what's the proper way to request for one? – QuantumDot – 2016-06-04T14:43:50.360

1@QuantumDot I have forwarded your contact details to our prerelease program coordinators and I hope they will be in touch soon with more information. – ilian – 2016-06-04T15:52:48.583