Follow-up Comment #2, bug #53152 (project make): I can reliably reproduce this on Fedora 26 if I have enough busy-wait processes running, using this command line:
while true; do date; rm mksync; make -j2 -dr; done and this Makefile: all: foo baz foo: bar date > mksync bar: @echo bar baz: while [ ! -f mksync ]; do sleep 1; done @echo baz Based on the output, it looks like the jobs are queued breadth-first, but only one at a time actually runs, so the all.baz child runs before the all.foo child... i.e. with -j2 the first two jobs queued are all.foo.bar (not all.foo!) and all.baz. all.foo.bar runs, then all.baz, but all.foo remains queued until the load is reduced. I suspect a depth-first search would solve this; the jobs would be queued in the same order as with -j1... all.foo.bar, all.foo, then all.baz. However, that would also mean we'd not parallelize as much as possible. Alternately, if the job token for the last dependency of a rule could be reserved for the parent rule - as if the parent got the token, and let its children "borrow" it, at least the rules *could* be run in the same order as -j1. A third option is to test for system load as jobs are queued, so that in this case all.baz wouldn't even be queued in the first batch. (yes, I looked at the code; no, I couldn't figure out where to fix anything ;) GNU Make 4.2.1 Updating goal targets.... Considering target file 'all'. File 'all' does not exist. Looking for an implicit rule for 'all'. No implicit rule found for 'all'. Considering target file 'foo'. File 'foo' does not exist. Considering target file 'bar'. File 'bar' does not exist. Finished prerequisites of target file 'bar'. Must remake target 'bar'. Need a job token; we don't have children bar Putting child 0x55ab69cf95c0 (bar) PID 30261 on the chain. Recipe of 'bar' is being run. Finished prerequisites of target file 'foo'. The prerequisites of 'foo' are being made. Considering target file 'baz'. File 'baz' does not exist. Finished prerequisites of target file 'baz'. Must remake target 'baz'. Live child 0x55ab69cf95c0 (bar) PID 30261 Reaping winning child 0x55ab69cf95c0 PID 30261 Removing child 0x55ab69cf95c0 PID 30261 from chain. Need a job token; we don't have children while [ ! -f mksync ]; do sleep 1; done Putting child 0x55ab69cf95c0 (baz) PID 30262 on the chain. Recipe of 'baz' is being run. Finished prerequisites of target file 'all'. The prerequisites of 'all' are being made. Live child 0x55ab69cf95c0 (baz) PID 30262 _______________________________________________________ Reply to this item at: <https://savannah.gnu.org/bugs/?53152> _______________________________________________ Message sent via Savannah https://savannah.gnu.org/ _______________________________________________ Bug-make mailing list Bug-make@gnu.org https://lists.gnu.org/mailman/listinfo/bug-make