使用XHProf对drupal7.34实例进行概要分析后,我看到file_scan_dir调用的opendir函数递归到15深度需要很长的执行时间。 file_scan_dir又由drupal_system_listing(3次调用)
调用Function Calls Ex Wall Wall %
opendir 1608 500ms 27%
ob_flush 1 270ms 17%
is_dir 10,872 107ms 7%
preg_match 20,597 85ms 5%
关键设置
**php.ini (PHP5.3.3)**
memory_limit = 512MB
realpath_cache_size = 1024k
max_execution_time = 90
**apc.ini**
apc.shm_size=192M (free 100MB after several loads)
apc.stat=1
apc.stat_ctime=0
drupal文件在NFS文件系统上,所以我希望它有点慢。 当我更改apc.stat = 0并重新启动apache时。我希望opendir开销消失,因为大多数文件将从opcache中读取,但是在重新加载同一页面之后这些数字根本不会改变。
我确实检查过我没有丢失模块,这是drupal 7的一个已知问题。仍然看起来drupal正在搜索一些丢失的文件。
可能导致此问题的任何想法?
答案 0 :(得分:0)
我通过临时添加dpm(func_get_args())找到了问题;在bootstrap.inc中,如此处所述https://drupal.stackexchange.com/a/138345
原来 AT-commerce版本7.x-3.0 主题未正确检查导致严重性能下降的其他可选模块。
每次加载页面时修复程序保存超过900毫秒,这会产生很大的影响
我为drupal模块https://www.drupal.org/node/2406089提供了建议的修复程序 在此处列出完整性
/**
* Implements hook_css_alter().
*/
function at_commerce_css_alter(&$css) {
// Replace all Commerce module CSS files with our own for total control over all styles.
// Commerce module uses the BAT CSS file naming convention (base, admin, theme).
$path = drupal_get_path('theme', 'at_commerce');
// cart
if (module_exists('commerce_cart')){
$cart_theme = drupal_get_path('module', 'commerce_cart') . '/theme/commerce_cart. theme.css';
if (isset($css[$cart_theme])) {
$css[$cart_theme]['data'] = $path . '/css/commerce/commerce_cart.theme.css';
$css[$cart_theme]['group'] = 1;
}
}
// checkout
if (module_exists('commerce_checkout')){
$checkout_base = drupal_get_path('module', 'commerce_checkout') . '/theme/ commerce_checkout.base.css';
$checkout_admin = drupal_get_path('module', 'commerce_checkout') . '/theme/ commerce_checkout.admin.css';
$checkout_theme = drupal_get_path('module', 'commerce_checkout') . '/theme/ commerce_checkout.theme.css';
if (isset($css[$checkout_base])) {
$css[$checkout_base]['data'] = $path . '/css/commerce/commerce_checkout.base. css';
$css[$checkout_base]['group'] = 1;
}
if (isset($css[$checkout_admin])) {
$css[$checkout_admin]['data'] = $path . '/css/commerce/commerce_checkout.admin. css';
$css[$checkout_admin]['group'] = 1;
}
if (isset($css[$checkout_theme])) {
$css[$checkout_theme]['data'] = $path . '/css/commerce/commerce_checkout.theme. css';
$css[$checkout_theme]['group'] = 1;
}
}
// customer
if (module_exists('commerce_customer')){
$customer_admin = drupal_get_path('module', 'commerce_customer') . '/theme/ commerce_customer.admin.css';
if (isset($css[$customer_admin])) {
$css[$customer_admin]['data'] = $path . '/css/commerce/commerce_customer.admin. css';
$css[$customer_admin]['group'] = 1;
}
}
// file (contrib)
if (module_exists('commerce_file')){
$file_forms = drupal_get_path('module', 'commerce_file') . '/theme/commerce_file. forms.css';
if (isset($css[$file_forms])) {
$css[$file_forms]['data'] = $path . '/css/commerce/commerce_file.forms.css';
$css[$file_forms]['group'] = 1;
}
}
// line items
if (module_exists('commerce_line_item')){
$line_item_admin = drupal_get_path('module', 'commerce_line_item') . '/theme/ commerce_line_item.admin.css';
$line_item_theme = drupal_get_path('module', 'commerce_line_item') . '/theme/ commerce_line_item.theme.css';
if (isset($css[$line_item_admin])) {
$css[$line_item_admin]['data'] = $path . '/css/commerce/commerce_line_item.admin. css';
$css[$line_item_admin]['group'] = 1;
}
if (isset($css[$line_item_theme])) {
$css[$line_item_theme]['data'] = $path . '/css/commerce/commerce_line_item.theme. css';
$css[$line_item_theme]['group'] = 1;
}
}
// order
if (module_exists('commerce_order')){
$order_admin = drupal_get_path('module', 'commerce_order') . '/theme/ commerce_order.admin.css';
$order_theme = drupal_get_path('module', 'commerce_order') . '/theme/ commerce_order.theme.css';
if (isset($css[$order_admin])) {
$css[$order_admin]['data'] = $path . '/css/commerce/commerce_order.admin.css';
$css[$order_admin]['group'] = 1;
}
if (isset($css[$order_theme])) {
$css[$order_theme]['data'] = $path . '/css/commerce/commerce_order.theme.css';
$css[$order_theme]['group'] = 1;
}
}
// payment
if (module_exists('commerce_payment')){
$payment_admin = drupal_get_path('module', 'commerce_payment') . '/theme/ commerce_payment.admin.css';
$payment_theme = drupal_get_path('module', 'commerce_payment') . '/theme/ commerce_payment.theme.css';
if (isset($css[$payment_admin])) {
$css[$payment_admin]['data'] = $path . '/css/commerce/commerce_payment.admin. css';
$css[$payment_admin]['group'] = 1;
}
if (isset($css[$payment_theme])) {
$css[$payment_theme]['data'] = $path . '/css/commerce/commerce_payment.theme. css';
$css[$payment_theme]['group'] = 1;
}
}
// price
if (module_exists('commerce_price')){
$price_theme = drupal_get_path('module', 'commerce_price') . '/theme/ commerce_price.theme.css';
if (isset($css[$price_theme])) {
$css[$price_theme]['data'] = $path . '/css/commerce/commerce_price.theme.css';
$css[$price_theme]['group'] = 1;
}
}
// product
if (module_exists('commerce_product')){
$product_admin = drupal_get_path('module', 'commerce_product') . '/theme/ commerce_product.admin.css';
$product_theme = drupal_get_path('module', 'commerce_product') . '/theme/ commerce_product.theme.css';
if (isset($css[$product_admin])) {
$css[$product_admin]['data'] = $path . '/css/commerce/commerce_product.admin. css';
$css[$product_admin]['group'] = 1;
}
if (isset($css[$product_theme])) {
$css[$product_theme]['data'] = $path . '/css/commerce/commerce_product.theme. css';
$css[$product_theme]['group'] = 1;
}
}
// tax
if (module_exists('commerce_tax')){
$tax_admin = drupal_get_path('module', 'commerce_tax') . '/theme/commerce_tax. admin.css';
$tax_theme = drupal_get_path('module', 'commerce_tax') . '/theme/commerce_tax. theme.css';
if (isset($css[$tax_admin])) {
$css[$tax_admin]['data'] = $path . '/css/commerce/commerce_tax.admin.css';
$css[$tax_admin]['group'] = 1;
}
if (isset($css[$tax_theme])) {
$css[$tax_theme]['data'] = $path . '/css/commerce/commerce_tax.theme.css';
$css[$tax_theme]['group'] = 1;
}
}
}