91

Which things should one have in mind when one wants to buy new hardware optimized for best (pdf)latex performance?

For example one might think the more cores on your cpu the better. But since latex is a linear thing there is no much space for parallelizing. So the number of cores seems not to be so important.

What features of your new system especially the cpu are crucial for best latex performance?

Which features that are usually important for good performance for general use are not crucial for latex performance?

Edit:

Clearly you could simply choose the most expensive high end system you can get. However usually one has a budget and the question is really about which parts of the system and features in detail are crucial for latex compile performance and which are not so important because latex cannot use it for example...

lockstep
  • 250,273
student
  • 29,003
  • 4
    LaTeX depends on input/output, so caching at CPU and OS level may have a big impact on performance. Since caching support may be implemented by different threads/processes, having more cores can be a great advantage. –  Mar 21 '13 at 06:52
  • Though @MarcvanDongen is right, I think that you'd get much higher productivity boost from using a well-thought toolset, i.e. a good editor/LaTeX IDE and a reasonable pdf viewer (i.e. either not Adobe Reader, either properly configured Adobe Reader). – mbork Mar 21 '13 at 06:59
  • 19
    For the editor: an algorithm for choosing a very good editor may be: 1. toss a coin. 2. Heads choose Vim, tails choose Emacs. 3. STOP. However, there is also a better algorithm, which chooses not a good editor, but the best one: 1. choose Emacs. 2. STOP. – mbork Mar 21 '13 at 07:00
  • 1
    @mbork I usually use emacs+auctex+evince however the question is really about optimizing the hardware for latex and not the software... For example is it more important for latex to have high clock speed or is cache more crucial or the number of cores... – student Mar 21 '13 at 07:01
  • And last but not least: what may count the most (I think) is the workflow and habits. You can use Emacs in a non-productive way, for instance, not utilizing its power. (The same goes for Vim, of course.) Another example: if you use LuaTeX on a netbook machine (I do - sometimes), recompiling after each tiny change is probably a very bad idea. – mbork Mar 21 '13 at 07:03
  • 6
    TeX basically consists of four processors that work in a pipeline (input processor, expansion processor, execution processors, and visual processor). Each can be implemented using a dedicated thread. If TeX is implemented that way, then it's possible to assign each thread to a dedicated core, which should speed up the overall compilation process. –  Mar 21 '13 at 07:10
  • 4
    @MarcvanDongen: though I'm afraid even Taco is not brave enough to reimplement TeX that way... The communication between these "threads" is quite complicated... – mbork Mar 21 '13 at 07:15
  • It just occurred to me that, depending on whether you are more into music or more into games, good speakers or a fast video card might be the best option - see http://xkcd.com/303/ ;D – mbork Mar 21 '13 at 07:20
  • 1
    @mbork As Judge Judy would say: speculation. –  Mar 21 '13 at 07:21
  • 21
    @mbork "1. choose Emacs. 2. STOP" Yes, when you choose Emacs, that's when it all stops. At least vim lets you continue working. –  Mar 21 '13 at 07:44
  • 5
    apres mbork: So now hard core TeXers need a customized rig? It's all about the pps (pages per second). :) – Ryan Reich Mar 21 '13 at 13:54
  • 5
    After reading Daniel's answer, I don't know if I should claim to have been joking anymore. – Ryan Reich Mar 21 '13 at 13:57

1 Answers1

100

In the end, it is only one thing that really makes a difference: Single-Threaded CPU power!

I do a lot of LaTeX compiling, especially of large beamer presentations (lecture notes with 500+ slides, lots of overlays and lots of TikZ stuff). Compilation time with three pdflatex runs usually takes minutes.

I have done experiments with this setting on a bunch of different machines at our lab, from my dual-core notebook over ordinary quadcore PCs with 2 to 4 GB of RAM up to an 48-core AMD server with 32 GB of RAM and ultra-fast SCSI disks.

I don't have recorded the actual numbers of these tests. However, the result roughly is: compilation times scale nearly linear with the CPU clock. It's the fasted Core i7 that makes the run; memory and disk plays only a minor role (given that you provide modest quality and size of both).

The results should not be surprising:

  • Compiling LaTeX documents does not consume a lot of of memory by today standards. On a machine that is able to execute Word at modest performance, you will never hit the memory barrier when using LaTeX.
  • LaTeX does do a lot of IO, that is true. Nevertheless, even with a slow hard disk, the IO load does not take more than a couple of milliseconds. For the second and third compiler run, most files are in the buffer cache anyway.
  • None of the existing TeX/LaTeX compilers use thread-level parallelism and, thus, would profit significantly from multiple CPU cores. Also the typical three pdflatex runs cannot be parallelized, they have to be executed sequentially. In some cases it might, however, be possible to use process-level parallelism, so that multiple cores can speed up the compilation process:

    • For my beamer lecture notes, I maintain a "presentation", "handout", and "notes" version. When I am done with editing, I usually compile all three in parallel to speed things up.
    • With the TikZ external library, it is possible to compile your TikZ figures in parallel in background processes and include them as PDFs. If your document contains many complicated TikZ or pgfplots images, multiple cores could speed up this process. (Thanks to Alexander for this hint!)
  • I have not done any tests regarding cache size, but as the memory load is low, we can not expect a significant benefit of extra-large caches.

To sum up: For a "LaTeX machine" it is the processor and in particularly it's single-core throughput one should look for.

However, the latter is not always easy to figure out, as basically all processors nowadays are multi-core and benchmarked and advertised with their multi-core throughput. A good starting point is the PassMark CPU Benchmarks site, which provides a frequently updated report on "Single Thread Performance" for all current IA32e/AMD64 CPUs.

Daniel
  • 37,517
  • 8
    I thought IO should also have quite a bit of influence so I just benchmarked (fast) HD vs. SSD. Given enough RAM the differences under Windows 7 are within a few percent, much less than I thought. It seems that pretty much everything is cached, so yes indeed, CPU power it is. Fortunately TikZ supports multiple cores via the external library so that they can also contribute. – Alexander Jul 10 '13 at 12:42
  • 3
    @Alexander: Thanks for sharing this experience. The TikZ externalize/multicore hint is a good one! I have incorporated it into the answer. – Daniel Jul 10 '13 at 22:23
  • @Daniel I'm not so sure about the cache size not mattering so much... I do feel it plays a big part. Although the memory usage is not so high, having the information "at hand" should really improve the processing time. – Mario S. E. Jul 10 '13 at 23:32
  • 1
    @MarioS.E. Memory is slow, so caches are extremely important. However, because of the locality rule (over short periods of time, >90% of all memory accesses go to a relatively little range of physical memory) even a small cache already has a tremendeous impact – and the benefit of larger caches becomes much less significant. Pdflatex is no exception here, it is a CPU-bound process. The 8MB L3 cache of Core i7 are more than enough. – Daniel Jul 11 '13 at 05:53
  • Even with a complete ramdisk setup (put all files inside a ramdisk), there are only few percent. – math Mar 04 '14 at 08:41
  • Any insight on choosing Intel vs. AMD processors? AMD seems to have higher clock speed (around 3.5-4.2 GHz, compared to 3.4-3.9 GHz for i7's), but I know the numbers are not necessarily directly comparable between the two. I'm wondering if your tests actually showed Intel chips to be faster. – David Z Aug 25 '14 at 07:59
  • 1
    @DavidZ: The only AMD machine at our lab was the big AMD server (48 x Opteron 6180SE@2.5 GHz), which was more than ten percent slower than the Intel workstation (8 X Xeon E5620@2.4 GHz). The current Haswell generation is said to have further increased the advantage over AMD, so I would go for Intel. However, to be really sure I suggest to compare the CPU performance benchmark results at http://www.cpubenchmark.net or some similar site. – Daniel Aug 25 '14 at 16:28
  • In terms of integer vs floating point arithmetics, which is more intensively used by LaTeX? I thought that TikZ would be more FPU intense, but what about the rest of LaTeX? Particualrly interested in speeding up Chemfig and MHChem which take foooooorever! – ajeh Apr 21 '17 at 18:50
  • @ajeh In the TeXbook Knuth implies TeX uses fixed-point (i.e.) arithmetic (in very small units) for consistency across machines. – Blaisorblade Jul 21 '17 at 01:39
  • Sounds like TikZ which I use most of the time uses FP. Am I wrong? – ajeh Jul 21 '17 at 13:44
  • @ajeh I recommend a separate question, but I understand there is NO WAY to use CPU floating-point in TeX. My grep-fu on TikZ suggests that TikZ implements FPU in TeX except if you use LuaTeX. On my TeXlive 2016 install, /usr/local/texlive/2016/texmf-dist/tex/generic/pgf/math/pgfmathfunctions.basic.code.tex (look for ln) and /usr/local/texlive/2016/texmf-dist/tex/generic/pgf/libraries/luamath/pgf/luamath/functions.lua fit this hypothesis. No real clue though—please ask :-) – Blaisorblade Jul 26 '17 at 23:10
  • @ajeh: Update: I'll ask myself, and I found more info here: https://tex.stackexchange.com/q/37178/1340, https://tex.stackexchange.com/a/261475/1340 and https://tex.stackexchange.com/questions/112599/perform-matrix-operations-addition-product-transpose-etc-in-latex#comment248984_112599 – Blaisorblade Jul 26 '17 at 23:17
  • @ajex My question is https://tex.stackexchange.com/q/383437/1340. – Blaisorblade Jul 26 '17 at 23:38
  • Related: http://www.complang.tuwien.ac.at/franz/latex-bench – student Mar 14 '21 at 20:54
  • Remark: some other user claim that disk read/write speed affects the compilation (which can be sped up by using RAM-disk for compilation) https://tex.stackexchange.com/a/522569/250119 – user202729 Nov 11 '21 at 16:18