5

The following MWE, compiled under several situations (with appropriate lines removed) gives the following timings (with all output files removed between runs), as timed by Measure-Command on Windows 7 Powershell with TL2014:

Engine   | unicode-math?   | sisetup options             | Time
-------------------------------------------------------------------
lualatex | unicode-math    | per-mode=symbol-or-fraction | ~53 sec
lualatex | unicode-math    | per-mode=default            | ~5 sec
lualatex | no unicode-math | per-mode=symbol-or-fraction | ~2 sec
lualatex | fontspec        | per-mode=symbol-or-fraction | ~4 sec
xelatex  | unicode-math    | per-mode=symbol-or-fraction | ~4 sec
xelatex  | no unicode-math | per-mode=symbol-or-fraction | ~2 sec
pdflatex | no unicode-math | per-mode=default            | ~1 sec
pdflatex | no unicode-math | per-mode=symbol-or-fraction | ~1 sec
--------------------------------------------------------------------

Why does adding the per-mode=symbol-or-fraction with unicode-math increase the compile time by an order of magnitude in lualatex?

Binary versions:

LuaTeX, Version beta-0.79.1 (rev 4971)
XeTeX 3.14159265-2.6-0.99991
pdfTeX 3.14159265-2.6-1.40.15

\documentclass{article}
\usepackage{mathtools}
\usepackage{unicode-math}
\usepackage{siunitx}
\sisetup{
    per-mode = symbol-or-fraction,
}
\begin{document}
\begin{align*}
\text{at $p=\SI{1.0}{\MPa}$:}\begin{cases}
v(T) &= v_1 + \left(T - T_1\right)\frac{v_2 - v_1}{T_2 - T_1} \\
v(\SI{220}{\degreeCelsius}) &= \SI{0.2060}{\meter\cubed\per\kilogram} + \left(\SI{220}{\degreeCelsius} - \SI{200}{\degreeCelsius}\right) \frac{\SI{0.2275}{\meter\cubed\per\kilogram} - \SI{0.2060}{\meter\cubed\per\kilogram}}{\SI{240}{\degreeCelsius} - \SI{200}{\degreeCelsius}} \\
v(\SI{220}{\degreeCelsius}) &= \SI{0.21675}{\meter\cubed\per\kilogram}
\end{cases}\\
\text{at $p=\SI{1.5}{\MPa}$:}\begin{cases}
v(T) &= v_1 + \left(T - T_1\right)\frac{v_2 - v_1}{T_2 - T_1} \\
v(\SI{220}{\degreeCelsius}) &= \SI{0.1325}{\meter\cubed\per\kilogram} + \left(\SI{220}{\degreeCelsius} - \SI{200}{\degreeCelsius}\right) \frac{\SI{0.1483}{\meter\cubed\per\kilogram} - \SI{0.1325}{\meter\cubed\per\kilogram}}{\SI{240}{\degreeCelsius} - \SI{200}{\degreeCelsius}} \\
v(\SI{220}{\degreeCelsius}) &= \SI{0.1404}{\meter\cubed\per\kilogram}
\end{cases}\\
\text{at $T=\SI{220}{\degreeCelsius}$:}\begin{cases}
v(p) &= v_1 + \left(p - p_1\right)\frac{v_2 - v_1}{p_2 - p_1} \\
v(\SI{1.4}{\MPa}) &= \SI{0.21675}{\meter\cubed\per\kilogram} + \left(\SI{1.4}{\MPa} - \SI{1.0}{\MPa}\right) \frac{\SI{0.1404}{\meter\cubed\per\kilogram} - \SI{0.21675}{\meter\cubed\per\kilogram}}{\SI{1.5}{\MPa} - \SI{1.0}{\MPa}} \\
v(\SI{1.4}{\MPa}) &= \SI{0.1557}{\meter\cubed\per\kilogram}
\end{cases}
\end{align*}
\end{document}

closed as too broad by Moriambar, TeXnician, CarLaTeX, Stefan Kottwitz Jun 11 '17 at 10:00

Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer. Avoid asking multiple distinct questions at once. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

  • 2
    Hmmm, I have LuaTeX 0.79.1 as well, running on an early-2014 MacBookPro model with a 2.8 GHz Corei7 CPU and with OSX 10.10.2. With the unicode-math package loaded, I get a compile time of between 5 and 6 seconds with the per-mode=symbol-or-fraction set. Without that option, it takes between 1 and 2 seconds to compile. – Mico Feb 5 '15 at 20:40
  • @Mico I have an unknown year Dell Optiplex 9010 with a Core i7 at 3.4 GHz and 8 GB RAM. I guess you don't see the order of magnitude, but its still a factor of 5. Seems strange! – darthbith Feb 5 '15 at 20:54
  • 2
    I can confirm that the difference in speed with/without per-mode=symbol-or-fraction is dramatic. – Ulrike Fischer Feb 6 '15 at 10:48
  • 1
    There are some performance issues which are really beyond my control (I have looked for anything obvious at my end). Here, the thing to remember is that doing this sort of 'auto-detection' uses \mathchoice, so typesets everything four times (display, text, script, scriptscript). – Joseph Wright Feb 6 '15 at 19:09
  • @JosephWright Thanks for looking! Based on some reading I've done (that I'm not sure is relevant), it may be due to font loading in lualatex: tug.org/pipermail/luatex/2013-March/004114.html If lualatex loads fonts for each of the required sizes, that might take a long time... – darthbith Feb 6 '15 at 19:36