[tex4ht] what is the fastest way to convert large document to HTML?

Reinhard Kotucha reinhard.kotucha at web.de
Sun Aug 19 22:36:37 CEST 2018

On 2018-08-19 at 13:53:49 +0200, Michal Hoftich wrote:

 >   local command = "make -j -f " .. makefilename

Hi Michal,
if you use -j without an argument make will try to do everything at
the same time.  This leads to zillions of processes and open
files. It's better to specify the number of available CPUs:

#!/usr/bin/env texlua

local cpu_cnt = 4  -- set a reasonable default for non-Linux systems

if os.name == 'linux' then
  cpu_cnt = 0
  local cpuinfo=assert(io.open('/proc/cpuinfo', 'r'))
  for line in cpuinfo:lines() do
    if line:match('^processor') then
      cpu_cnt = cpu_cnt + 1

-- print(cpu_cnt)

And then

-  local command = "make -j -f " .. makefilename
+  local command = "make -j"..cpu_cnt.." -f " .. makefilename

Please note that the variable os.name is a LuaTeX extension and not
available in stock Lua, hence texlua is required.


Reinhard Kotucha                            Phone: +49-511-3373112
Marschnerstr. 25
D-30167 Hannover                    mailto:reinhard.kotucha at web.de

More information about the tex4ht mailing list