Commit graph

92 commits

Author SHA1 Message Date
Ori Livneh
27b9c0639d Simplify profiler output class selection
Instead of maintaining a mapping of short names to class names ('db' =>
'ProfilerOutputDb', etc.), let us adopt the convention of using the full
class name to indicate the output type. We can maintain backward-compatibility
by using simple string manipulation to transform short names to the full class
names.

Change-Id: I976e0da2873d88b9892fb41823cfe3af0a2d3974
2015-04-02 11:01:52 -07:00
Ori Livneh
4e5d016e72 Follow-up to Icf644ad34: Introduce ProfilerOutputStats
Change-Id: Ib3585303b75899c4cd7c9c88fb3473b441e52c23
2015-04-01 21:09:20 -07:00
Ori Livneh
1b6f70089d Introduce ProfilerOutputStats
* Associate Profiler objects with a request context by adding a $context
  property with a getter and a setter.
* Introduce ProfilerOutputStats, which writes profiling data to the stats
  buffer associated with the current request context.
* Make it the Profiler class's responsibility to enforce $wgProfilerLimit.
* Deprecate $wgProfilerLimit in favor of the (more aptly named, IMO)
  $wgProfiler['threshold'] config setting.
* Tidy up Profiler instance creation code in Profiler::instance().
* Add Profiler::getOutputs, which returns an array of ProfilerOutput instances
  which are configured for the current profiler and whose canUse() method
  returns true.
* Make ProfilerStub not log by creating a stub ProfilerStub::logData() method
  which does not call the parent. Previously the parent class checked if $this
  was an instance of ProfilerStub and returned early if so.

Task: T90623
Task: T85641
Change-Id: Icf644ad3435c1f30d0a49957a97b481808a3153d
2015-04-02 01:32:46 +00:00
Aaron Schulz
5012ac6c6a Made ProfilerStub return null instead of a dummy ScopedCallback
* This can happen well over 10k times per request due to the message
  hooks. Avoiding the object construction seems prudent.

Change-Id: I45ff7b8c10851f15a25cbea9a2df3669ec21dbd3
2015-03-25 20:50:41 -07:00
Stanislav Malyshev
750e4eb9d9 Allow dumping raw xhprof data for consumption by xhprof GUI
Change-Id: Iab90cef1c61b92ffc6d46a6bc93a03cf7bc2adb9
2015-03-04 01:29:02 +00:00
Chad Horohoe
ef621e06eb Make Profiler::$instance private and drop double underscores
Nothing calls it anymore outside of the class

Change-Id: Icc9ebcd63e440f9bafca29647856d36fc493ff39
2015-02-12 12:54:11 -08:00
Niklas Laxström
a7f7f8cbcb Unbreak master by restoring Profiler::profile(In|Out)
Keep functions in the abstract class to keep BC with SMW.

To I781f62be9

Change-Id: I81d3912cbffc88ed66c9d6d787db9f1ffe3b2de3
2015-01-09 09:17:13 +00:00
Aaron Schulz
4236b9beb6 Made profileIn/profileOut methods a no-op
Change-Id: I781f62be9747bb41af6faad6fbe265414fb77669
2015-01-08 01:54:51 -08:00
Aaron Schulz
e145b81e5d Refactored xhprof getFunctionReport() to use getFunctionStats()
* Also added more doc comments to getFunctionStats()

Change-Id: I3741713d3c80b0bbc622eb17ce4c3a047bf5a06c
2014-12-08 23:39:18 +00:00
Aaron Schulz
7dba64f2c1 Revert "Remove deprecated profiling config parameters, clarify docs"
StatCounter still needs $wgUDPProfilerHost.

This reverts commit 88c42dc1df.

Change-Id: I4a56f6fb6bc454d15a9dc752f45dfb29b2b47a84
2014-12-04 21:40:13 +00:00
Chad Horohoe
88c42dc1df Remove deprecated profiling config parameters, clarify docs
We've already broken profiling completely in this release. Make
this abundantly clear in the RELEASE-NOTES and just remove the
awful back-compat attempt from I2af28cd3 and I49c0a83e.

Change-Id: Ib0b87192e2a6e87db19f7821906dd7b2063081e3
2014-12-04 12:51:19 -08:00
Chad Horohoe
52f3b13312 Remove Profiler::isStub()
Just check for ProfilerStub directly.

Change-Id: I503916599f182df4206da5282193ae6ec9324ee6
2014-12-03 20:19:56 -08:00
Aaron Schulz
240152117c Added custom frame support to Profiler
* Made use of it in the DatabaseBase classes
* For the xhprof class, this only works in HHVM for now

Change-Id: I95d7cc128d4a770328fbdd2b546972d3fc2e2e8a
2014-11-25 14:52:21 -07:00
Aaron Schulz
66170e7e59 Adding basic profiler sampling support and restored the --profiler script option
* Also enforce that the profiler is normally off in CLI mode

Change-Id: I35faedff818af2ad459b544c9ad50e77b54b378e
2014-11-21 15:14:18 -08:00
Timo Tijhof
8e765baa8c profiler: Simplify code for class name mapping
Follows-up 000c6529d. Handle errors first.

Change-Id: I70308783a2e8b140b3c850758cce36544b32eb20
2014-11-18 20:46:41 +00:00
jenkins-bot
c5cdba22fa Merge "ProfilerOutput: Remove logStandardData() and make log() abstract" 2014-11-18 20:02:06 +00:00
Chad Horohoe
d1f1f9d98d ProfilerOutput: Remove logStandardData() and make log() abstract
Became unused layer of abtraction as I266ed820 went through iterations

Change-Id: Ic739fb4519bb2e23e679828b191c11c0158ade78
2014-11-18 11:51:49 -08:00
Kunal Mehta
000c6529d8 Profiler: Explicitly convert output type to class name
Follows-up b8d93fb4fd.

Change-Id: I50faa25fdc4fb980e0ff71014b8d1b2a5818af80
2014-11-18 11:12:07 -08:00
Chad Horohoe
b8d93fb4fd Refactor profiling output from profiling
* Added a standard getFunctionStats() method for Profilers to return
  per function data as maps. This is not toolbar specific like getRawData().
* Cleaned up the interface of SectionProfiler::getFunctionStats() a bit.
* Removed unused cpu_sq, real_sq fields from profiler UDP output.
* Moved getTime/getInitialTime to ProfilerStandard.

Co-Authored-By: Aaron Schulz <aschulz@wikimedia.org>
Change-Id: I266ed82031a434465f64896eb327f3872fdf1db1
2014-11-17 19:26:04 -07:00
Chad Horohoe
4fa6c46c94 Remove per-template profiling
Creates absurd dependency on the profiler from the parser. This profiling
is also not compatible with function-level profiling that we're trying to
aim for with xhprof.

Change-Id: I3c780fcb06e3470a0cbf50311ba916a0b67ea49e
2014-11-12 18:18:30 -08:00
Bryan Davis
46c47e11bc Enable profiling via xhprof
Add a helper class to assist in collecting profiling information using
XHProf <https://github.com/phacility/xhprof> and a Profiler
implementation to hook it into the existing MediaWiki profiling system.

The Profiler includes support for generating tabular reports similar to
the traditional output of ProfilerSimpleText and ProfilerSimpleTrace or
sending data to a udpprofile daemon as supported by ProfilerSimpleUDP.
It also produces data compatible with the debugging toolbar.

Bug: T759
Change-Id: I16a75cb7636cb5dcef3830d738b2dcd2047d0aaa
2014-11-08 11:47:25 -07:00
jenkins-bot
2f97bc63f1 Merge "Profiler: Move debug(Group)() to ProfilerStandard, not used elsewhere" 2014-11-06 19:27:02 +00:00
Chad Horohoe
1aa7a72508 Profiler: Move debug(Group)() to ProfilerStandard, not used elsewhere
Change-Id: I6066d0e2a80d04808f772396f578521857d6c550
2014-11-06 19:20:28 +00:00
Chad Horohoe
8784f22964 Profiling: remove "m" prefixes from variables since they're pointless
Change-Id: I88cdbac935d6d908fa3745634922a0bb70c0dbc8
2014-11-06 19:17:26 +00:00
Aaron Schulz
671bcd8d27 Changed TransactionProfiler to only work via the DB classes
* This makes it work with xhprof/xdebug, though it will only examine DB queries.

Change-Id: I999b66e6c3af88dda408b2252c248e085af9eea4
2014-11-06 10:30:51 -08:00
Chad Horohoe
bb025faa19 Remove Profiler::setInstance()
This is a weird construction that only existed for dumpHTML.
DumpHTML will no longer require this as of Ia38aa904.

It won't work with future plans to separate profiling & profiling
output

Change-Id: I4d7806596fa233a2b2d1d691c8adfa68724f20f5
2014-11-04 22:01:12 +00:00
Chad Horohoe
4e61f1bb8b Profiler code cleanup
- Put Profiler, ProfileSection and TransactionProfiler in their own
  files and rely on Autoloader to use them (maintenance has been
  using the autoloader here for some time--we don't profile the
  autoloader manually)
- This reduces overhead in WebStart/doMaintenance by only loading
  three functions at profiler initialization and defers until the
  first profiling call happens
- Inline callback functions in ProfilerSimpleText rather than having
  public static functions.
- Small comment and code formatting changes in various touched files.

Change-Id: Idf27677c068c50b847152c523a33e7f0c33fdeeb
2014-11-04 21:14:51 +00:00
Chad Horohoe
d4c77064a2 Remove back-compat profiling configuration
This old style was deprecated like 3 or 4 releases ago

Change-Id: Ic61424aacb376151019a08ade214fea655d82a3f
2014-10-28 17:21:23 -07:00
Ori Livneh
4ee9063956 Under HHVM, measure resources for the thread, not calling process
As of <https://github.com/facebook/hhvm/commit/0f98cab>, it is possible to
call getrusage( [ int $who = 0 ] ) with $who = 2 to request resource usage
info for the current thread (RUSAGE_THERAD), rather than the calling process
(RUSAGE_SELF). (Earlier versions of HHVM return RUSAGE_SELF data unless $who
is 1.)

PHP5 code can assume that each request is handled in a dedicated subprocess,
but the same is not true of HHVM, which is multi-threaded. Therefore, to get
resource usage data for the current request context, it is necessary to ask
for RUSAGE_THREAD rather than RUSAGE_SELF.

To do this, introduce a new global function in Profiler.php: wfGetRusage().
It is defined there and not in GlobalFunctions.php so that it can be used early
in WebStart.php.

Bug: 70227
Change-Id: Ibe9598ecdfc0f6c434f8b3c7a94f06a7b2fcca23
2014-09-10 12:03:32 -07:00
umherirrender
dd8921c9d9 Cleanup some docs (includes/[m-r])
- Swap "$variable type" to "type $variable"
- Added missing types
- Fixed spacing inside docs
- Makes beginning of @param/@return/@var/@throws in capital
- Changed some types to match the more common spelling

Change-Id: I8ebfbcea0e2ae2670553822acedde49c1aa7e98d
2014-07-24 19:43:25 +02:00
umherirrender
abfa0d7854 Standardize @todo
Always use lowercase @todo
Changed some "@FIXME" to "@todo FIXME: "

Change-Id: I016d1f9511e6f3bbd22427f0fffeccd77ab5e0db
2014-07-23 22:27:20 +02:00
umherirrender
2b021dc48a Fixed spacing
- Added/removed spaces around parenthesis
- Added space after switch/if/foreach
- changed else if to elseif

Change-Id: I99cda543e0e077320091addd75c188cb6e3a42c2
2014-07-19 23:12:10 +02:00
Aaron Schulz
630284a62a Added some sanity warnings to TransactionProfiler
* The use of $id should avoid any nesting, unless something is broken

Change-Id: I01941a186d1e74ddd6c4610b0eb9e15f54e28347
2014-06-27 11:40:50 -07:00
Aaron Schulz
a1bc02ec8b Include trx state in query profiling (and DBPerformance log)
* Replaced use of spl hash with random transaction IDs.
  These can be correlated better and make the DBPerformance
  log easier to make sense of. They are also shorter.

Change-Id: I5f49c0d0c26e37807341bbc83b1b41b124164419
2014-06-25 14:13:25 -07:00
Aaron Schulz
2dcf1395c5 Lowered the TransactionProfiler threshold
Change-Id: Id574e8d2b2a28cba3003d6a344a4afb0307699e3
2014-06-05 15:59:07 -07:00
Aaron Schulz
60e65d8d8d Made TransactionProfiler handle interlaced transactions better
* Previously the list of involved DBs might be incomplete

Change-Id: I75b91d3b9a951169038b40b9cf2f59707ba0c11d
2014-05-29 14:47:59 -07:00
Siebrand Mazeland
1c0980ebb0 Pass phpcs-strict on includes/profiler/
Change-Id: Ic9058a650ea0735b71b3725703d76cc62b5c9fb1
2014-05-10 10:45:53 +02:00
Aaron Schulz
28bed62ae6 Made TransactionProfiler handle nested transactions to the same server/DB
Change-Id: Ie4dfd4af88a9da76c76b21053bbd125c6ad3b193
2014-05-01 19:38:39 +00:00
Aaron Schulz
63b1f29d76 Fixed call to undefined method in TransactionProfiler
Change-Id: I855b514f8b63c7e81935b13df4612f09628142b3
2014-04-28 17:57:55 +00:00
umherirrender
23bb3d1cb4 Follow-Ups to "Fixed some @params documentation"
Fix of inline comments of the following patch sets:
Follow-Up: I0056b4a8df243cfc0c5f25378de48f7a35170aca
Follow-Up: I7f605aa9e117b5fd80d9b1440864fe526d2b14a5
Follow-Up: I3622f216a2ca8ac1b5e51892be9f98665f65bc36
Follow-Up: I6627ba0e76d3577c40bf2473e0f78a5ad7368634
Follow-Up: Id75b5ecf648ca50f955b3bde3307c82c4366b102
Follow-Up: I4ca5231119f33039d91da3b57a41cd40719a576b

Change-Id: Id9bbe84b2820e9db44af5783411e955f55f643d4
2014-04-23 13:39:49 +02:00
umherirrender
a3983418d5 Fixed some @params documentation (includes/*)
Swapped some "$var type" to "type $var" or added missing types
before the $var. Changed some other types to match the more common
spelling. Makes beginning of some text in captial.
Also added some missing @param.

Change-Id: I0056b4a8df243cfc0c5f25378de48f7a35170aca
2014-04-22 13:07:02 +02:00
Aaron Schulz
9c586d6361 More Profiler class refactoring
* Factored a ProfilerStandard class out of Profiler
* Profiler is now an abstract base class
* For b/c, using Profiler as the profiler switches to ProfilerStub
  to avoid trying to instantiate an abstract class
* Also factored out a small TransactionProfiler class
* Fixed fatal in "new ProfilerStub()" line in getInstance();
  Profiler has long since type hinted $params as an array
* Removed bogus debug var usage left in ProfilerMwprof::getRawData()
* Removed useless mTimeMetric stuff

Change-Id: I854dabba6c8b1fb7d92baca59ebd4af25878d11d
2014-04-21 10:54:51 -07:00
umherirrender
b45420410f Fixed some @params documentation (includes/*)
Swapped some "$var type" to "type $var" or added missing types
before the $var. Changed some other types to match the more common
spelling. Makes beginning of some text in captial.
Also added some missing @param.

Change-Id: Iced714bca004756b461b66067a49a925a7e3b877
2014-04-19 22:22:20 +02:00
Aaron Schulz
afa6af07d7 Profiler class refactoring
* Merged the "collate at end" and "running collate" logic
  into the base class to make it more unified and consistent.
* Pulled out DB code into ProfilerSimpleDB class.
* Removed the ProfilerSimple class and updated child classes.
* Made ProfilerSimpleTrace set the debug information too.
* Work around "ended by close()" bug from 99aef03f. Since the
  getRawData() method gets called while some wfProfileOut() calls
  have not yet happened, make it use the matched call data and let
  the final logData() method work on the full data as normal.
* Let ProfilerSimple classes use getFunctionReport() for the profiler
  debug log if it is setup instead of making it just return "".
* Made getRawData() work as best as possible with ProfilerMwprof.
* Removed $wgProfileToDatabase since it is now useless.
* Improved DB profile performance with sqlite.
* Updated visibility of various methods.

Change-Id: I1260bab2b5ba12dccbba701bcae4a637cb85c6e8
2014-04-14 16:46:55 +00:00
Erik Bernhardson
99aef03f04 Visualize profile output in debug toolbar
This adds a new pane for the debug toolbar labeled Profiler.  It groups
together events sent to wfProfileIn/Out and draws a timeline giving a
visual representation of what the page was doing at a particular point
in time. Hovering over a timeline brings up a flyout about the contained
events.

Depends on I08854d80f57286129f19cb14566f84ed3c7fa21c for proper positioning
of the flyout.

Change-Id: I23a0ce4137abcd74ad87967fb263214c08cb9685
2014-04-02 21:53:51 +00:00
Alexandre Emsenhuber
811a084abf New 'profileerror' log group for profiling errors
Easier to catch them than if they are in the default debug log.

Added Profiler::debugGroup() as wrapper to wfDebugLog(), as
there already is Profiler::debug() for wfDebug(), so that
there won't be a fatal error if the error happens before the
inclusion of GlobalFunctions.php and converted other calls
to wfDebugLog() to use it.

Change-Id: Ie8481a2e13a94efa0248dd5a36b6b1a22811817e
2014-03-15 21:43:39 +01:00
umherirrender
0bc583af2c Move closing parenthesis from multi line if and function to own line
The Line continuation Coding conventions prefers the closing parenthesis
on the same line than the beginning curly braces. This is done for ifs
and functions.
Also move some boolean operator from the end of a line to the beginning
and changed some indentation to make the condition hopefully better
readable.

Change-Id: Id0437b06bde86eb5a75bc59eefa19e7edb624426
2013-12-01 21:39:00 +01:00
MatmaRex
df8ec1e216 No spaces after (casts)
Also removed some unnecessary ones. I think I've caught them all.

The spaceless version already appears in core ~300 times (after
accounting for false positives when grepping). Some consistency would
be nice.

Change-Id: I607655b5f4366e66dc78730d5fd2f57ed8776cae
2013-09-04 20:05:43 +02:00
Kevin Israel
0643e83df7 Profiler: remove unnecessary checks
Should slightly reduce overhead.

Change-Id: Iff71041f1cbc12b0d28f24752a01c63456cb9eaf
2013-08-25 22:46:55 +00:00
Aaron Schulz
138d5dc92c Typo fix
Change-Id: I778f1291cfcc1b6cc5441898607e4c1341c9f6df
2013-08-02 16:48:40 -07:00