One of my biggest problems with LaTeX is the speed that it takes to process large documents. (I typeset books with LaTeX.) I have approaches, such as breaking the book into chapters and running them independently. But the results are not satisfactory.
For example, the book I'm currently working on reports this after I run LaTeX:
Latexmk: All targets () are up-to-date
make 74.57s user 1.92s system 99% cpu 1:17.05 total
My computer has six cores! LaTeX uses one.
Details of my system:
- MacMini (2018) 3 Ghz 6-Core Intel Core i5 Processor, 32 GB 2667 MHz DDR4 RAM
.texinput files, total of 11,000 lines of LaTeX source, over 100,000 words of text.
- Moved to xelatex due to Unicode issues, but
pdflatextook roughly the same period of time.
- 69 included packages
- Book typesets to 326 pages currently, will typeset to 500 at completion of project.
- 72 images, most in the neighborhood of 20-50k.
- Output logfile is 5611 lines long (!)
- Still using
biberbreaks, and I can't debug it. But using
biblatex, at least.
- Compiling with
- Multiple targets in
Makefile, including targets to just typeset each chapter. Typesetting a single chapter can be done in 15.97 seconds
LaTeX experts will say that every page depends on everything that comes before it because LaTeX is Turing Complete. And, of course, every page also depends on every page that comes after it, because of tempfiles. Frankly, it's amazing that LaTeX converges when typesetting!
However, there are well-known tricks that could be used to solve this problem. For example, pages could checkpoint relevant state, and then a new compile could use a multi-threaded implementation and run each page using the previous run's checkpoint, and re-run the pages if the checkpoint changes. Something similar could be used to speed even single-threaded runs: if we're compiling page 265, and the state at the beginning of page 265 is the same this run as the previous run, and no text in the document has changed between the start of page 265 and the start of page 266, then nothing on page 266 probably changed.
It seems that optimizations like these could make LaTeX dramatically faster. So why don't we see them in LaTeX2e, and will they be in LaTeX3?