jenkins-bot has submitted this change and it was merged.
Change subject: Add role::profiler utilizing XHProf
......................................................................
Add role::profiler utilizing XHProf
Adds a profiling role which installs xhprof from pecl and enables its web
interface on /xhprof of the devwiki http server.
One issue remaining in regards to utilizing disable-role. The only part that
gets uninstalled when removing the role is the apache configuration. The php
config installed by php::ini will still be in /etc/php5/conf.d/xhprof.ini and
loaded. The module installed in /usr/lib/php/20090626/xhprof.so will also still
be in place. Additionally the assets and code files installed to /usr/share/php
are left behind. In general this isn't a big deal, but worth mentioning.
Change-Id: I12b7041739ba1a4ba9b3c651c99c801123252e56
---
M puppet/manifests/roles.pp
A puppet/modules/xhprof/files/xhprof-apache-config
A puppet/modules/xhprof/manifests/init.pp
3 files changed, 104 insertions(+), 0 deletions(-)
Approvals:
Ori.livneh: Looks good to me, approved
jenkins-bot: Verified
diff --git a/puppet/manifests/roles.pp b/puppet/manifests/roles.pp
index d253dcc..bd6d611 100644
--- a/puppet/manifests/roles.pp
+++ b/puppet/manifests/roles.pp
@@ -404,6 +404,28 @@
}
}
+# == Class role::xhprof
+# This class enables support for function-level hierarchical profiling of PHP
+# using XHProf. The graphical interface for the profiler is available at
+# /xhprof on the same port as the wiki.
+#
+# You can add the following code to $IP/StartProfiler.php to use XHProf with
+# MediaWiki:
+#
+# xhprof_enable( XHPROF_FLAGS_CPU | XHPROF_FLAGS_MEMORY );
+# register_shutdown_function( function() {
+# $profile = xhprof_disable();
+# require_once 'xhprof_lib/utils/xhprof_runs.php';
+# $runs = new XHProfRuns_Default();
+# $runs->save_run( $profile, 'mw' );
+# } );
+#
+class role::xhprof {
+ include role::mediawiki
+
+ include xhprof
+}
+
# == Class: role::multimedia
# This class configures MediaWiki for multimedia development.
# It is meant to contain general configuration of shared use to other
diff --git a/puppet/modules/xhprof/files/xhprof-apache-config
b/puppet/modules/xhprof/files/xhprof-apache-config
new file mode 100644
index 0000000..4d83082
--- /dev/null
+++ b/puppet/modules/xhprof/files/xhprof-apache-config
@@ -0,0 +1,11 @@
+# vim: filetype=apache sts=4 sw=4 autoindent
+#
+# Apache site configuration for XHProf
+# This file is managed by Puppet.
+#
+
+<Directory /usr/share/php/xhprof_html>
+</Directory>
+
+Alias /xhprof "/usr/share/php/xhprof_html"
+
diff --git a/puppet/modules/xhprof/manifests/init.pp
b/puppet/modules/xhprof/manifests/init.pp
new file mode 100644
index 0000000..d185d04
--- /dev/null
+++ b/puppet/modules/xhprof/manifests/init.pp
@@ -0,0 +1,71 @@
+# == Class: xhprof
+#
+# This Puppet class configures XHProf, a function-level hierarchical
+# profiler for PHP with a simple HTML based navigational interface.
+#
+# === Parameters
+#
+# [*profile_storage_dir*]
+# Path where profiles should be stored. Default: '/vagrant/profiles'.
+#
+class xhprof (
+ $profile_storage_dir = '/vagrant/profiles'
+) {
+
+ $xhprof_version = '0.9.4'
+ $installed_module = '/usr/lib/php5/20090626/xhprof.so'
+
+ exec { 'download xhprof':
+ cwd => '/tmp',
+ creates => $installed_module,
+ command => "wget http://pecl.php.net/get/xhprof-${xhprof_version}.tgz",
+ }
+
+ exec { 'extract xhprof':
+ cwd => '/tmp',
+ command => "tar -xzf xhprof-${xhprof_version}.tgz",
+ creates => $installed_module,
+ require => Exec['download xhprof'],
+ }
+
+ exec { 'install xhprof':
+ cwd => "/tmp/xhprof-${xhprof_version}/extension",
+ command => 'phpize && ./configure && make && make install',
+ creates => $installed_module,
+ require => [ Exec['extract xhprof'], Package['php5-dev'] ],
+ }
+
+ exec { 'install xhprof assets':
+ cwd => "/tmp/xhprof-${xhprof_version}",
+ command => "cp -rf /tmp/xhprof-${xhprof_version}/xhprof_html
/tmp/xhprof-${xhprof_version}/xhprof_lib /usr/share/php",
+ creates => '/usr/share/php/xhprof_html',
+ # php-pear ensures existance of /usr/share/php, better way?
+ require => [ Exec['install xhprof'], Package['php-pear'] ],
+ }
+
+ php::ini { 'xhprof':
+ require => Exec['install xhprof'],
+ settings => {
+ 'extension' => 'xhprof.so',
+ # Not used by the extension directly, used by the
+ # XHProf_Runs utility class
+ 'xhprof.output_dir' => $profile_storage_dir,
+ }
+ }
+
+ # Directory used, by default, to store profile runs
+ file { $profile_storage_dir:
+ ensure => directory,
+ owner => 'vagrant',
+ group => 'www-data',
+ mode => 0775,
+ }
+
+ # Enable xhprof viewer on /xhprof directory of devwiki
+ @apache::conf { 'xhprof':
+ ensure => present,
+ site => $role::mediawiki::wiki_name,
+ source => 'puppet:///modules/xhprof/xhprof-apache-config',
+ require => Php::Ini['xhprof'],
+ }
+}
--
To view, visit https://gerrit.wikimedia.org/r/91122
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I12b7041739ba1a4ba9b3c651c99c801123252e56
Gerrit-PatchSet: 9
Gerrit-Project: mediawiki/vagrant
Gerrit-Branch: master
Gerrit-Owner: EBernhardson <[email protected]>
Gerrit-Reviewer: BryanDavis <[email protected]>
Gerrit-Reviewer: EBernhardson <[email protected]>
Gerrit-Reviewer: Ori.livneh <[email protected]>
Gerrit-Reviewer: jenkins-bot
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits