In attempting to optimize and speed up our Wine applications, we ran into a relatively large problem. There is a very large hole in the open source tools community with respect to multi-threaded profiler support. So we employed one of our co-operative education students to write one for us. Cprof is the result of this effort.
This document leads you through the steps required to build cprof, and use it with your applications, including your winelib and wine loader applications.
The following is a list of system requirements. Cprof can be built, maintained and used on a stock Debian GNU/Linux 2.2 (Potato) system. It will not work with version 1.0 or 1.1 of CorelLINUX as they are glibc 2.0 based. It will work on CorelLINUX 1.2 if you install all of the required packages.
Running this software requires:
Building this software requires:
Maintaining this software requires:
Note: Corel Linux 1.2 includes older versions of most of these packages and will require upgrading. You can get binary packages by pointing Corel Update to the Debian potato release.
You are now ready to start building your application with cprof support, and begin speeding up your applications.
There are a few changes to wine which are required in order to use Cprof. If you are using corelwine, you can do a ./configure (or ./corel-configure if that is how you normally invoke configure) with the command line options --enable-cprof and --disable-dll. eg. ./configure --enable-cprof --disable-dll
If you are not using the corelwine tree, you must apply the wine-support-for-cprof.diff patch to your wine tree. This patch contains the necessary support for cprof. Now you must run ./configure --disable-dll from the root or your wine tree.
After you have run configure (in either configuration method), you can make and install your wine normally.
The first step to analyzing the output of your code is to actually run the code. So run the application you just built for cprof. When you exit, you should see a file called cmon.out in the current directory. This file contains all the timing and call stack information. In order to use this information, you must pass it through cprof, a program which takes the cmon.out file, as well as the original application as parameters, and gives you timing information.
eg. if you just ran your wine loader application from the corelwine folder, you would execute the following command
cprof wine cmon.out > wine.profiled.prof
This would output a text file called wine.profiled.out which contains summary information sorted by function and children time.
There are a number of options you can pass to cprof. Most notably are the --calltrace and --sort=STYLE where style is one of f, fc, or c (function, function+children, calls to function ). --calltrace outputs a full calltrace for every function call made during the execution of your application. This results in a lot of data. The --sort=STYLE option allows you to sort the summary data based on the parameters above. You will probably get the most use out of the function + children time sort style.
The following is a list of usefull links regarding code optimization:
Delphi Optimization An in depth look at optimization guidelines
gprof manual The gprof manual. Gprof is what cprof is conceptually based off of.
Tau. An excellent set of cross platform profiling tools which unfortunately require changes to your code for instrumentation
Taking Extreme Advantage of PowerPC An excellent read on code profiling and optimization. A little bit PowerPC specific, but the concepts are there.