Manual:Profiling/ja
プロファイリングは、ページ操作中のコード実行を追跡し、特定の機能に費やされたコード実行が全体に占める割合を報告します。 Profiling is an advanced task intended for developers and system administrators to track sources of slowness in MediaWiki that should be optimized.
PHP プロファイリング
Tideways also advertises a proprietary UI to visualize results, but you don't need that.
Install the php-tideways
package on Debian/Ubuntu, or Homebrew on macOS.
For XDebug, see XDebug profiling documentation.
For command line scripts, you can use php -d xdebug.mode=profile maintenance/{script}
.
Webgrind can then be used to view profile results.
MediaWiki カスタム プロファイラー
wfProfileIn
/wfProfileOut
) are deprecated, were no-ops since MediaWiki 1.25+, and were removed in 1.31.MediaWiki バージョン: | <translate> ≥</translate> 1.25 |
In MediaWiki 1.25 profiling was completely rewritten and many settings previous relating to profiling were removed in favor of consolidating them as parameters to $wgProfiler. Notably, output has been separated from class types. For documentation about profiling prior to 1.25, see an older version of this page.
Example $wgProfiler configuration:
<?php
$wgProfiler['class'] = 'ProfilerXhprof';
$wgProfiler['output'] = [ 'ProfilerOutputText' ];
$wgProfiler['visible'] = true;
Each of these parameters (and more) are described in detail:
- class
- 'ProfilerXhprof'. ProfilerXhprof is new in MediaWiki 1.25 and provides an Xhprof-backed profiler that captures profiling data for all functions as well as sub-functional units. Old values such as ProfilerStandard, ProfilerUDP, ProfilerDB, etc do not work. Even if you are using Tideways, still specify the ProfilerXhprof class.
- output
- One or more of 'ProfilerOutputText', 'ProfilerOutputDump', 'ProfilerOutputStats'[1]. Text outputs the information in either HTML comments or after the skin. UDP is a format send to a udpprofile daemon. Dump produces a dump of the profiling info for use with xhprof GUI (xhprofgui role on Vagrant setup).
- outputDir
- Only applies to 'ProfilerOutputDump' format. Required to specify where the dump files will be stored.
- visible
- Only applies to 'ProfilerOutputText' format. Whether text is shown after the skin or in an HTML comment.
Maintenance scripts
Maintenance scripts support a --profiler option.
This changes the output method of the profiler as well as ensuring its enabled in the CLI.
Because this only changes the output method and not the profiler class, you still must have some sort of profiling setup in $wgProfiler
.
Troubleshooting
If you get "Fatal error: Uncaught Exception: Neither xhprof nor tideways are installed" then you need to do:
$ sudo apt install php-tideways
$ sudo service apache2 restart
If you still get an error, then take a look at https://tideways.com/profiler/xhprof-for-php7
出力
テキストをこのように出力します
100.00% 508.972 1 - main()
96.67% 492.003 1 - MediaWiki::run
96.61% 491.699 1 - MediaWiki::main
87.12% 443.434 1 - MediaWiki::performRequest
84.16% 428.356 1 - SpecialPageFactory::executePath
84.11% 428.073 1 - SpecialPage::run
84.10% 428.058 1 - SpecialRecentChanges::execute
63.82% 324.838 1 - ChangesListSpecialPage::execute
57.07% 290.495 1 - ChangesListSpecialPage::webOutput
51.06% 259.877 1 - SpecialRecentChanges::outputChangesList
44.72% 227.633 397 - Wikimedia\Rdbms\Database::query
31.07% 158.155 922 - Message::fetchMessage
30.61% 155.788 865 - MessageCache::get
29.55% 150.398 398 - Wikimedia\Rdbms\Database::doProfiledQuery
29.39% 149.570 865 - MessageCache::getMessageFromFallbackChain
29.26% 148.923 869 - MessageCache::getMessageForLang
29.06% 147.931 393 - Wikimedia\Rdbms\Database::select
27.30% 138.962 1 - EnhancedChangesList::endRecentChangesList
27.30% 138.960 1 - EnhancedChangesList::recentChangesBlock
...
The first column is the time percent; the second column is the time (in ms); the third column is the count; and the fourth column is the name of the method.
関連項目
脚注
- ↑ See git #750e4eb9
Code steward
- <translate> Maintained by <tvar name=1>MediaWiki Platform Team</tvar>.</translate>
- <translate> Live chat ([[<tvar name=1>Special:MyLanguage/MediaWiki on IRC</tvar>|IRC]]): <tvar name=2><span class="plainlinks" style="font-family: monospace,Courier; white-space: pre-wrap !important; word-wrap: break-word; max-width: 1200px; overflow: auto;" title="<translate nowrap> <tvar name=1>#mediawiki-core</tvar> on Libera.Chat IRC</translate>">#mediawiki-core <translate> connect</translate></tvar></translate>
- <translate> Issue tracker: [<tvar name=url>https://phabricator.wikimedia.org/tag/mediawiki-core-profiler/</tvar> Phabricator <tvar name=phab>MediaWiki-Core-Profiler</tvar>] ([<tvar name=url2>https://phabricator.wikimedia.org/maniphest/task/edit/form/1/?projects=mediawiki-core-profiler</tvar> Report an issue])</translate>