Commit 12f99357 authored by moshe weitzman's avatar moshe weitzman

Remove performance module. Hopefully it will return to http://drupal.org/project/performance.

parent 54079474
By Khalid Baheyeldin
Copyright 2008 http://2bits.com
Description
-----------
This module provides performance statistics logging for a site, such as page generation
times, and memory usage, for each page load.
This module is useful for developers and site administrators alike to identify pages that
are slow to generate or use excessive memory.
Features include:
* Settings to enable detailed logging or summary logging. The module defaults to no
logging at all.
* Detailed logging causes one database row to be written for each page load of the site.
The data includes page generation time in milliseconds, and the number of bytes allocated
to PHP, time stamp, ...etc.
* Summary logging logs the average and maximum page generation time, average and maximum memory
usage, last access time, and number of accesses for each path.
* Summary can be logged to memcache, if configured, so as to not cause extra load on the database.
This works when APC cannot be used (e.g. certain FastCGI configurations, or when you have many
web servers on different boxes. This mode is recommended for live sites.
* Summary can be logged to APC, if installed, and the APC data cache is shared, so as to not cause
extra load on the database. This mode is recommended for live sites.
* A settings option is available when using summary mode with APC, to exclude pages with less
than a certain number of accesses. Useful for large sites.
* Support for normal page cache.
Note that detailed logging is only suitable for a site that is in development or testing. Do NOT
enable detailed logging on a live site.
The memory measurement feature of this module depends on the memory_get_peak_usage() function,
available only in PHP 5.2.x or later.
Only summary logging with Memcache or APC are recommended mode for live sites, with a threshold of
2 or more.
Note on Completeness:
---------------------
Please note that when summary logging to APC or Memcache, the data captured in the summary will
not be comprehensive reflecting every single page view for every URL.
The reason for this is that there is no atomic locking when updating the data structures that
store per-URL statistics in this module.
This means that the values you get when using these storage caches are only samples, and would
miss some page views, depending on how busy the site is.
For memcache, there is way to implement locking using the $mc->increment and/or $mc->add as well.
However, there is a risk if these are implemented, that there will be less concurrency and we
can cause a site to slow down.
Configuration:
--------------
If you are using memcache, then you need to configure an extra bin for performance.
If you have multiple web server boxes, then it is best to centralize this bin for
all the boxes, so you get combined statistics.
Your settings.php looks like this:
$conf = array(
'cache_inc' => './sites/all/modules/memcache/memcache.inc',
'memcache_servers' => array(
'127.0.0.1:11211' => 'default',
// More bins here ....
'127.0.0.1:11311' => 'performance',
),
'memcache_bins' => array(
'cache_performance' => 'performance',
),
);
Bugs/Features/Patches:
----------------------
If you want to report bugs, feature requests, or submit a patch, please do so at the project page on
the Drupal web site at http://drupal.org/project/performance
Author
------
Khalid Baheyeldin (http://baheyeldin.com/khalid and http://2bits.com)
If you use this module, find it useful, and want to send the author a thank you note, then use the
Feedback/Contact page at the URL above.
The author can also be contacted for paid customizations of this and other modules.
name = Performance Logging
description = Logs detailed and/or summary page generation time and memory consumption for page requests.
package = Development
core = 6.x
<?php
/**
* @file
* Install and update for Performance Logging
*
* Copyright Khalid Baheyeldin 2008 of http://2bits.com
*/
// Minimum APC shm memory size to require
define('PERFORMANCE_MIN_MEMORY', 48);
function performance_schema() {
$schema = array();
$schema['performance_summary'] = array(
'fields' => array(
'path' => array('type' => 'varchar', 'length' => '255', 'not null' => TRUE, 'default' => ''),
'last_access' => array('type' => 'int', 'not null' => TRUE, 'default' => 0, 'disp-width' => '11'),
'bytes_max' => array('type' => 'int', 'not null' => TRUE, 'default' => 0, 'disp-width' => '11'),
'bytes_avg' => array('type' => 'int', 'not null' => TRUE, 'default' => 0, 'disp-width' => '11'),
'ms_max' => array('type' => 'int', 'not null' => TRUE, 'default' => 0, 'disp-width' => '11'),
'ms_avg' => array('type' => 'int', 'not null' => TRUE, 'default' => 0, 'disp-width' => '11'),
'query_count_max' => array('type' => 'int', 'not null' => TRUE, 'default' => 0, 'disp-width' => '11'),
'query_count_avg' => array('type' => 'int', 'not null' => TRUE, 'default' => 0, 'disp-width' => '11'),
'query_timer_max' => array('type' => 'int', 'not null' => TRUE, 'default' => 0, 'disp-width' => '11'),
'query_timer_avg' => array('type' => 'int', 'not null' => TRUE, 'default' => 0, 'disp-width' => '11'),
'num_accesses' => array('type' => 'int', 'not null' => TRUE, 'default' => 0, 'disp-width' => '11'),
),
'primary key' => array('path'),
'indexes' => array(
'last_access' => array('last_access')),
);
$schema['performance_detail'] = array(
'fields' => array(
'pid' => array('type' => 'serial', 'not null' => TRUE, 'disp-width' => '11'),
'timestamp' => array('type' => 'int', 'not null' => TRUE, 'default' => 0, 'disp-width' => '11'),
'bytes' => array('type' => 'int', 'not null' => TRUE, 'default' => 0, 'disp-width' => '11'),
'ms' => array('type' => 'int', 'not null' => TRUE, 'default' => 0, 'disp-width' => '11'),
'query_count' => array('type' => 'int', 'not null' => TRUE, 'default' => 0, 'disp-width' => '11'),
'query_timer' => array('type' => 'int', 'not null' => TRUE, 'default' => 0, 'disp-width' => '11'),
'anon' => array('type' => 'int', 'not null' => FALSE, 'default' => 1, 'disp-width' => '1'),
'path' => array('type' => 'varchar', 'length' => '255', 'not null' => FALSE),
'data' => array('type' => 'blob', 'not null' => FALSE, 'size' => 'big'),
),
'primary key' => array('pid'),
'indexes' => array(
'timestamp' => array('timestamp')),
);
return $schema;
}
function performance_install() {
drupal_install_schema('performance');
// Set the weight so this module runs last
db_query("UPDATE {system} SET weight = 3000 WHERE name = 'performance'");
}
function performance_uninstall() {
drupal_uninstall_schema('performance');
db_query("DELETE FROM {variable} WHERE name LIKE 'performance%'");
}
function performance_requirements($phase) {
$requirements = array();
if ($phase != 'runtime') {
return $requirements;
}
if (variable_get('performance_detail', 0)) {
$requirements['performance_detail'] = array(
'title' => t('Performance logging details'),
'value' => 'Enabled',
'severity' => REQUIREMENT_WARNING,
'description' => t('Performance detailed logging is <a href="@link">enabled</a>. This can cause severe issues on live sites.', array('@link' => url('admin/settings/performance_logging'))),
);
}
if (variable_get('dev_query', 0)) {
if (variable_get('performance_detail', 0) ||
variable_get('performance_summary_db', 0) ||
variable_get('performance_summary_apc', 0)) {
$requirements['performance_query'] = array(
'title' => t('Performance logging query'),
'value' => 'Enabled',
'severity' => REQUIREMENT_WARNING,
'description' => t('Query timing and count logging is <a href="@link">enabled</a>. This can cause memory size per page to be larger than normal.', array('@link' => url('admin/settings/performance_logging'))),
);
}
}
if (!function_exists('apc_fetch')) {
$requirements['performance_apc'] = array(
'title' => t('Performance logging APC'),
'value' => 'Disabled',
'severity' => REQUIREMENT_WARNING,
'description' => t('Performance logging on live web sites works best if APC is enabled.'),
);
}
$shm_size = ini_get('apc.shm_size');
if (function_exists('apc_fetch') && $shm_size < PERFORMANCE_MIN_MEMORY) {
$requirements['performance_apc_mem'] = array(
'title' => t('Performance logging APC memory size'),
'value' => $shm_size,
'severity' => REQUIREMENT_WARNING,
'description' => t('APC has been configured for !size, which is less than the recommended !min_memory MB of memory. If you encounter errors when viewing the summary report, then try to increase that limit for APC.', array('!size' => 1*$shm_size, '!min_memory' => PERFORMANCE_MIN_MEMORY)),
);
}
return $requirements;
}
function performance_update_1() {
$ret = array();
db_drop_field($ret, 'performance_detail', 'title');
db_drop_field($ret, 'performance_summary', 'title');
return $ret;
}
function performance_update_2() {
$ret = array();
db_add_field($ret, 'performance_detail', 'data', array('type' => 'blob', 'not null' => FALSE, 'size' => 'big'));
return $ret;
}
/**
* Harmonize notations for milliseconds to "ms".
*
* @return array
*/
function performance_update_6001() {
$int_field = array('type' => 'int', 'not null' => TRUE, 'default' => 0, 'disp-width' => '11');
$ret = array();
db_change_field($ret, 'performance_summary', 'millisecs_max', 'ms_max', $int_field);
db_change_field($ret, 'performance_summary', 'millisecs_avg', 'ms_avg', $int_field);
db_change_field($ret, 'performance_detail', 'millisecs', 'ms', $int_field);
// We don't have a cache update method, so it's better to clear it
if (function_exists('apc_fetch')) {
apc_clear_cache('user');
}
return $ret;
}
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment