tectonic
tectonic copied to clipboard
Tectonic is too slow on one of my document
Hello,
I tried using tectonic on one of my document, generated by pandoc (slides.tex), in the hope it would be faster than what pandoc uses by default (latex).
The result is waaaay slower using tectonic, which hints at a bug / problem, from my point of view. For the records:
$ time pdflatex slides.tex
[…]
real 0m4,157s
user 0m3,976s
sys 0m0,180s
$ time tectonic slides.tex
Running TeX ...
[…]
real 2m10,571s
user 1m59,683s
sys 0m10,873s
Looking at what tectonic is doing with strace, it seems stuck doing many things regarding fonts I don't use, e.g.
openat(AT_FDCWD, "/nix/store/2mv4kkdwmmbn0yyp2bbvi118afz6hz98-noto-fonts-2020-01-23/share/fonts/truetype/noto/NotoSerifLao-Light.ttf", O_RDONLY) = 6
and many
openat(AT_FDCWD, "template/map.pdf", O_RDONLY|O_CLOEXEC) = 4
log_tectonic_0.txt log_tectonic_1.txt log_tectonic_2.txt
I do have this in my .tex: \setbeamertemplate{background canvas}{ \includegraphics[width=1\paperwidth,height=1\paperheight,keepaspectratio]{template/map.pdf} }
but so many open calls seems unecessary.
I'm using tectonic on NixOS:
$ tectonic --version
Tectonic 0.8.0
I can't really provide my source file for the moment, but I can help debug if needed.
Cheers, Rémy
Hey @rgrunbla thx for the issue! 💛 In my experience XeLaTeX/LuaTeX/tectonic are going to be slower than pdfLaTeX for some scenarios, can you run the benchmark against tectonic with time latexmk -pdfxe slides.tex
?
Could you provide a benchmark file even if it's not the slides.tex
so we give it a try?
The tracing is good info, I also believe hyperfine
could give us more reliable measurements for several runs:
hyperfine --warmup 32 -i -r 8192 \
'latexmk -pdf test.tex' \
'latexmk -pdflua test.tex' \
'latexmk -pdfxe test.tex' \
'tectonic test.tex'
Not sure if it helps, but I've recently tried pdflatex
vs. tectonic
and at least in my situation:
- single page document on
pdflatex
: 0.15sec - hello world example using
tectonic
: 1.50sec
This is on Ubuntu with an AMD Ryzen 7 3700X. I'm using tectonic as a crate in my app.
These were run as rust unit tests, and the reported time is the whole test time, but that doesn't really explain the order of magnitude discrepancy. Running tectonic
multiple times didn't seem to help either, and neither did turning off the internet. To reproduce this with tectonic
, just run the hello world example from the API documentation. To reproduce the pdflatex
version, write the contents to file, then open a process:
let _p = Command::new("pdflatex")
.arg("single_page.tex")
.arg("-interaction=batchmode")
.current_dir("../tex_compilation")
.spawn()
.expect("aaa")
.wait();
I couldn't run my single page document in tectonic
as it complained of errors (probably all fixable).
I'm wondering why tectonic
happened to be so much slower. I'd have expected the hello world example to be in the miliseconds. Which is too bad for me, an in-memory latex engine is exactly what I want, this is a very good project.
I've found that often an unusually slow compilation happens when the document references a font by a symbolic name, like Times New Roman
. This forces Tectonic to scan the system fonts (using, e.g., fontconfig
on Linux), and this can take a while. If you specify fonts by a specific filename that Tectonic can load directly, like roboto-400.ttf
, the search is skipped and things can be a lot faster.
Tectonic's virtualized I/O subsystem and related infrastructure will add some overhead to compilations, too. I'd hope that that kind of thing would be at the 10s-of-percent level for large documents, but for smaller documents there's probably some additional fixed startup cost that will dominate the processing time.
Thanks for taking the time to explain.