ontarget-ridofjit.tex /size: 4488 b    last modification: 2024-01-16 10:21
1% language=us runpath=texruns:manuals/ontarget
2
3\startcomponent ontarget-dk
4
5\environment ontarget-style
6
7\startchapter[title={Getting rid of jit}]
8
9At the \NTG\ meeting there was a short discussion about performance of the
10\OPENTYPE\ font machinery. Currently we still support \LUAJITTEX\ and although
11the \MKIV\ code base is mostly separated from the \LMTX\ one there is still some
12compromise going on, as some \LUA\ code is shared and needs to adapt to the fact
13that \LUAJIT\ is stuck to \LUA 5.2 (sort of). One reason why we still support
14\LUAJITTEX\ is that there are users who like the performance gain. However, if
15these can switch to \CONTEXT\ we could get rid of \LUAJITTEX\ support. After all,
16\LUAJIT\ is stalled as is \FFI. Of course a plain \TEX\ users can object to using
17\CONTEXT\ but one can just use the basics and be as plain as possible.
18
19Performance of \LUAMETATEX\ is quite okay and it often performs better than
20\LUATEX\ or even \LUAJITTEX. One border case is for instance the somewhat
21overdone in terms of split feature steps is the Brill font. So, I decided to do
22some tests on my 2017 laptop that had replaced the 2013 one (Windows 10). We use
23cross compiled binaries. Here is the test:
24
25\starttyping
26% \enableexperiments[fonts.compact]
27
28\definefont[Fa][brill*default    @ 10pt]
29\definefont[Fb][brill*default    @ 12pt]
30\definefont[Fc][brill-bf*default @ 10pt]
31\definefont[Fd][brill-bf*default @ 12pt]
32
33\start \testfeatureonce{1000}{
34    \Fa \samplefile{tufte}       \samplefile{tufte}\par
35}\stop \page \edef\TimeA{\elapsedtime}
36\start \testfeatureonce{1000}{
37    \Fa \samplefile{tufte}\par\Fb\samplefile{tufte}\par
38}\stop \page \edef\TimeB{\elapsedtime}
39\start \testfeatureonce{1000}{
40    \Fa \samplefile{tufte}    \Fb\samplefile{tufte}\par
41}\stop \page \edef\TimeC{\elapsedtime}
42\start \testfeatureonce{1000}{
43    \Fa \samplefile{tufte}    \Fd\samplefile{tufte}\par
44    \Fb \samplefile{tufte}    \Fc\samplefile{tufte}\par
45}\stop \page \edef\TimeD{\elapsedtime}
46
47\startTEXpage[offset=10pt]
48    \strut\infofont
49    2 par 1 font : \TimeA\par
50    2 par 2 font : \TimeB\par
51    1 par 2 font : \TimeC\par
52    1 par 4 font : \TimeD\par
53\stopTEXpage
54\stoptyping
55
56The next table shows the best times from three tests where each one produces 1693
57pages in the default layout. We're talking of one run as normally \CONTEXT\ will
58run till a two pass stable state is reached (unless it is forced to one run),
59although in practice fixing a few typos will not for an extra run. Keep in mind
60that in \LUAMETATEX\ we have a \LUA\ driven backend that is more flexible with
61respect to fonts but therefore also adds some extra overhead. Also keep in mind
62that four different fonts per paragraph is a rare case.
63
64\starttabulate[|lT|c|c|c|c|]
65\NC
66    \BC 2 pars 1 font
67    \BC 2 pars 2 fonts
68    \BC 1 par 2 fonts
69    \BC 1 par 4 fonts
70\NC \NR
71\ML
72\BC luametatex         \NC  8.9 \NC  9.4 \NC 12.1 \NC 24.6 \NC \NR
73\BC luametatex compact \NC  8.9 \NC  9.3 \NC  9.3 \NC 23.9 \NC \NR
74\BC luatex             \NC 10.0 \NC 10.3 \NC 14.5 \NC 31.2 \NC \NR
75\BC luajittex          \NC  8.0 \NC  8.1 \NC 11.4 \NC 23.2 \NC \NR
76\stoptabulate
77
78One should take these measurements with a grain of salt because it also depends
79on the system load, but it shows that there is no real need to favor a
80\LUAJITTEX\ setup over a \LUAMETATEX\ one. In the meantime the default \LUATEX\
81binaries exceed 7~MB (and the hb variant adds quite a bit more) which
82\LUAMETATEX\ stays around 3~MB which is nice for high performance setups with
83thousands of (small) runs.
84
85Just for the record, when we use Dejavu Serif we get 2767 pages and the following
86timings. Again, the differences between \LUAMETATEX\ and \LUAJITTEX\ is not that
87significant, especially when you realize that we're not doing anything fancy that
88more runtime. In practice fonts are only part of the story.
89
90\starttabulate[|lT|c|c|c|c|]
91\NC
92    \BC 2 pars 1 font
93    \BC 2 pars 2 fonts
94    \BC 1 par 2 fonts
95    \BC 1 par 4 fonts
96\NC \NR
97\ML
98\BC luametatex         \NC 4.2 \NC 4.4 \NC 5.0 \NC 10.8 \NC \NR
99\BC luametatex compact \NC 4.2 \NC 4.5 \NC 4.5 \NC 10.5 \NC \NR
100\BC luatex             \NC 4.9 \NC 5.0 \NC 6.2 \NC 13.3 \NC \NR
101\BC luajittex          \NC 4.0 \NC 4.0 \NC 5.0 \NC 10.3 \NC \NR
102\stoptabulate
103
104% I tried to run \XETEX\ on the same file but that failed for some reason (it looks
105% like it got stuck in updating the font database; some 50~MB binaries are needed
106% so I guess I messed up somewhere).
107
108\stopchapter
109
110\stopcomponent
111
112