[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#1070150: Loading of expl3.ltx **extremely** slow on emulated runs



Hi Norbert,

On Thu, 2024-05-02 at 17:44 +0900, Norbert Preining wrote:
> sorry, but I don't understand!!
>
> On Wed, 01 May 2024, Max Chernoff wrote:
> > I don't think that this is TeX-related. From a Fedora 39 x86_64 host:
>
> Your data:
>
> >     $ podman run --arch arm64 --rm -it --pull always debian:stable /bin/bash
> [...]
> >     real	0m52.253s
>
>
> >     $ podman run --arch arm64 --rm --pull always -it debian:sid /bin/bash
> [...]
> >     real	3m52.398s
>
> That is a 4 times increase, ok, this does a lot of things. IN
> particular, apt uses fsync a lot.

I noticed that everything seemed much slower when trying to install the
TeX in the container, so I thought that it might be that the entire
system is slower, not just TeX.

> But what I measured in the emails is *only* the loading of one text
> file, without IO ops.

There's quite a bit of IO. From my host system:

   $ sudo strace -ffe read fmtutil-sys --byfmt lualatex 2>&1 | wc -l
   21440

But I've done some further testing, and my initial guess was completely
wrong (sorry). This *does* appear to be an issue particular to the
Debian TeX binaries. Using the attached file "factorial.tex" (you can
change the "10000" inside the file to "1000" if you're impatient), on my
host system I get:

   $ time luatex --ini ./factorial.tex
   This is LuaTeX, Version 1.17.0 (TeX Live 2023)  (INITEX)
    restricted system commands enabled.
   (./factorial.tex)
   No pages of output.
   Transcript written on factorial.log.

   real    0m3.952s
   user    0m3.921s
   sys     0m0.030s

and inside an arm64 sid container I get:

   $ apt install --no-install-recommends texlive-binaries
   $ wget 'https://ftp.math.utah.edu/pub/tex/historic/systems/texlive/2023/tlnet-final/archive/luatex.aarch64-linux.tar.xz'
   $ tar xf luatex.aarch64-linux.tar.xz
   $ cd bin/aarch64-linux

   $ time luatex --ini ~/factorial.tex
   This is LuaTeX, Version 1.17.0 (TeX Live 2023/Debian)  (INITEX)
   (/root/factorial.tex)
   No pages of output.
   Transcript written on factorial.log.

   real	17m49.488s
   user	17m49.395s
   sys	0m0.016s

   $ time ./luatex --ini ~/factorial.tex
   warning: kpathsea: configuration file texmf.cnf not found [...]
   This is LuaTeX, Version 1.17.0 (TeX Live 2023)  (INITEX)
   (/root/factorial.tex)
   No pages of output.
   Transcript written on factorial.log.

   real	0m42.353s
   user	0m42.319s
   sys	0m0.021s

Last year, there was a similar problem where the main TeX Live LuaTeX
binaries were compiled with full debug symbols, but that was a ~50%
slowdown, not a 25x slowdown. See the thread starting at

   https://tug.org/pipermail/luatex/2023-August/007853.html

or some more detailed benchmarks at

   https://tug.org/pipermail/luatex/2023-August/007875.html
   https://tug.org/pipermail/luatex/2023-August/007864.html

Looking through the build logs

   https://tests.reproducible-builds.org/debian/rbuild/unstable/amd64/texlive-bin_2023.20230311.66589-9.rbuild.log.gz

it looks like the LuaTeX binaries were compiled with "-g -O2", but
running "readelf" and "objdump" shows that they're stripped, so I don't
think that that's the issue here.

And this issue appears to affect all engines: I also tried testing with
pdfTeX (comment out the \directlua line, and add the --etex command line
flag), and for 1000 iterations I got:

   Debian Sid    arm64  LuaTeX: 0m15.392s
   Debian Sid    arm64  pdfTeX: 0m7.914s
   TeX Live 2023 arm64  LuaTeX: 0m0.737s
   TeX Live 2023 x86_64 pdfTeX: 0m0.156s
   TeX Live 2023 x86_64 LuaTeX: 0m0.156s

I'm not sure what's going on here, but hopefully this gives you some
clues.

Thanks,
-- Max
\catcode`\{=1
\catcode`\}=2
\catcode`\#=6

\directlua{tex.enableprimitives("", tex.extraprimitives("etex"))}

\def\factorial#1{%
    \ifnum#1=0
        1%
    \else%
        \numexpr\factorial{\numexpr#1 - 1\relax} * #1\relax%
    \fi%
}


\def\loop#1\repeat{\def\body{#1}\iterate}
\def\iterate{\body \let\next=\iterate \else\let\next=\relax\fi \next}
\let\repeat=\fi

\def\out{}
\countdef\n=0

\loop\ifnum\n<10000
    \edef\out{\out \the\factorial{12}}
    \advance\n by 1
\repeat

\end

Reply to: