PHP Profiling via XHProf now built into SugarCRM 6.5.10 and later

sugarcrmdevelopers —  February 5, 2013 — Leave a comment

We just released SugarCRM 6.5.10 late last week, and one big new feature developers will be happy to know about is the new ability to profiling via XHProf, which is an easy to use, hierarchical profiler for PHP. This allows developers to better manage and understand customer performance issues introduced by their customizations.  This tool enables quick and accurate identification of the sources of performance sinks within the code by generating profiling logs. Profiling gives you the ability to see the call stack for the entire page load with timing details around function and method calls as well as statistics on call frequency.

Assuming XHProf is installed and enabled in your PHP configuration ( which you can learn how to do in the PHP Manual ), you can enable profiling in Sugar by adding the following parameters to the ./config_override.php file:

$sugar_config['xhprof_config']['enable'] = true;
$sugar_config['xhprof_config']['log_to'] = '{instance server path}/cache/xhprof';
$sugar_config['xhprof_config']['sample_rate'] = 1; // x where x is a number and 1/x requests are profiled. So to sample all requests set it to 1
$sugar_config['xhprof_config']['ignored_functions'] = array(); // array of function names to ignore from the profile (pass into xhprof_enable)
$sugar_config['xhprof_config']['flags'] = XHPROF_FLAGS_CPU + XHPROF_FLAGS_MEMORY; // flags for xhprof

Please note that with the above ‘log_to’ parameter, you would need to create the ./cache/xhprof/ directory in your instance directory with proper permissions and ownership for the Apache user. You can also opt to leave the ‘log_to’ parameter empty and set the logging path via the xhprof.output_dir parameter in the php.ini file.

Once the above parameters are set, XHProf profiling will log to the indicated directory and allow you to research any performance related issues encountered in the process of developing and maintaining the application.

You can read more about this in the Sugar Developer Guide.

No Comments

Be the first to start the conversation!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s