Documentation/Maemo Eclipse Tutorial/Eclipse Performance Profiling

To obtain high-quality applications to be deployed on user's mobile devices, making sure that your application is bug-free is not enough. Mobile devices have limited resources, mainly CPU processing and memory. Also the way that applications interact with system resources impacts directly on performance. It is very problematic if your application crashes during execution. However, it can be worse if the application freezes due to excessive CPU processing, for example. The OProfile tool can be used to monitor your application and define bottle necks in real-world systems. In order to find problems in performance, Maemo SDK also provides OProfile packages so it can be used to profiling Maemo applications as well Internet Tablet environments.

Maemo Eclipse IDE integration products (ESbox and PluThon) provide support to profiling applications by using OProfile profiling and monitoring tool. This tutorial starts with a quickly introduction to OProfile profiling and monitoring tool. After that, it demonstrates how you can profile C/C++, Qt4 and Python applications at ESbox and PluThon using the OProfile tool integration. Finally, you can see how to interpret OProfile output at ESbox and PluThon.

Contents

OProfile

OProfile is an open source project that helps you to identify common performance issues, such as loop unrolling, poor cache utilization, inefficient type conversion and redundant operations, branch mispredictions, and so on. OProfile collects information about different counters: interrupt handlers, shared libraries, and much more. OProfile generates different outputs, ranging from simple tables with numbers that describe the total of samples registered during monitoring, to call graphs with detailed information about shared libraries. You can also obtain detailed source annotation, instruction-level reports and call graphs.

To start collecting profiling data, it is necessary to start opcontrol tool. It is OProfile tool that collects the information that is then used to generate profiling reports. After profiling information has been collected with opcontrol tool you can generate the reports you want to with opreport tool.

You can use OProfile on Maemo devices. However, you need to enable it on the kernel, so OProfile can monitor the system and applications. For more information about this step, see chapter #Configuring your Maemo device.

OProfile and IDE Integration

Both Maemo Eclipse IDE integration products ESbox and PluThon provide support for OProfile tool for C/C++, Qt4 and Python projects only on Maemo device environments. It does make sense to profile Maemo applications on Scratchbox with OProfile: it would catch also host machine interruptions, signals and produce a lot of other useless information so the result would not be accurate.

OProfile support on ESbox and PluThon uses the command opreport -a -l -g to generate profiling reports. In such cases, OProfile generates the report with source file and line for each symbol (-g) and it also accumulates sample and percentage counts in the symbol list (-a). This section shows how to profile your applications at ESbox and PluThon and how to analyse profiling results.

Configuring your Maemo device

If you want to configure your device to profile Maemo applications, you need to enable the Maemo device kernel to execute OProfile on it. For more information, see documentation from the OProfile site like OProfile Manual [1] and from maemo.org site like OProfiling with Maemo [2].

ESbox and PluThon products can configure the OProfile environment for you. If the system detects that your Maemo device kernel is not properly configured, a dialog prompts the user (figure 11.1) to configure the kernel for OProfile.

Figure 11.1: Profiling application with OProfile

File:Oprofile-04.png

Profiling your Maemo application

At first, you must create a C/C++, Qt4 or Python project and select an ARMEL Scratchbox target. To run OProfile, right-click on the application (binary for C/C++ and qt4 projects or the Python script for Python projects) and select Profile As > Remote OProfile Profiler, figure 11.2. If the tool is not properly installed at the selected target, the system can automatically install it for you.

Figure 11.2: OProfile Launch Menu

File:Oprofile-01.png

ESbox and PluThon runs your application on the Maemo device and the result is shown in the OProfile view, figure 11.3. All statistics found by OProfile are shown in an OProfile viewer, see chapter #Analyzing results for more details.

Figure 11.3: OProfile View

File:Oprofile-05.png

Image:Ambox_notice.png
If you are planning to run the OProfile profiler more than once, you will probably need to clear current OProfile view before running the current program. For that, you just need to click the Delete Current Sample button on the OProfile view toolbar. If you do not, current results are merged with the older ones.

Analyzing results

Each line of OProfile viewer contains the following information:

Samples
Shows the number of samples for each symbol.
Acummulate samples
Outputs accumulate sample.
Percentage
Shows the percentage regarding to total samples for each binary image.
Acummulate percentage
Shows the accumulate percentage.
Line info
Provides source file and line for each symbol. If the source file is not provided, the label (no location information) is shown instead.
Application name
Shows the name of binary image.
Symbol name
Shows the symbol name. If the symbol name cannot be retrived, the label (no symbols) is shown instead.

On the following figure 11.4, there is an example of OProfile chapter from a Maemo C project:

Figure 11.4: OProfile View

File:Oprofile-08.png

In this example, we used a very simple GTK application, which only contains a simple label. On the third line (the selected line), information about library ld-2.5.so is shown in the table. For example, in about 12.030 samples (columm Cum. Samples), the library was used on 10.879 samples (4.59%). Its symbol name is known as /lib/ld-2.5.so (columm Symbol Name). This library does provides source file, so no information can be shown on Line Info columm.

References

  1. OProfile Manual. http://oprofile.sourceforge.net/doc/index.html
  2. OProfiling with Maemo. http://maemo.org/development/tools/doc/diablo/oprofile/