Bug#1080322: latexmk: add -parallel=N option

John Collins <[email protected]>
Newsgroups gmane.linux.debian.devel.tetex
Message-ID <13569900-3007-464d-81f4-a1aadf0385c8__47523.8679022127$1774394130$gmane$org@psu.edu>
Barak,

This is interesting, and it works in my simple tests.  I'll get back to you 
later with further comments.  How much tweaking of the code did you have to do 
after the github copilot produced its results?

Meanwhile, here are some small points:

1. The -parallel=num option isn't parsed correctly.  Currently, line 2306 is

            if ( $1 =~ /^\d+$/ ) { $parallel_jobs = $1; }

The problem is that the pattern matching operation resets $1 to undef, so the 
assignment to $parallel_jobs is not what is intended; I was getting warning 
messages about an uninitialized value.  Just change that line to

       if ( $1 =~ /^(\d+)$/ ) { $parallel_jobs = $1; }

and everything will be fine.  (There are now parentheses around the matched 
pattern, so that $1 is reinitialized, correctly.)

2. Stdout and stderr are redirected in the forked processes so that the outputs 
doesn't get mixed up.  But the *latex programs also sometimes get input from 
stdin, particularly under error conditions (unless -interaction=batchmode is 
used).  Potentially the same could happen with other invoked programs  I think 
that can be solved by redirecting stdin to be from /dev/null.

3. The methods used don't work on Windows.  So under Windows, I would give a 
warning if $parallel_jobs isn't 0 or 1 after the command line is parsed, and 
then set it back to zero.

4. Would you mind changing the version identification and keeping the date 
updated.  I'm calling my test version 4.88.parallel.  It makes it a lot easier 
to identify what's being run, especially when comparing different versions or 
getting bug reports.  (Note that by default, latexmk outputs the version 
information near the beginning of its work, which makes the output self 
documenting as to the version in use.)

Best,
John




On 3/23/26 4:24 PM, Barak A. Pearlmutter wrote:
> 
> I asked github copilot to add a latexmk -parallel[=n] option and ate
> dinner and came back and tested it and it seems to work fine. First it
> just allowed various top-level .tex files to be processed in parallel.
> Then I asked for other stuff to be  concurrent too, and also to stop
> mixing up outputs and buffer them instead, and it did that. Then I
> told it I was worried about errors from interaction of multiple
> subjobs generating the same intermediate file, so it added some
> flock'ing. And I tested it some more and it seems to work fine.
> 
> https://github.com/barak/latexmk branch copilot/add-parallel-option-to-latexmk
> 
> "If you can dream it...!"
> 
> --Barak.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.