Compiling duration

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

Moderators: RoccoMarco, lbednarz, utzig, tfAteba, barthess

User avatar
Tectu
Posts: 1226
Joined: Thu May 10, 2012 9:50 am
Location: Switzerland
Contact:

Re: Compiling duration

Postby Tectu » Wed Feb 13, 2013 12:44 pm

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
Location: Germany

Re: Compiling duration

Postby goeck » Wed Feb 13, 2013 1:15 pm

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
Location: Aberdeenshire, UK

Re: Compiling duration

Postby gmb42 » Wed Feb 13, 2013 10:32 pm

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

Postby Prof. Dr. YoMan » Thu Feb 14, 2013 9:09 am

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: 14457
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 1076 times
Been thanked: 922 times
Contact:

Re: Compiling duration

Postby Giovanni » Thu Feb 14, 2013 9:34 am

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

Giovanni

User avatar
Tectu
Posts: 1226
Joined: Thu May 10, 2012 9:50 am
Location: Switzerland
Contact:

Re: Compiling duration

Postby Tectu » Thu Feb 14, 2013 10:08 am

@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

Postby Prof. Dr. YoMan » Thu Feb 14, 2013 10:12 am

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: 1226
Joined: Thu May 10, 2012 9:50 am
Location: Switzerland
Contact:

Re: Compiling duration

Postby Tectu » Thu Feb 14, 2013 11:12 am

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

Postby Prof. Dr. YoMan » Thu Feb 14, 2013 12:08 pm

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: 1226
Joined: Thu May 10, 2012 9:50 am
Location: Switzerland
Contact:

Re: Compiling duration

Postby Tectu » Thu Feb 14, 2013 1:18 pm

How comes that you have such a big difference then?


~ Tectu


Return to “General Support”

Who is online

Users browsing this forum: No registered users and 54 guests