| [ Index ] |
PHP Cross Reference of Drupal 6 (yi-drupal) |
[Summary view] [Print] [Text view]
1 <?php 2 // $Id: performance.install,v 1.1.4.12 2010/02/08 03:56:14 kbahey Exp $ 3 4 /** 5 * @file 6 * Install and update for Performance Logging 7 * 8 * Copyright Khalid Baheyeldin 2008 of http://2bits.com 9 */ 10 11 // Minimum APC shm memory size to require 12 define('PERFORMANCE_MIN_MEMORY', 48); 13 14 function performance_schema() { 15 $schema = array(); 16 17 $schema['performance_summary'] = array( 18 'fields' => array( 19 'path' => array('type' => 'varchar', 'length' => '255', 'not null' => TRUE, 'default' => ''), 20 'last_access' => array('type' => 'int', 'not null' => TRUE, 'default' => 0, 'disp-width' => '11'), 21 'bytes_max' => array('type' => 'int', 'not null' => TRUE, 'default' => 0, 'disp-width' => '11'), 22 'bytes_avg' => array('type' => 'int', 'not null' => TRUE, 'default' => 0, 'disp-width' => '11'), 23 'ms_max' => array('type' => 'int', 'not null' => TRUE, 'default' => 0, 'disp-width' => '11'), 24 'ms_avg' => array('type' => 'int', 'not null' => TRUE, 'default' => 0, 'disp-width' => '11'), 25 'query_count_max' => array('type' => 'int', 'not null' => TRUE, 'default' => 0, 'disp-width' => '11'), 26 'query_count_avg' => array('type' => 'int', 'not null' => TRUE, 'default' => 0, 'disp-width' => '11'), 27 'query_timer_max' => array('type' => 'int', 'not null' => TRUE, 'default' => 0, 'disp-width' => '11'), 28 'query_timer_avg' => array('type' => 'int', 'not null' => TRUE, 'default' => 0, 'disp-width' => '11'), 29 'num_accesses' => array('type' => 'int', 'not null' => TRUE, 'default' => 0, 'disp-width' => '11'), 30 ), 31 'primary key' => array('path'), 32 'indexes' => array( 33 'last_access' => array('last_access')), 34 ); 35 36 $schema['performance_detail'] = array( 37 'fields' => array( 38 'pid' => array('type' => 'serial', 'not null' => TRUE, 'disp-width' => '11'), 39 'timestamp' => array('type' => 'int', 'not null' => TRUE, 'default' => 0, 'disp-width' => '11'), 40 'bytes' => array('type' => 'int', 'not null' => TRUE, 'default' => 0, 'disp-width' => '11'), 41 'ms' => array('type' => 'int', 'not null' => TRUE, 'default' => 0, 'disp-width' => '11'), 42 'query_count' => array('type' => 'int', 'not null' => TRUE, 'default' => 0, 'disp-width' => '11'), 43 'query_timer' => array('type' => 'int', 'not null' => TRUE, 'default' => 0, 'disp-width' => '11'), 44 'anon' => array('type' => 'int', 'not null' => FALSE, 'default' => 1, 'disp-width' => '1'), 45 'path' => array('type' => 'varchar', 'length' => '255', 'not null' => FALSE), 46 'data' => array('type' => 'blob', 'not null' => FALSE, 'size' => 'big'), 47 ), 48 'primary key' => array('pid'), 49 'indexes' => array( 50 'timestamp' => array('timestamp')), 51 ); 52 53 return $schema; 54 } 55 56 function performance_install() { 57 drupal_install_schema('performance'); 58 59 // Set the weight so this module runs last 60 db_query("UPDATE {system} SET weight = 3000 WHERE name = 'performance'"); 61 } 62 63 function performance_uninstall() { 64 drupal_uninstall_schema('performance'); 65 db_query("DELETE FROM {variable} WHERE name LIKE 'performance%'"); 66 } 67 68 function performance_requirements($phase) { 69 $requirements = array(); 70 71 if ($phase != 'runtime') { 72 return $requirements; 73 } 74 75 if (variable_get('performance_detail', 0)) { 76 $requirements['performance_detail'] = array( 77 'title' => t('Performance logging details'), 78 'value' => 'Enabled', 79 'severity' => REQUIREMENT_WARNING, 80 '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'))), 81 ); 82 } 83 84 if (variable_get('dev_query', 0)) { 85 if (variable_get('performance_detail', 0) || 86 variable_get('performance_summary_db', 0) || 87 variable_get('performance_summary_apc', 0)) { 88 $requirements['performance_query'] = array( 89 'title' => t('Performance logging query'), 90 'value' => 'Enabled', 91 'severity' => REQUIREMENT_WARNING, 92 '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'))), 93 ); 94 } 95 } 96 97 if (!function_exists('apc_fetch')) { 98 $requirements['performance_apc'] = array( 99 'title' => t('Performance logging APC'), 100 'value' => 'Disabled', 101 'severity' => REQUIREMENT_WARNING, 102 'description' => t('Performance logging on live web sites works best if APC is enabled.'), 103 ); 104 } 105 106 $shm_size = ini_get('apc.shm_size'); 107 if (function_exists('apc_fetch') && $shm_size < PERFORMANCE_MIN_MEMORY) { 108 $requirements['performance_apc_mem'] = array( 109 'title' => t('Performance logging APC memory size'), 110 'value' => $shm_size, 111 'severity' => REQUIREMENT_WARNING, 112 '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)), 113 ); 114 } 115 116 return $requirements; 117 } 118 119 function performance_update_1() { 120 $ret = array(); 121 db_drop_field($ret, 'performance_detail', 'title'); 122 db_drop_field($ret, 'performance_summary', 'title'); 123 return $ret; 124 } 125 126 function performance_update_2() { 127 $ret = array(); 128 db_add_field($ret, 'performance_detail', 'data', array('type' => 'blob', 'not null' => FALSE, 'size' => 'big')); 129 return $ret; 130 } 131 132 /** 133 * Harmonize notations for milliseconds to "ms". 134 * 135 * @return array 136 */ 137 function performance_update_6001() { 138 $int_field = array('type' => 'int', 'not null' => TRUE, 'default' => 0, 'disp-width' => '11'); 139 140 $ret = array(); 141 db_change_field($ret, 'performance_summary', 'millisecs_max', 'ms_max', $int_field); 142 db_change_field($ret, 'performance_summary', 'millisecs_avg', 'ms_avg', $int_field); 143 db_change_field($ret, 'performance_detail', 'millisecs', 'ms', $int_field); 144 145 // We don't have a cache update method, so it's better to clear it 146 if (function_exists('apc_fetch')) { 147 apc_clear_cache('user'); 148 } 149 return $ret; 150 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated: Mon Jul 9 18:01:44 2012 | Cross-referenced by PHPXref 0.7 |