Compiling duration

ChibiOS public support forum for all topics not covered by a specific support forum.

Moderators: RoccoMarco, lbednarz, tfAteba

User avatar
Tectu
Posts: 1225
Joined: Thu May 10, 2012 9:50 am

Re: Compiling duration

Post by Tectu »

Do you only have three physical CPU cores?
The -j option flag dosen't tell make how many cores it shall use, it tells how many jobs shall be created. For the best performance it's recommended to use cpu cores + 1. Therefore -j5 for a four core machine. You can get this out of the documentation.

The other thing to consider is that when using a dual core which has two threads per core it might be better to just create three make jobs instead of five. But this is OS dependend.


~ Tectu
goeck
Posts: 92
Joined: Mon Feb 11, 2013 12:00 pm

Re: Compiling duration

Post by goeck »

I have two cores with two hyperthreads .. as Intel calls it, right?
I actually just copied the settings that came up, when telling Eclipse to use 4 processors under "Preferences"->"C\C++"->"Build": Behaviour : Build Settings: Enable Parallel Build
As far as I was concerned the j Flag tells make to use more than one job. Here is the man page, http://linux.die.net/man/1/make which doesn't show the facts you mentioned. To me it seems, that 4 jobs can be distributet onto four cores, which runs smoothly then.
Anyway, I will adapt the settings, as not everybody own exactly 4 cores, right. Thanks for the hint.

Cheers
gmb42
Posts: 31
Joined: Tue Oct 02, 2012 8:09 pm

Re: Compiling duration

Post by gmb42 »

FYI timings on an i7, I primed the caches with a 'make' before these tests:

$ time make
make: Nothing to be done for `all'.

real 3m23.188s
user 0m45.067s
sys 2m36.545s

$ time make -r
make: Nothing to be done for `all'.

real 0m0.821s
user 0m0.310s
sys 0m0.420s

$ time make -j
make: Nothing to be done for `all'.

real 3m17.816s
user 0m45.380s
sys 2m30.664s

$ time make -j 5
make: Nothing to be done for `all'.

real 2m54.113s
user 0m39.858s
sys 2m12.240s
User avatar
Prof. Dr. YoMan
Posts: 57
Joined: Thu May 24, 2012 11:00 am
Been thanked: 1 time

Re: Compiling duration

Post by Prof. Dr. YoMan »

You should add -r to all makes using windows. I am building any example projects in ~5sec with a i5-2500 on ssd with make -j -r.

ARMCM3-STM32F107 with some additions (five c files and headers).

...
Build Finished (took 5s.197ms)

The key is the -r and i dont see any drawbacks because of it.
User avatar
Giovanni
Site Admin
Posts: 14891
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 996 times

Re: Compiling duration

Post by Giovanni »

What -r exactly does? should I add that to default projects?

Giovanni
User avatar
Tectu
Posts: 1225
Joined: Thu May 10, 2012 9:50 am

Re: Compiling duration

Post by Tectu »

@Giovanni, you can read what -r does here.

Code: Select all

 -r, --no-builtin-rules
       Eliminate  use of the built-in implicit rules.  Also clear out the
       default list of suffixes for suffix rules.

I wouldn't recommend adding that to the default makefile.


@goeck: I must search the article about why amount of threads + 1 is the optimum for the -j flag. There is a reason. It has something to do with the scheduling.


~ Tectu
User avatar
Prof. Dr. YoMan
Posts: 57
Joined: Thu May 24, 2012 11:00 am
Been thanked: 1 time

Re: Compiling duration

Post by Prof. Dr. YoMan »

I guess it is a bug in make on windows with -r. Its way to much difference with the flag set or not.
User avatar
Tectu
Posts: 1225
Joined: Thu May 10, 2012 9:50 am

Re: Compiling duration

Post by Tectu »

I'm on a linux system. I did take the demos/ARMCM4-STM32F407-LWIP-USB-FATFS demo:

Code: Select all

[tectu@TecTop ARMCM4-STM32F407-LWIP-FATFS-USB]$ time make -j5
real   0m5.916s
user   0m19.247s
sys   0m1.510s


Code: Select all

[tectu@TecTop ARMCM4-STM32F407-LWIP-FATFS-USB]$ time make -j5 -r
real   0m5.906s
user   0m18.917s
sys   0m1.667s



~ Tectu
User avatar
Prof. Dr. YoMan
Posts: 57
Joined: Thu May 24, 2012 11:00 am
Been thanked: 1 time

Re: Compiling duration

Post by Prof. Dr. YoMan »

Windows:

ARMCM3-STM32F107 with some additions (five c files and headers).
make -r -j4
Build Finished (took 5s.197ms)

make -j4
Build Finished (took 28s.785ms)

Most of the time is spend directly after the call of make. When the compiling finally starts, it is as fast as with -r.
User avatar
Tectu
Posts: 1225
Joined: Thu May 10, 2012 9:50 am

Re: Compiling duration

Post by Tectu »

How comes that you have such a big difference then?


~ Tectu
Post Reply