Commit graph

112 commits

Author SHA1 Message Date
Daimona Eaytoy
b1a5367ec8 Fix new phan errors, part 7
Bug: T231636
Change-Id: Ia5e0abee7163c5a1abd0bb53b89603cc2e7a9b5c
2019-10-21 22:10:20 +00:00
Timo Tijhof
8a87ec2778 profiler: Centralise output responsibility from ProfilerOutputText to Profiler
Make it Profiler.php's responsibility to enforce this, based on the
existing signal from ProfilerOutput::logsToOutput().

The ProfilerOutputText class should not have to double-check this
a second time.

Long-term, I'd like even this check in Profiler::logDataPageOutputOnly
to be removed, because really the external caller of that should
know whether it is safe to output stuff or not rather than stashing
its own state inside Profiler::$allowOutput and then implicitly
reading it back out again later on. But, that's for another time.

Also:
* Remove use of deprecated Profiler::setTemplated while at it.
* Make 'visible' parameter explicit, as for other parameters.

Change-Id: Iaa3fc4ea25a059b90235d769db60c04b8f152f05
2019-08-28 16:07:18 +00:00
Timo Tijhof
bc7c85d609 profiler: Rename Profile::setTemplated to Profile::setAllowOutput
This is set from three places:
1) SkinTemplate.php, 2) Maintenance.php, and 3) load.php.

These last two are very much *not* HTML-templated output.
Rename these this method pair to getAllowOutput/setAllowOutput instead,
which is less confusing going forward. No known callers outside of
core (updated in the next commit), but I'll keep compat for one
release cycle just in case.

Change-Id: I828f95332dca3c6766b2b485ffb71762542b42d7
2019-08-28 01:10:56 +00:00
Aaron Schulz
93f29a1286 Deprecate Profiler::profileIn and Profiler::profileOut stubs
Change-Id: I2a8764d2464883e9fe66048e97b688c5a76d595a
2019-03-14 23:03:44 +00:00
Aaron Schulz
58ee03b13d Avoid sending duplicate ProfilerOutputText comments/html
Change-Id: I4130845cdb7208b8456740e5dbaf8bf96e175f49
2019-03-13 10:27:38 -07:00
Aaron Schulz
5196ac32c6 Rename WikiMap DB domain ID methods to reduce confusion with web domains
Those added in this same release do not need alias methods.

Change-Id: I05feeb9b0b13afe43aea1f95551965489cdbe094
2019-02-06 12:28:45 -08:00
Aaron Schulz
42a6f991e0 Use new WikiMap::getCurrentWikiDomain() for objectcache and profiler keyspace
Change-Id: I0e77c58a55b7ce908ec1d6399ec6629d00a48953
2018-10-30 06:41:07 +00:00
Umherirrender
130ec2523d Fix PhanTypeMismatchDeclaredParam
Auto fix MediaWiki.Commenting.FunctionComment.DefaultNullTypeParam sniff

Change-Id: I865323fd0295aabd06f3e3c75e0e5043fb31069e
2018-07-07 00:34:30 +00:00
Aaron Schulz
07c38641b2 Fix Profiler::getOutputs() type documentation
Change-Id: I4ff2ccc16363bfc3093b75263da2b09c3af40627
2018-02-22 10:58:36 -08:00
Umherirrender
3124a990a2 Use ::class to resolve class names in includes files
This helps to find renamed or misspelled classes earlier.
Phan will check the class names

Change-Id: I07a925c2a9404b0865e8a8703864ded9d14aa769
2018-01-27 20:34:29 +01:00
Kunal Mehta
251a0b97e5 Treat phpdbg as run from the command line when checking PHP_SAPI
phpdbg is a gdb-style debugger for PHP that is run from the command
line. However, it has a different PHP_SAPI value, so it was impossible
to run maintenance scripts with it (until now).

To avoid having to check both PHP_SAPI values in a bunch of places,
introduce wfIsCLI() to easily check whether running from the
command-line or not.

We're (CI team) interested in generating code coverage with phpdbg
instead of xdebug, hence this patch.

Bug: T184043
Change-Id: Id1f994ca146d7858cd8bb6ab6cdbb7718ff524fb
2018-01-03 23:00:37 -08:00
Umherirrender
a9007e8baf Add missing & to @param documentation to match functon call
Change-Id: I81e68310abcbc59964b22e0e74842d509f6b1fb9
2017-08-11 18:47:46 +02:00
Aaron Schulz
59053a0716 Move ChronologyProtector/TransactionProfiler to Rdbms namespace
Change-Id: I37a655bd8bd267c9bc32028b55925b2dce527d33
2017-01-26 10:30:57 -08:00
Kunal Mehta
61adc1e146 Use namespaced ScopedCallback
The un-namespaced \ScopedCallback is deprecated.

Change-Id: Ie014d5a775ead66335a24acac9d339915884d1a4
2016-10-17 15:46:05 -07:00
Aaron Schulz
058707ef38 Fix SectionProfileCallback type error
Avoids "Argument 1 passed to Profiler::scopedProfileOut() must
be an instance of ScopedCallback, SectionProfileCallback given"

Change-Id: I92713de71df9722d8a5d7e5cd04460aff71cf096
2016-09-30 15:57:44 -07:00
Kunal Mehta
6e9b4f0e9c Convert all array() syntax to []
Per wikitech-l consensus:
 https://lists.wikimedia.org/pipermail/wikitech-l/2016-February/084821.html

Notes:
* Disabled CallTimePassByReference due to false positives (T127163)

Change-Id: I2c8ce713ce6600a0bb7bf67537c87044c7a45c4b
2016-02-17 01:33:00 -08:00
Aaron Schulz
660a775931 Remove old ProfilerOutputUdp class
This uses a non-standard output and requires a custom
collector that wmf does not maintain nor use anymore.

Change-Id: I41a68f7061465417fbdc5ca41f8eb6e1f99f1111
2015-10-21 20:59:47 -07:00
Ori Livneh
c099155a17 ellapsed => elapsed
Also fix some files that don't end with a newline.

Change-Id: Id0672d685b929a5832b42f733dad49683536180a
2015-06-23 03:32:33 +00:00
Vivek Ghaisas
fd9178e4c3 Fix braces code style
Bug: T102805
Change-Id: I7ce4c71dd605f9be79a630602391271bb269b962
2015-06-17 16:28:51 +03:00
Aaron Schulz
016fd0b776 Refactored entry points to have uniform shutdown handling
* Added doPreOutputCommit() and doPostOutputShutdown(),
  which most entry points just using the later
* Also fixed problem where text profiling did not show up
* Avoid calling triggerJobs() in the file streaming
  entry points

Bug: T100127
Bug: T100085
Change-Id: Ibc7e768fd483389a01847f08cdeba4058c853d3f
2015-05-29 20:40:46 +00:00
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