# While compiling expl3-code.tex takes more time than the others

What does expl3-code.tex do and why does it take longer than the others to load in LuaLaTeX. Can it be avoided.

("C:/Program Files/MiKTeX 2.9/tex/latex/l3kernel/expl3-code.tex")

MWE :

\documentclass[11pt]{book}
\RequirePackage{luatex85}
\usepackage[paperwidth=142mm,paperheight=210mm,top=25mm,bottom=20mm,left=17mm,right=22mm]{geometry}
%\usepackage{fontspec}
\usepackage{fancyhdr}
\usepackage{graphicx}
\usepackage{chngcntr}
\usepackage{tocloft}
\usepackage{charter}
\usepackage{polyglossia}

\begin{document}
test
\end{document}


What calls it ..

• The file has 23000 lines. That's quite a lot. If you want to see what it does: Open it in your editor and study the code ;-). – Ulrike Fischer Oct 18 '17 at 17:31
• No thank you. What does it do. It seems to be called by fontspec. I tried putting it in comment, but it's still loaded. – alfred Oct 18 '17 at 22:55
• I have to ask how long is it taking to load? Typically on a modern system you are looking at less than a second per file ... – Joseph Wright Oct 19 '17 at 7:12
• @JosephWright In miktex there is a noticable pause when expl3-code is read. I already wondered a bit about it and now compared with texlive which is much faster. I think I will ask Christian about it. – Ulrike Fischer Oct 19 '17 at 8:12
• I raised an issue in the miktex tracker github.com/MiKTeX/miktex/issues/22, and according to the comment there was at least a problem with a double file look-up. – Ulrike Fischer Oct 20 '17 at 8:04

polyglossia loads fontspec which loads expl3 which loads expl3-code.tex.

texdoc expl3 will tell you all about expl3. It is part of the LaTeX3 kernel and is a set of programming conventions and tools for writing more complex packages. Or something like that.

The terminal output of lualatex tells you the order in which packages are loaded and which package loads what.

I've trimmed this to show what happens in the preamble (more is loaded by the class file before this, and after this by hooks at the beginning of the document). I've also added some indents to this output so you can see more clearly which package is loaded when and by what.

(/usr/share/texlive/texmf-dist/tex/generic/luatex85/luatex85.sty)
(/usr/share/texlive/texmf-dist/tex/latex/geometry/geometry.sty
(/usr/share/texlive/texmf-dist/tex/latex/graphics/keyval.sty)
(/usr/share/texlive/texmf-dist/tex/generic/oberdiek/ifpdf.sty)
(/usr/share/texlive/texmf-dist/tex/generic/oberdiek/ifvtex.sty)
(/usr/share/texlive/texmf-dist/tex/generic/ifxetex/ifxetex.sty)
(/home/dcpurton/texmf/tex/latex/geometry/geometry.cfg))
(/usr/share/texlive/texmf-dist/tex/latex/fancyhdr/fancyhdr.sty)
(/usr/share/texlive/texmf-dist/tex/latex/graphics/graphicx.sty
(/usr/share/texlive/texmf-dist/tex/latex/graphics/graphics.sty
(/usr/share/texlive/texmf-dist/tex/latex/graphics/trig.sty)
(/usr/share/texlive/texmf-dist/tex/latex/graphics-cfg/graphics.cfg)
(/usr/share/texlive/texmf-dist/tex/latex/graphics-def/luatex.def)))
(/usr/share/texlive/texmf-dist/tex/latex/chngcntr/chngcntr.sty)
(/usr/share/texlive/texmf-dist/tex/latex/tocloft/tocloft.sty)
(/usr/share/texlive/texmf-dist/tex/latex/psnfss/charter.sty)
(/usr/share/texlive/texmf-dist/tex/latex/polyglossia/polyglossia.sty
(/usr/share/texlive/texmf-dist/tex/latex/etoolbox/etoolbox.sty)
(/usr/share/texlive/texmf-dist/tex/latex/makecmds/makecmds.sty)
(/usr/share/texlive/texmf-dist/tex/latex/xkeyval/xkeyval.sty
(/usr/share/texlive/texmf-dist/tex/generic/xkeyval/xkeyval.tex
(/usr/share/texlive/texmf-dist/tex/generic/xkeyval/xkvutils.tex)))
(/usr/share/texlive/texmf-dist/tex/latex/fontspec/fontspec.sty
(/usr/share/texlive/texmf-dist/tex/latex/l3kernel/expl3.sty
(/usr/share/texlive/texmf-dist/tex/latex/l3kernel/expl3-code.tex)
(/usr/share/texlive/texmf-dist/tex/latex/l3kernel/l3pdfmode.def))
(/usr/share/texlive/texmf-dist/tex/latex/l3packages/xparse/xparse.sty)
(/usr/share/texlive/texmf-dist/tex/latex/fontspec/fontspec-luatex.sty
(/usr/share/texlive/texmf-dist/tex/latex/base/fontenc.sty
(/usr/share/texlive/texmf-dist/tex/latex/base/tuenc.def))
(/usr/share/texlive/texmf-dist/tex/latex/fontspec/fontspec.cfg)
(/usr/share/texlive/texmf-dist/tex/generic/oberdiek/ifluatex.sty)
(/usr/share/texlive/texmf-dist/tex/luatex/luatexbase/luatexbase.sty
(/usr/share/texlive/texmf-dist/tex/luatex/ctablestack/ctablestack.sty)))


Here's the number of lines in each file, which probably gives a good indication of why expl3-code.tex is slow to process compared to the others (as noted in the comments above by Ulrike).

On my machine (mid 2014 Macbook Air running Linux), your MWE takes just over a second to run. If I remove the polyglossia package, the time drops to just under 0.4 seconds.

122   /usr/share/texlive/texmf-dist/tex/generic/luatex85/luatex85.sty
1130  /usr/share/texlive/texmf-dist/tex/latex/geometry/geometry.sty
87    /usr/share/texlive/texmf-dist/tex/latex/graphics/keyval.sty
49    /usr/share/texlive/texmf-dist/tex/generic/oberdiek/ifpdf.sty
261   /usr/share/texlive/texmf-dist/tex/generic/oberdiek/ifvtex.sty
50    /usr/share/texlive/texmf-dist/tex/generic/ifxetex/ifxetex.sty
236   /usr/share/texlive/texmf-dist/tex/latex/fancyhdr/fancyhdr.sty
276   /usr/share/texlive/texmf-dist/tex/latex/graphics/graphicx.sty
521   /usr/share/texlive/texmf-dist/tex/latex/graphics/graphics.sty
117   /usr/share/texlive/texmf-dist/tex/latex/graphics/trig.sty
61    /usr/share/texlive/texmf-dist/tex/latex/graphics-cfg/graphics.cfg
581   /usr/share/texlive/texmf-dist/tex/latex/graphics-def/luatex.def
110   /usr/share/texlive/texmf-dist/tex/latex/chngcntr/chngcntr.sty
1151  /usr/share/texlive/texmf-dist/tex/latex/tocloft/tocloft.sty
31    /usr/share/texlive/texmf-dist/tex/latex/psnfss/charter.sty
871   /usr/share/texlive/texmf-dist/tex/latex/polyglossia/polyglossia.sty
1755  /usr/share/texlive/texmf-dist/tex/latex/etoolbox/etoolbox.sty
95    /usr/share/texlive/texmf-dist/tex/latex/makecmds/makecmds.sty
152   /usr/share/texlive/texmf-dist/tex/latex/xkeyval/xkeyval.sty
622   /usr/share/texlive/texmf-dist/tex/generic/xkeyval/xkeyval.tex
271   /usr/share/texlive/texmf-dist/tex/generic/xkeyval/xkvutils.tex
41    /usr/share/texlive/texmf-dist/tex/latex/fontspec/fontspec.sty
326   /usr/share/texlive/texmf-dist/tex/latex/l3kernel/expl3.sty
23763 /usr/share/texlive/texmf-dist/tex/latex/l3kernel/expl3-code.tex
442   /usr/share/texlive/texmf-dist/tex/latex/l3kernel/l3pdfmode.def
2174  /usr/share/texlive/texmf-dist/tex/latex/l3packages/xparse/xparse.sty
3758  /usr/share/texlive/texmf-dist/tex/latex/fontspec/fontspec-luatex.sty
113   /usr/share/texlive/texmf-dist/tex/latex/base/fontenc.sty
518   /usr/share/texlive/texmf-dist/tex/latex/base/tuenc.def
22    /usr/share/texlive/texmf-dist/tex/latex/fontspec/fontspec.cfg
265   /usr/share/texlive/texmf-dist/tex/generic/oberdiek/ifluatex.sty
301   /usr/share/texlive/texmf-dist/tex/luatex/luatexbase/luatexbase.sty
59    /usr/share/texlive/texmf-dist/tex/luatex/ctablestack/ctablestack.sty