2

I am trying to create a binary dump format for sped up compile times with luahbtex -ini and mylatexformat.

However, depending on certain packages being loaded, I get an error I can't make sense of.

In my personal research, this is a follow-up development on https://tex.stackexchange.com/a/690435/53868, but needs to be investigated on its own.

Setup

I am running

$ tex --version
TeX 3.141592653 (TeX Live 2023)

mwe.tex

\documentclass[UKenglish]{scrbook}

\usepackage{babel} \usepackage{lipsum}

% \usepackage{pgfplots} % \usepackage{amsmath} % \usepackage{siunitx} % \usepackage{geometry}

\begin{document} \title{Lualatex Binary Dumping} \subtitle{Is dumping with lualatex dumb?} \subject{Case Studies} \date{\today} \maketitle{}

\lipsum[1-20]

\end{document}

commands to run

luahbtex  -ini "&lualatex" mylatexformat.ltx mwe

Expected behaviour

A binary dump mwe.fmt is created alongside the m mwe.tex file, which then can be used in further lualatex runs:

lualatex -fmt=mwe mwe

Observed behaviour

  • Running the commands from section Setup on file mwe.tex produces the error message
    (/usr/local/texlive/2023/texmf-dist/tex/latex/l3backend/l3backend- 
    luatex.def)))
    ! Use of \??? doesn't match its definition.
    <argument> \???  
          ! LaTeX Error: Access to an entry beyond an array's bounds.
    l.208   }
    

    ? ! Emergency stop. <argument> ???
    ! LaTeX Error: Access to an entry beyond an array's bounds. l.208 }

    while commenting out the line
    % \usepackage{lipsum}
    

    makes the binary dumping process run through without error. The issue seems related to lipsum or l3backend-luatex.

  • The mwe compiles fine with just lualatex mwe.tex, so the issue is not a general incompatibility between lualatex and lipsum.
  • Commenting in other packages, which use latex3 has the memory dump also run sucessfully.

Question

I just happened to notice this behaviour with the lualatex package, and I do not understand it. I do not care so much for the lualatex package, but I want to understand what is happening there, as the same problem could arise with other packages I want to use in the future. Thus, my questions are:

  • Is this a bug exclusively with lipsum and luahbtex or
  • is this behaviour rooted more deeply?
  • What is going wrong here anyway, and how can I improve my debugging skills for error messages like this?
  • Should I continue considering creating luahbtex formats files, or is the process too error-prone in general?
marc
  • 701
  • 1
    you can not dump opentype fonts or Lua state so dumping lualatex is tricky you have to trap any lua that would be loaded (eg in l3 backend) and arrange that is re-loaded (or byte compiled and re-executed) in \everyjob when the new format is used. – David Carlisle Jul 12 '23 at 09:51
  • So, keeping in mind that my users are going to load their own additional packages, it is futile to try the format dumping according to @DavidCarlisle 's comment, right? There is no way of automating that with reasonable effort? – marc Jul 12 '23 at 10:16
  • 2
    I tried before but catching a random \directlua in some package and re-instating everything in the right order is tricky, adapting any particular package to work here isn't that hard but a general solution that will catch any package with no package-specific changes is hard (and as far as I know, has not been done) – David Carlisle Jul 12 '23 at 10:34
  • 2
    if for example you use fontspec and specify an opentype font then dump, all the "tex side" of the font setup is dumped but the font is not, so in \everyjob you need to reload the font (without re-doing all the tex setup and getting errors from already defined commands) doing that without specific knowledge of fontspec isn't really possible.or you modify so that \setmainfont and friends delay all their setup till atbegindocument so they do nothing in the dumped format and act in the document, but if you delay everything, then you get no speed benefit from dumping a custom format – David Carlisle Jul 12 '23 at 10:38
  • Thank you very much for the insight. I will abandon this pursuit and accept reloading packages between runs. – marc Jul 12 '23 at 13:24

0 Answers0