sudar / Arduino-Makefile

Makefile for Arduino sketches. It defines the workflows for compiling code, flashing it to Arduino and even communicating through Serial.
http://hardwarefun.com/tutorials/compiling-arduino-sketches-using-makefile
GNU Lesser General Public License v2.1
2.02k stars 448 forks source link

Compilation much slower since #277 #280

Closed ladislas closed 10 years ago

ladislas commented 10 years ago

Hi there!

I just pulled the latest changes to support 1.5.x as I'm willing to move to this new version for Moti.

As I did some tests to make sure it did not break anything, I noticed the compilation was much much slower than usual. I first thought it was on my side but after quitting every apps open and restarting my Mac, I still got the same issue. Rolling back to where I was previously fixed it.

Here are the outputs of time make:

master and auto-lib share the exact same base, but auto-lib adds the python script to auto-detect libraries. The time difference between the two is only 0,47 second.

update pulled the latest changes from #277. The time difference with master is now 1,76 seconds.

In the last example, I've merge update and auto-lib and it's now even worse! The time difference with master is now 11,27 seconds which is just huge! :(

When looking at the output, it's really calling avr-gcc which takes most of the time, avr-ar is just as quick as usual.

Is anybody else experiencing some issues? I haven't tested the 1.5.x IDE, is there a difference of compilation time with 1.0.6?

sej7278 commented 10 years ago

slightly slower but its bound to be, its recursively searching for dependencies. never seen a build take 11 seconds though, and the script i tested uses 10 libraries.

surely you're auto-lib branch is going to massively conflict with recursion in master though?

1.3.4 release with 1.0.5 (avr-gcc 4.8.1)

real    0m2.978s
user    0m2.304s
sys 0m0.132s

1.3.4 release with 1.0.6 (avr-gcc 4.7.2)

real    0m3.421s
user    0m1.880s
sys 0m0.092s

master with 1.0.5 (avr-gcc 4.8.1)

real    0m3.112s
user    0m2.296s
sys 0m0.152s

teensy (master+pull #278) with 1.0.6 (avr-gcc 4.7.2)

real    0m3.764s
user    0m2.344s
sys 0m0.136s

teensy (master+pull #278) with with 1.0.5 (avr-gcc 4.8.1)

real    0m2.694s
user    0m1.808s
sys 0m0.148s

So it seems 1.0.6 is a bit slower, but that's because its using the ide's avr-gcc 4.7.2 instead of the avr-gcc 4.8.1 from the core-arduino debian package. but not much variance in any branches.

my 1.5.6 build is in a vm, so not worth benchmarking that.

ladislas commented 10 years ago

I'm compiling ChibOS/RT + FreeIMU + a dozen of my own libs, which adds up to a lot of LoC.

The recursive search is done every time?

I'll dig into it.

lukasz-e commented 10 years ago

Recursive search should be done only for "new 1.5 layout" librararies. Old 1.0.x libs should compile almost the same time as before - the only new thing is check for library.properties file and src subdirectory (once for each library), which shouldn't take much time. But if make expands both true/false variants from conditional "$(if" expressions (even if only one variant is used) - then it can be slower also for 1.0.x code. I'll try to investigate this.

lukasz-e commented 10 years ago

As I've just checked - my make (ver. 3.81) does not evaluate/expand unneeded "$(if" branches, so there shouldn't be significant "recursive search" overhead for 1.0.x libs.

I made some quick tests on my ubuntu 14.04 (arduino 1.0.5, avr-gcc 4.8.2) one sample (Ethernet/examples/AdvancedChatServer) gave (real):

I also tried do disable all output from make (>/dev/null 2>&1) - there was some change in times, but generally differences between Arduino-Makefile versions were still similar.

To be honest, I have no idea what is the cause for these time differences now...

@ladislas How can I reproduce your results ? (I don't have mac, but maybe on linux/windows results will be similar)

sej7278 commented 10 years ago

It could be library specific, as I've just built /usr/share/arduino/libraries/Ethernet/examples/ChatServer/ChatServer.ino and it does seem to have slowed down after 1.3.4

1.3.4:
real    0m1.863s
user    0m1.208s
sys 0m0.140s

master:
real    0m2.807s
user    0m1.324s
sys 0m0.160s

make 4.0 with output disabled.

ladislas commented 10 years ago

Thanks @lukasz-e for investigating :)

you can try to reproduce my results with my moti project: https://github.com/WeAreLeka/moti

Just clone the repo, init and update the submodules, go to src/ShakeToDiscover, cp the Linux Makefile from root and then make.

There's installation instructions in INSTALL.md

EDIT:

to test different branch of Arduino-Makefile, cd to the Arduino-Makefile folder and git checkout the branch you want.

sej7278 commented 10 years ago

can't really test 1.3.4 or master as it won't compile without your auto-lib changes.

couple of builds using your master+autolib branch:

real    0m3.286s
user    0m2.396s
sys 0m0.136s

real    0m3.294s
user    0m2.412s
sys 0m0.136s

why are you using gnu++14 as that requires avr-gcc 4.9, its not even going to compile on any existing IDE builds that use 4.7 or most linux distro's that use 4.8

ladislas commented 10 years ago

@sej7278 yep, you need to include all of this:

#include <Arduino.h>
#include <Wire.h>

#include "Motion.h"
#include "Moti.h"
#include "Light.h"

#include "Stabilization.h"
#include "Heart.h"
#include "Wander.h"

#include "ChibiOS_AVR.h"
#include "DriveSystem.h"
#include "Motor.h"
#include "Led.h"
#include "Sensors.h"
#include "Toolbox.h"
#include "Color.h"
#include "Queue.h"
#include "FreeIMU.h"

why are you using gnu++14 as that requires avr-gcc 4.9, its not even going to compile on any existing IDE builds that use 4.7 or most linux distro's that use 4.8

I have it installed on my machine, wanted to try the error colouring. It works great and I've even noticed a reduction of program space.