ARM Technical Support Knowledge Articles

How can I improve the build time of my application?

Applies to: ARM Developer Suite (ADS), RealView Development Suite (RVDS), Tool Licensing (License Management)

Answer

Modern applications can often consist of many thousands of source files which can take a considerable amount of time to compile and link. Also, the many different techniques that ARM compilation tools use to optimize for smaller code size and higher performance can increase build times as well. This article considers various ways of decreasing the time your code takes to build.

What happens when the compiler is invoked?

When you invoke the compiler, three steps are carried out:

  1. The compiler is loaded and begins to execute.

    This will normally take a fixed period of time.
     
  2. The compiler tries to obtain a license.

    Assuming a license is available, this should take a similar period of time for each request. If a floating license is used, this will depend on network traffic and whether a license is free for checkout on the server. Note that whereas compilation tools in ADS 1.2 will fail if no license is available, RVCT and ARM Compiler will in most circumstances wait for a license to become available.

    The process of obtaining a floating license is more involved than obtaining a node-locked license. With a node-locked license, the compiler simply has to parse the file to check that there is a valid license.

    With a floating license, the compiler has to check where the license is, send a message through the TCP/IP stacks over the network to the server, then wait for a response. When this is received, it then needs to check whether it has been granted a license. Then, after the compile has completed the license has to be returned back to the server.

    Floating licenses provides flexibility, but at the cost of speed. If speed is your priority, then you should consider obtaining node-locked licenses for your build machines, or some node-locked licenses locked to USB network cards which can be moved between machines as required.

    Setting the environment variable TCP_NODELAY to 1, on client and server machines, improves FlexNet license server system performance when processing license requests. However, this must be used with caution, as it may cause an increase in network traffic.

    For more information on floating licenses please see the License Management FAQ entry: Optimizing license checkouts from a floating license server.

  3. The compiler compiles your code.

    The time taken for this step is dependent on the complexity and size of the files being compiled. Compiling a small number of larger files may be quicker than compiling a large number of smaller files. This is because the longer compiling time per file may be offset by the smaller amount of time spent loading/unloading the compiler and obtaining licenses.

    Taking this one stage further, it is possible to have a single invocation of armcc (and single license checkout) to compile many files. To do this, instead of having a build script like:

    armcc file1.c ....
    armcc file2.c ....
    armcc file3.c ....
    :
    :

    you could instead use:

    armcc file1.c file2.c file3.c ..... 

    Alternatively, you could list all your .c files in a single "via" file, invoked with:

    armcc --via sources.txt 

    This mechanism dramatically reduces license checkouts and compiler load/unloads and can give huge improvements in performance. It does have some limitations:

    • All files will be compiled with the same options.
    • It may be difficult to convert existing build systems.
    • Usability depends on source file structure and dependencies.
    • An IDE may be unable to report which file had compile errors.

    Note 1: After finding an error, ARM Compiler and RVCT will not compile subsequent files. The much older ADS compiler will attempt to compile all subsequent files.

    Note 2: Compiling at optimization level -O3 enables multifile compilation, which may increase build times. If you wish to disable multifile compilation use the --no_multifile option.

The effect of include paths

Include paths can also increase build times. You should try to keep the number of include paths to a minimum. If you have a lot of include paths, make sure the files you need to include the most often exist in directories near the start of the include search path.

You should also try to avoid including headers more than once, which can increase compile times. You can guard against including headers multiple times. For example, if you have a header file 'foo.h', then add:

#ifndef foo_h
#define foo_h
:
// rest of header file as before
:
#endif /* foo_h */

You can use the compiler option -W+g to warn about unguarded header files.

Use of parallel make

If you are using a makefile-based build environment you could consider using parallel make (functionality provided by some make tools, such as gnu make). To do this you typically use "make -j N", where N is the number of compile processes you want to have running in parallel. Even on a single machine with a single processor, this can give you a performance boost by allowing you to hide network delays and general I/O accesses (for example, loading/saving files to disk) by fully using the CPU during these times with another compile process.

If you have multiple processor machines then you can make use of even more parallelism by using "make -j N*M" (where M is the number of processors).

Operating System Choice

Linux generally gives better build speed than Windows.

If you are using Windows, there are ways to "tune" the performance of the OS (at a general level) which may help to increase the percentage of CPU time being used for your build. At a simple level, turning off virus checking software can help, but an internet search for "tune windows performance" provides a lot of information.

In general, ARM development tools will work on Windows and Linux platforms that were in common use at the time of development. Testing will have been carried out on all of the supported platforms for that product. For more information, please refer to the documentation and/or release notes for the version of tools you are using.

Article last edited on: 2016-06-01 20:22:11

Rate this article

[Bad]
|
|
[Good]
Disagree? Move your mouse over the bar and click

Did you find this article helpful? Yes No

How can we improve this article?

Link to this article
Copyright © 2011 ARM Limited. All rights reserved. External (Open), Non-Confidential