gda2004
gda2004

Reputation: 746

make faster using -k faster than make?

why does make -k -j4 ;make -k -j4;make; appear to be faster than make -j4 ? I am using it to compile c++ and It appears to be faster because it does the linking all in one go but I am not sure does anyone know why ?

Upvotes: -1

Views: 80

Answers (2)

Some programmer dude
Some programmer dude

Reputation: 409186

You do know what the -k flag does? It tells make to try and keep going even in the case of errors. That means it will probably continue even when some files fails to build because of dependencies not being built yet (which can happen when you use the -j flag). The second invocation of make does a second attempt to build files, and the third finishes up.

The invocation without -k will stop as soon as there is an error, making you do it again, maybe multiple times. This will definitely feel that it takes a longer time, and probably do take longer time as well as it needs user interactions.

Upvotes: 1

Didier Trosset
Didier Trosset

Reputation: 37437

The flag -k instructs make to keep going doing its stuff even in case of errors. -j4 instructs make to start four processes at the same time when possible for unrelated targets.

In case your make operation is successful, i.e. no error occurs, then the second and third calls to make, whatever the arguments you pass should report a simple 'Nothing to do'.

I've to suggest this as a time illusion.

Upvotes: 1

Related Questions