Граф коммитов

704 Коммитов

Автор SHA1 Сообщение Дата
Nicholas Nethercote 08e54b7c13 Bug 1384819 (part 1) - Split MozStackWalk(). r=glandium.
MozStackWalk() is different on Windows to the other platforms. It has two extra
arguments, which can be used to walk the stack of a different thread.

This patch makes those differences clearer. Instead of having a single function
and forbidding those two arguments on non-Windows, it removes those arguments
from MozStackWalk, and splits off MozStackWalkThread() which retains them. This
also allows those arguments to have more appropriate types (HANDLE instead of
uintptr_t; CONTEXT* instead of than void*) and names (aContext instead of
aPlatformData).

The patch also removes unnecessary reinterpret_casts for the aClosure argument
at a couple of MozStackWalk() callsites.

--HG--
extra : rebase_source : 111ab7d6426d7be921facc2264f6db86c501d127
2017-07-27 12:46:47 +10:00
Markus Stange cfee6598e0 Bug 1382928 - Use atomics for thread-shared pieces of state in ThreadResponsiveness.cpp. r=njn
MozReview-Commit-ID: LZJ4XHZPi7N

--HG--
extra : rebase_source : 0b66d03165571c39948076961c69c40bb35a37af
2017-08-01 15:32:18 -04:00
Markus Stange 398fdf44de Bug 1384688 - Update profile version to 8. r=njn
MozReview-Commit-ID: K8IGUZ3NTRY

--HG--
extra : rebase_source : 305e979be23a9bcc42bf9349ed6c4f2c6d0aada5
2017-07-27 19:11:53 -04:00
Markus Stange 69e6cc5e40 Bug 1384688 - Add a pausedRanges field to the profile JSON of each process which lists time ranges during which the profiler was paused or collecting a profile. r=njn
MozReview-Commit-ID: 6nzt7uHTLVm

--HG--
extra : rebase_source : 9ba0f7d87ee39dff3b54916d3f7369432240b2df
2017-07-31 14:44:35 -04:00
Markus Stange 803835a8f1 Bug 1384688 - Add an aIsShuttingDown argument to profiler_get_profile() and to profiler_stream_json_for_this_process(). r=njn
When set to true, the resulting profile will have a non-null meta.shutdownTime
field which is set to current time.
Non-shutdown profiles also get that field, but it's null for them.

MozReview-Commit-ID: 1vpmhBR8rC6

--HG--
extra : rebase_source : b026088053c30acd287f0dc3afa7ddf14093ec27
2017-07-31 14:23:13 -04:00
Markus Stange ac0a69f132 Bug 1384688 - Add thread register and unregister time. r=njn
MozReview-Commit-ID: JDRP8m7QrE1

--HG--
extra : rebase_source : c5d09aeeae52dac63bc2cd31e76414ff7050afa1
extra : source : e5bfaac22eedecebc581e930c93512852e6884f8
2017-07-28 15:43:19 -04:00
Sebastian Hengst 1a67078fdf Backed out changeset ed86b892433b (bug 1384688) for bustage at tools/profiler/gecko/nsProfiler.cpp:573: the address of 'thisProcessFirstSampleTime' will always evaluate as 'true'. r=backout 2017-07-31 20:10:32 +02:00
Sebastian Hengst c4e0fbd639 Backed out changeset e9d92bc3be81 (bug 1384688) 2017-07-31 20:09:57 +02:00
Sebastian Hengst 5447aa09bb Backed out changeset 399d40cb5c1c (bug 1384688) 2017-07-31 20:09:47 +02:00
Sebastian Hengst 8df015cb1c Backed out changeset 802c36bf1b27 (bug 1384688) 2017-07-31 20:09:41 +02:00
Markus Stange 4827b962f9 Bug 1384688 - Update profile version to 8. r=njn
MozReview-Commit-ID: K8IGUZ3NTRY

--HG--
extra : rebase_source : c9c2f5d2a88310bc4090a853a56c3314a3529252
2017-07-27 19:11:53 -04:00
Markus Stange c7c66c1a29 Bug 1384688 - Add a pausedRanges field to the profile JSON of each process which lists time ranges during which the profiler was paused or collecting a profile. r=njn
MozReview-Commit-ID: 6nzt7uHTLVm

--HG--
extra : rebase_source : a7e7a3fe3ddacb6d03ba3349ce0193dee328ed80
2017-07-28 16:40:37 -04:00
Markus Stange 607fc637d3 Bug 1384688 - Add an aIsShuttingDown argument to profiler_get_profile() and to profiler_stream_json_for_this_process(). r=njn
When set to true, the resulting profile will have a non-null meta.shutdownTime
field which is set to current time.
Non-shutdown profiles also get that field, but it's null for them.

MozReview-Commit-ID: 1vpmhBR8rC6

--HG--
extra : rebase_source : 38573ff847ee7e2ac5df9c82564dd6495cc1636f
2017-07-31 13:11:19 -04:00
Markus Stange 23d29459f0 Bug 1384688 - Add thread register and unregister time. r=njn
MozReview-Commit-ID: JDRP8m7QrE1

--HG--
extra : rebase_source : c5d09aeeae52dac63bc2cd31e76414ff7050afa1
extra : source : e5bfaac22eedecebc581e930c93512852e6884f8
2017-07-28 15:43:19 -04:00
Markus Stange 4036fdd6b0 Bug 1384693 - Let callers of profiler_stream_json_for_this_process obtain the time of the first sample in the buffer. r=njn
MozReview-Commit-ID: IRFq1F3dWIk

--HG--
extra : rebase_source : d4454baf4b4eaf8f185b96a59e40ace5f6702bcc
2017-07-27 15:04:59 -04:00
Carsten "Tomcat" Book 0738c08d98 Merge mozilla-central to mozilla-inbound 2017-07-26 11:16:03 +02:00
Wes Kocher f19f28adfd Merge m-c to autoland, a=merge
MozReview-Commit-ID: F1X8wKqbkg
2017-07-25 19:16:09 -07:00
Nicholas Nethercote cfb30daf2c Bug 1340721 - Enable profiler stack walking on Windows even for --disable-profiling builds. r=mstange.
On Win32, stack frames are now always present, so we can always use
FramePointerStackWalk(). On Win64, stack frames are never present, so we always
use MozStackWalk().

In both cases, we can get stack traces no matter the value of MOZ_PROFILING. So
this patch removes MOZ_PROFILING from the relevant conditions. It also
restructures the conditions and adds some helpful comments.

--HG--
extra : rebase_source : c76aee00432b875ae0c81f8e61f56cd4112bffde
2017-07-22 12:04:10 +10:00
Carsten "Tomcat" Book bdf7db3d13 Merge mozilla-central to mozilla-inbound
--HG--
rename : dom/tests/mochitest/chrome/test_window_getAppLocales.html => dom/tests/mochitest/chrome/test_window_getRegionalPrefsLocales.html
rename : mobile/android/app/src/main/res/drawable/as_contextmenu_divider.xml => mobile/android/app/src/main/res/drawable/as_contextmenu_divider_helper.xml
rename : testing/tools/autotry/autotry.py => tools/tryselect/selectors/syntax.py
extra : rebase_source : d74c74a654cd977d35e35de2768ada4ebe659ae4
2017-07-25 14:38:43 +02:00
Nicholas Nethercote d80dca9e65 Bug 1380286 (follow-up) - Fix hazard bustage. r=bustage.
--HG--
extra : rebase_source : 56b7f9c562568d848b7a240ed1f8e10ccb973ed6
2017-07-25 20:16:02 +10:00
Nicholas Nethercote 37c96fc477 Bug 1380286 (attempt 2) - Introduce ProfilerStackCollector. r=mstange.
--HG--
extra : rebase_source : 7eac82fa5f01f48f239a804ff9d8d662cd1c44aa
2017-07-25 16:47:14 +10:00
Kan-Ru Chen 5454b4c576 Bug 1382990 - Change the DOMEventMarkerPayload field name 'type' to 'eventType' to avoid conflicts. r=mstange
MozReview-Commit-ID: BX9nLoCybbG

--HG--
extra : rebase_source : 996326a32fdb58ff6f13b9532e73710851899627
2017-07-21 17:41:51 +08:00
Markus Stange c1e5917d06 Bug 1382910 - Add profiler_ensure_started. r=njn
MozReview-Commit-ID: LBLlOLXqCwK

--HG--
extra : rebase_source : c3810fdd0805f5fadfd789118b1154435da0a62d
2017-07-24 16:48:15 -04:00
Markus Stange 5ecaa17d34 Bug 1382910 - Propagate the current profiler state to a newly-launched child process using environment variables. r=njn
This also fixes the bug where we would always profile child processes if the
parent process had been launched with MOZ_PROFILER_STARTUP=1, regardless of
whether the profiler was still running in the parent process.

MozReview-Commit-ID: LkIpYmKJOJ1

--HG--
extra : rebase_source : 49b38bc58ded91ecc2e2fce08bcb4f2d20a13b92
2017-07-24 18:16:33 -04:00
Markus Stange 128202ec7e Bug 1382910 - Consistently treat empty env var values the same as the env var not being set. r=njn
This is what prenv.h suggests:
When manipulating the environment there is no way to un-set
an environment variable across all platforms. We suggest
you interpret the return of a pointer to null-string to
mean the same as a return of NULL from PR_GetEnv().

I interpret "null-string" to mean "empty string".

MozReview-Commit-ID: 2mfVD1zULXL

--HG--
extra : rebase_source : 07ec16c002f5c6d1ed0003fa05985f4155f85dfc
2017-07-20 20:52:20 -04:00
Markus Stange d81d287c35 Bug 1382910 - Add a MOZ_PROFILER_STARTUP_FEATURES_BITFIELD environment variable that lets you set the features as a number. r=njn
If set, MOZ_PROFILER_STARTUP_FEATURES_BITFIELD overrides the value set by
MOZ_PROFILER_STARTUP_FEATURES.

This means that we won't need to go through an intermediate string
representation when propagating profiler settings to a child process through
environment variables.

MozReview-Commit-ID: 49eTVMI21GJ

--HG--
extra : rebase_source : 084040e7816929a8b63b7b087d7202180be4d4d5
2017-07-24 15:52:04 -04:00
Markus Stange 48b6127613 Bug 960153 - Add env var MOZ_PROFILER_STARTUP_FEATURES that lets you select which features should be active for startup profiling. r=njn
MozReview-Commit-ID: 9RzHNgIVcSb

--HG--
extra : rebase_source : 73f4c5c5ae7700b9f8794d0cb0b03527721e829d
2017-07-20 20:43:19 -04:00
Markus Stange 22afd028e6 Bug 960153 - Factor out ParseFeaturesFromStringArray. r=njn
MozReview-Commit-ID: JrRecdiMPB0

--HG--
extra : rebase_source : 72d32cf396fc8a3e6e0363487bff9e66355af281
2017-07-20 14:49:35 -04:00
Markus Stange 76c3d32a44 Bug 960153 - Add env var MOZ_PROFILER_STARTUP_FILTERS that lets you select which threads should be profiled during startup profiling. r=njn
MozReview-Commit-ID: 3vZy4bn1mRN

--HG--
extra : rebase_source : 44160deb8d91b1865756c0dddabdd0358d1de30f
2017-07-24 15:40:42 -04:00
Carsten "Tomcat" Book 965777ef3a Backed out changeset 3923ce220df3 (bug 1380286) for hazard failures 2017-07-25 08:44:13 +02:00
Nicholas Nethercote 6041274802 Bug 1380286 - Introduce ProfilerStackCollector. r=mstange.
This allows code outside the profiler to get fully interleaved stack traces
containing frames from the pseudo-stack, native stack, and JS stack.

--HG--
extra : rebase_source : e21b64e86ffec83a0052947afad1793f3fd62d00
2017-07-17 10:18:50 +10:00
Steve Fink 683b884146 Bug 1380770 - Add more info to GCMinor marker JSON, r=jonco
--HG--
extra : rebase_source : 04d4bfc0188106f4c68b662ff5aa4e8a04dc37ab
extra : amend_source : 9692172a301e41c8bb029130c6d3a22a1e665feb
2017-07-13 17:36:46 -07:00
Nicholas Nethercote f5b5c1e817 Bug 1379933 (part 5) - Tweak ProfileBuffer arguments. r=mstange.
This patch changes ProfileBuffer arguments from pointers to references. For
functions that modify the ProfileBuffer, it also moves the argument to the end.

--HG--
extra : rebase_source : 394dd3effc852447c703c0f5802c092ae96e2eaa
2017-07-13 11:05:34 +10:00
Nicholas Nethercote 901524bc02 Bug 1379933 (part 4) - Start all ProfilerBuffer methods with an upper case letter. r=mstange.
--HG--
extra : rebase_source : 3fb137a4981cc3228384d3e477f71f637a1c4722
2017-07-13 11:05:31 +10:00
Nicholas Nethercote 2238ba75d1 Bug 1379933 (part 3) - Start all ProfilerBufferEntry methods with an upper case letter. r=mstange.
Also, hasKind() can be removed.

--HG--
extra : rebase_source : fa1276603cd6602ef649c33ab40f8c4b4c9d427f
2017-07-13 11:05:29 +10:00
Nicholas Nethercote ae465a9150 Bug 1379933 (part 2) - Improve ProfileBuffer's handling of labels and dynamic strings. r=mstange.
When a sample with a label and a dynamic string is written to the
ProfileBuffer, the profiler currently joins them together (up to a max length
of 512, omitting any that exceed this) and then writes a CodeLocation entry
with an empty string followed by a sequence of EmbeddedString entries. When
parsing those entries, we allow a length up to 8192, but that limit is never
reached due to the prior limit of 512.

This patch makes the following changes.

- Removes the joining at write time. Labels and dynamic strings are now written
  separately into the ProfileBuffer. The 512 limit still applies, but just for
  dynamic strings; dynamic strings longer than that are replaced with "(too
  long)". (Labels also always take up one entry, because they only require a
  single pointer, because they are always static strings.) The joining is
  now done when the ProfileBuffer is parsed, and the max length for the joined
  string is still 512; any strings exceeding 512 at that point are truncated,
  rather than omitted. (This also happens to be outside the profier's critical
  section.)

- Renames CodeLocation as Label and EmbeddedString as DynamicStringFragment.
  This makes the ProfileBuffer entry names better match the names used in
  GeckoProfiler.h.

- Moves AddDynamicCodeLocation(), now called addDynamicStringEntry(), into
  ProfileBuffer.

- Adds some testing of long and overly-long dynamic strings to the GTest.

--HG--
extra : rebase_source : 38bdf6e84fa19576c9e0291249e84b19dbb421f7
2017-07-13 11:05:27 +10:00
Nicholas Nethercote 95ff432c26 Bug 1379933 (part 1) - Remove Sample entries from the ProfileBuffer. r=mstange.
They serve no useful purpose.

--HG--
extra : rebase_source : d4d9b352f46285da4a36383f46af2d436c577232
2017-07-11 20:12:24 +10:00
Wes Kocher b4fca1d196 Backed out 4 changesets (bug 1365309) for frequent xpcshell timeouts after 5400 seconds a=backout CLOSED TREE
Backed out changeset 9fc4c6aabd8e (bug 1365309)
Backed out changeset 56850220bd77 (bug 1365309)
Backed out changeset 48f5e0597242 (bug 1365309)
Backed out changeset 39ed96d7b263 (bug 1365309)

MozReview-Commit-ID: 3V0eTL8qeYb
2017-07-12 16:35:14 -07:00
Michael Layzell c4e8a040c2 Bug 1374888 - Maintain a live shared libraries list in gecko on macOS, r=mstange
MozReview-Commit-ID: 5QvrWujquIq
2017-07-12 13:53:56 -04:00
Michael Layzell b34e7c42ec Bug 1365309 - Part 1: Move LUL to a separate lock, and initialize it outside of both the profiler and BHR lock on the BHR thread, r=njn
Currently LUL is a member of CorePS, meaning that it is guarded by the PSMutex.
This mutex is grabbed by the main thread at random points during the execution
of the program. This is unfortunate, as initializing LUL can take a long
time (>1s on my local machine), and we definitely don't want to be blocking the
main thread waiting for it.

In addition, in the BHR case, we used to be grabbing LUL when we got our first
hang, while both the PSMutex and the BHR monitor were being held. This meant
that the main thread could make no progress during LUL initializaion, as the BHR
monitor is grabbed by the main thread on every spin of the event loop.

This patch moves that initialization to be behind a completely separate lock,
and makes BHR initialize it on the background thread before acquiring the BHR
lock, meaning that no locks other than the one guarding LUL should be held
during its initialization.

MozReview-Commit-ID: GwNYQaEAqJ1
2017-07-12 13:13:07 -04:00
Sebastian Hengst 702df96bfc Backed out changeset b297e31320fd (bug 1374888) for mass-asserting, e.g. in dom/base/test/test_setInterval_from_start.html. r=backout on a CLOSED TREE
--HG--
extra : amend_source : 55b47f131608cac63c8bb0530a20b8b21f549471
2017-07-11 21:10:43 +02:00
Michael Layzell 5347ef82fe Bug 1374888 - Maintain a live shared libraries list in gecko on macOS, r=mstange
MozReview-Commit-ID: 5QvrWujquIq
2017-07-11 13:49:23 -04:00
Nicholas Nethercote e893cc5e8d Bug 1379565 - Overhaul ProfileBuffer::StreamSamplesToJSON. r=mstange.
The profiler writes ProfileBuffer entries in a particular order, and then later
has to parse them, mostly in StreamSamplesToJSON(). That function's parsing
code is poorly structured and rather gross, at least partly because no explicit
grammar is identified.

This patch identifies the grammar in a comment, and in the same comment also
includes some examples of the more complicated subsequences. Once written down,
the grammar is obviously suboptimal -- the |Sample| entries serve no useful
purpose, for example -- but I will leave grammar improvements as follow-ups.

The patch also rewrites the parser in a more typical fashion that obviously
matches the grammar. The new parser is slightly more verbose but far easier to
understand.

--HG--
extra : rebase_source : 762c21a68cdc18ff25b5feda3c5dfcf33afa53be
2017-07-05 21:29:29 +10:00
Sylvestre Ledru 4e9cf83ee8 Bug 1378712 - Remove all trailing whitespaces r=Ehsan
MozReview-Commit-ID: Kdz2xtTF9EG

--HG--
extra : rebase_source : 7235b3802f25bab29a8c6ba40a181a722f3df0ce
2017-07-06 14:00:35 +02:00
David Major 8f2fab9547 Bug 1378442 - Move Win64 profiler hooks to profiler_start. r=mstange 2017-07-05 18:45:31 -04:00
Nicholas Nethercote 6dbd7251d0 Bug 1378055 (part 7) - Use "entry", not "frame" when talking about ProfileBufferEntry objects. r=mstange.
--HG--
extra : rebase_source : 291cc3af4f827b9fe0662b756634e61ee5937562
2017-07-04 16:54:06 +10:00
Nicholas Nethercote ce36e6687b Bug 1378055 (part 6) - Use "entry", not "tag" when talking about ProfileBufferEntry objects. r=mstange.
The patch also changes ProfileBuffer::processEmbeddedString() to take the
readAheadPos, instead of recomputing it.

--HG--
extra : rebase_source : 62bacb4c7cc61f43d78ada342af0a813c307b96a
2017-07-04 16:53:21 +10:00
Nicholas Nethercote b9f8d7e37f Bug 1378055 (part 5) - Make ProfileBufferEntry always store 8 chars. r=mstange.
The double variant is always 8 bytes, so the chars variant can be too. As well
as reducing memory usage on 32-bit platforms, this patch makes the code
clearer.

--HG--
extra : rebase_source : 8f3dd0a1e35c18ac812fa5db7c3f6e4626447c4c
2017-07-04 16:52:46 +10:00
Nicholas Nethercote eaabbc455b Bug 1378055 (part 4) - Overhaul PROFILE_BUFFER_ENTRY_KIND_LIST. r=mstange.
This patch renames it, things around it, and fixes some formatting.

--HG--
extra : rebase_source : 03a189ab5fbe24613c66026bb7e550a5c4df5d42
2017-07-04 16:51:52 +10:00
Nicholas Nethercote ac56cf9abe Bug 1378055 (part 3) - Overhaul names used within ProfilerBufferEntry.cpp. r=mstange.
- It's common for unions to be named |u|, because this makes it obvious that
  it's a union when you access it, which is good. This patch introduces that
  for the union in ProfilerBufferEntry. (This required move the union setting in
  each constructor from the initializer list to the constructor body.)

- Each union variant had the prefix "mTag". But that's a bad name, because
  |mKind| is actually the tag. So this patch removes the "Tag".

- |mTagData| was a poor name for the |const char*| variant, so this patch
  renames it |mString|.

- The patch moves |mKind| before |u|, because that's the normal way that tagged
  unions are done.

--HG--
extra : rebase_source : 563cbcf6414fa3c45abcdd5eafd99965bb842de5
2017-07-04 16:51:21 +10:00
Nicholas Nethercote 0e7b1b3bf7 Bug 1378055 (part 2) - Remove ProfilerBufferEntry::getMarker(). r=mstange.
If marker pointer is null the uses of it will immediately crash, so asserting
non-nullness doesn't add much. And removing the getter makes it more similar to
the other union variants.

--HG--
extra : rebase_source : a1066ef98ac5d2dae5303b465106b844937cfb73
2017-07-04 16:50:43 +10:00
Nicholas Nethercote 1ab1b92249 Bug 1378055 (part 1) - Remove unused ProfileBufferEntry union variants. r=mstange.
--HG--
extra : rebase_source : 9904601ff47e8ba19d61af1ddc377cad4be243f6
2017-07-04 16:49:42 +10:00
Nicholas Nethercote fa0aab394a Bug 1375776 (part 7) - Add a comment to ThreadInfo. r=mstange.
--HG--
extra : rebase_source : f1b8bd5f9ba1db8ea67f10390c6dbedd0e9c4cb6
2017-07-03 13:46:48 +10:00
Nicholas Nethercote 5d446671a8 Bug 1375776 (part 4) - Allow ProfilerMarkerPayload.h to be #included unconditionally. r=mstange.
This requires:

- Moving the constructors of ProfilerMarkerPayload and its subclasses into the
  .h file so they are visible even when ProfilerMarkerPayload.cpp isn't
  compiled.

- Similarly, using a macro to make StreamPayload() a crashing no-op when the
  profiler isn't enabled. (It is never called in that case.)

--HG--
extra : rebase_source : 7aad2fdb1bd4e49782024dba6664e8f992771520
2017-06-23 16:24:15 +10:00
Nicholas Nethercote d4e5f6709b Bug 1375776 (part 3) - Improve destructor of ProfilerMarkerPayload and its subclasses. r=mstange.
No point having all these explicit empty destructors.

Also, we can avoid IOMarkerPayload's constructor by using a UniqueFreePtr.

--HG--
extra : rebase_source : 0a2a5aecb66a2990c9188354c861f67633ed2fee
2017-06-23 15:58:11 +10:00
Nicholas Nethercote ca8b2377bc Bug 1375776 (part 2) - Combine the two TracingMarkerPayload constructors. r=mstange.
--HG--
extra : rebase_source : 60ce2839cfebffbd2071b5821041fabc34c1ffe2
2017-06-23 14:29:03 +10:00
Michael Layzell 2eb92d98f1 Backout Bug 1365309 for test failures on a CLOSED TREE
MozReview-Commit-ID: 143ac9l7Goq
2017-07-04 17:31:13 -04:00
Florian Quèze 500a207037 Bug 1377916 - Include DOM workers in startup profiles, r=mstange. 2017-07-04 22:48:08 +02:00
Michael Layzell b24bf46af6 Bug 1377344 - Record the name of the currently running Runnable on thread hangs for BHR, r=njn, r=froydnj
MozReview-Commit-ID: IYRHh6jiTeo
2017-07-04 15:16:19 -04:00
Michael Layzell 1fda892d36 Bug 1365309 - Part 1: Move LUL to a separate lock, and initialize it outside of both the profiler and BHR lock on the BHR thread, r=njn
Currently LUL is a member of CorePS, meaning that it is guarded by the PSMutex.
This mutex is grabbed by the main thread at random points during the execution
of the program. This is unfortunate, as initializing LUL can take a long
time (>1s on my local machine), and we definitely don't want to be blocking the
main thread waiting for it.

In addition, in the BHR case, we used to be grabbing LUL when we got our first
hang, while both the PSMutex and the BHR monitor were being held. This meant
that the main thread could make no progress during LUL initializaion, as the BHR
monitor is grabbed by the main thread on every spin of the event loop.

This patch moves that initialization to be behind a completely separate lock,
and makes BHR initialize it on the background thread before acquiring the BHR
lock, meaning that no locks other than the one guarding LUL should be held
during its initialization.

MozReview-Commit-ID: GwNYQaEAqJ1
2017-07-04 13:19:26 -04:00
Nicholas Nethercote c3ff586b09 Bug 1376993 (part 2) - Remove ProfilerJSEventMarker(). r=mstange.
It's needless indirection.

--HG--
extra : rebase_source : 063d242ea14bb3236cb53a5ade2923827060630e
2017-06-28 16:44:28 -07:00
Bill McCloskey f115503a0b Bug 1372405 - Provide names for all runnables in the tree (r=froydnj)
MozReview-Commit-ID: DKR6ROiHRS7
2017-06-26 14:19:58 -07:00
Nicholas Nethercote 915a56fb41 Bug 1375299 (part 2) - Remove PROFILER_MARKER. r=mstange.
PROFILER_MARKER is now just a trivial wrapper for profiler_add_marker(). This
patch removes it.

--HG--
extra : rebase_source : 9858f34763bb343757896a91ab7ad8bd8e56b076
2017-06-22 13:40:21 +10:00
Nicholas Nethercote 4b364cf3f3 Bug 1375299 (part 1) - Reduce usage of MOZ_GECKO_PROFILER. r=mstange.
This patch reduces the differences between builds where the profiler is enabled
and those where the profiler is disabled. It does this by removing numerous
MOZ_GECKO_PROFILER checks.

These changes have the following consequences.

- Various functions and classes are now defined in all builds, and so can be
  used unconditionally: profiler_add_marker(), profiler_set_js_context(),
  profiler_clear_js_context(), profiler_get_pseudo_stack(), AutoProfilerLabel.
  (They are effectively no-ops in non-profiler builds, of course.)

- The no-op versions of PROFILER_* are now gone. The remaining versions are
  almost no-ops when the profiler isn't built.

--HG--
extra : rebase_source : 8fb5e8757600210c2f77865694d25162f0b7698a
2017-06-22 06:26:16 +10:00
Michael Layzell 4e0049276e Bug 1373980 - Null-check infoArray correctly in GetInfoForSelf on macOS, r=mstange
MozReview-Commit-ID: 9hZ9VL9MWl9
2017-06-22 14:50:48 -04:00
Nicholas Nethercote 4183270eec Bug 1375275 (part 3) - Remove profiler_log(). r=mstange.
It's a wafer thin wrapper around profiler_tracing() and it's only used three
times. Let's just remove it.

Note also that those three uses are the only places where TRACING_EVENT is
used. I wonder if they're really needed...

--HG--
extra : rebase_source : ac70b4c77c4592d96957a8e6249597eafc822fd4
2017-06-21 20:50:07 +10:00
Nicholas Nethercote dc54dc76f0 Bug 1375275 (part 2) - Remove TracingMarkerPayload::Get{Category,Kind}(). r=mstange.
--HG--
extra : rebase_source : 28b648baf294e61dcca70b4157dd023096057abc
2017-06-21 20:41:36 +10:00
Nicholas Nethercote a2e768a6ee Bug 1375275 (part 1) - Remove PROFILER_GET_BACKTRACE_ENTRIES. r=mstange.
It doesn't need to be exported.

--HG--
extra : rebase_source : 8732e0894082d8377ddae31619fffc3b91f3b6a7
2017-06-21 20:33:00 +10:00
Nicholas Nethercote e742d137c7 Bug 1374975 - Fix incorrect arguments to NotifyProfilerStarted. r=mstange.
--HG--
extra : rebase_source : e9f5b60c6126c9a6295616e9ab0e815a65a28c1a
2017-06-21 20:32:51 +10:00
Carsten "Tomcat" Book 8a1350b5a6 Backed out changeset 4f6302a98ae4 (bug 1372405)
--HG--
extra : rebase_source : 41632f3158e88e692809731394a683d065a73dfb
2017-06-21 13:59:26 +02:00
Julian Seward 7eda9d1a96 Bug 1374248 - LUL: remove stack scanning. r=njn.
This removes LUL's ability to recover frames by the heuristic mechanism of
stack scanning.  Stack scanning is a last-ditch way to try to recover the
unwind when all other methods (metadata-based, frame-pointer chasing) have
failed, by scanning back up the stack and looking for the first word that
could plausibly be a return address.  It often mis-identifies return addresses
because it has no way to distinguish live ones from dead ones that have not
been overwritten, and very often causes the unwind to fail as a result.

In any case LUL's stack scanning ability has actually been switched off (by
the parameters passed to LUL::Unwind) for some considerable time now, so this
change should make no observable difference to behaviour.  Specific changes:

In LUL::Unwind():

* Removes formal parameters |scannedFramesAcquired| and |scannedFramesAllowed|

* Removes code that does stack scanning

* Simplifies control flow in the main unwind loop, so that loop now
  has the easier-to-follow structure

  while (true) {
    // preliminary stuff

    if (CFI data available for current PC) {
       do CFI step;
       continue;
    }

    if (FP chasing possible for current PC) {
       do FP step;
       continue;
    }

    // give up
    break;
  }

* Moves two #ifdefs upwards to enclose the comments pertaining to them, as
  well as the code.  This makes the top level structure easier to follow.  The
  corresponding #endifs are likewise commented with the condition.

From class LULStats, removes |mScanned|.

Removes PriMap::MaybeIsReturnPoint() entirely.  This is a heuristic helper
only used by stack scanning.

In all, 395 lines of code are removed, according to hg diff --stat.

--HG--
extra : rebase_source : 5ffa73c64923149a58df3228cf940cb539f8f707
2017-06-19 16:21:59 +02:00
Bill McCloskey 6b3e84ed5f Bug 1372405 - Provide names for all runnables in the tree (r=froydnj)
MozReview-Commit-ID: DKR6ROiHRS7
2017-06-20 21:44:11 -07:00
Carsten "Tomcat" Book ea1b86680c Backed out changeset 9846de3bd954 (bug 1372405)
--HG--
extra : rebase_source : 5d4a48e8ec394c329994689d938d2a6e9b2752b0
2017-06-20 08:27:02 +02:00
Bill McCloskey 4592152411 Bug 1372405 - Provide names for all runnables in the tree (r=froydnj)
MozReview-Commit-ID: DKR6ROiHRS7
2017-06-19 22:25:47 -07:00
Nicholas Nethercote c078fc6036 Bug 1374127 (part 7) - Remove Registers' constructor. r=mstange.
We rely partly on the constructor to set Registers, and partly on subsequent
assignments. This patch changes things so we rely entirely on subsequent
assignments, for consistency.

--HG--
extra : rebase_source : ca69186f5755003e710985bfb40c90072067305c
2017-06-20 08:45:43 +10:00
Nicholas Nethercote cc6bc3e49b Bug 1374127 (part 6) - Rename FillInRegs(), and introduce a similar function for Windows to avoid repetition. r=mstange.
--HG--
extra : rebase_source : 5dcc319804661858e8d58b41d1f8b8f452d80c2b
2017-06-20 08:45:43 +10:00
Nicholas Nethercote 5e6717e1af Bug 1374127 (part 5) - Remove SyncPopulate's argument. r=mstange.
We can use a static ucontext_t on Linux for synchronous samples instead of
declaring one on the stack in profiler_get_backtrace(). This neatens
SyncPopulate()'s signature.

SyncPopulate() is also only used when HAVE_NATIVE_UNWIND is defined, so the
patch guards the definitions.

--HG--
extra : rebase_source : b71e6d76f24b37bc236ac8f4359d401b1551e2de
2017-06-20 08:45:43 +10:00
Nicholas Nethercote 453b6f2d11 Bug 1374127 (part 2) - Clean up ProfilerMarkerPayload. r=mstange.
This patch does the following.

- Renames some ProfilerMarkerPayload subclasses so they all of the form
  "FooMarkerPayload", to make the subclass relationship clearer.
  (ProfilerMarkerTracing -- now TracingMarkerPayload -- was the worst
  offender.)

- Removes ProfilerMarkerImagePayload and TouchDataPayload, neither of which are
  used.

- Changes streamCommonProps() to StreamCommonProps().

- Does some minor style and comment fixes in ProfilerMarkerPayload.h.

--HG--
extra : rebase_source : dd732905e96da83bcbf124c70b20011c661fc332
2017-06-19 13:32:32 +10:00
Nicholas Nethercote feb7783eed Bug 1374127 (part 1) - Add `using namespace mozilla;` to ProfilerMarkerPayload.cpp. r=mstange.
--HG--
extra : rebase_source : 37961947dbc0151903dabcda2d5fa00c99a1a333
2017-06-16 12:46:10 +10:00
Nicholas Nethercote 5d3808c6e5 Bug 1373436 (part 4) - Use UniquePtr with profile_add_marker(). r=mstange.
Once the |aPayload| argument to profile_add_marker() became a UniquePtr the
default value of nullptr caused compilation difficulties that could only be
fixed by #including ProfilerMarkerPayload.h into lots of additional places
(because the UniquePtr<T> instantiation required the T to be fully defined). To
get around this I just split profile_add_marker() into two functions, one with
1 argument and one with 2 arguments.

The patch also removes the definition of PROFILER_MARKER_PAYLOAD in the case
where MOZ_GECKO_PROFILER isn't defined. A comment explains why.
2017-06-16 12:26:26 +10:00
Nicholas Nethercote 8fccd59ba6 Bug 1373436 (part 3) - Use UniquePtr more with ProfilerMarkerPayload. r=mstange. 2017-06-16 10:51:05 +10:00
Nicholas Nethercote 442ac55216 Bug 1373436 (part 2) - Use a UniquePtr for CorePS::mLul. r=mstange. 2017-06-16 10:30:35 +10:00
Nicholas Nethercote 8d89035364 Bug 1373436 (part 1) - Use UniquePtr more for ProfileBuffer and ProfilerBacktrace . r=mstange. 2017-06-16 09:43:16 +10:00
Nicholas Nethercote d529284168 Bug 1373154 (part 3, attempt 2) - Overhaul TickSample and things around it. r=mstange.
Bug 1357829 added a third kind of sample, in addition to the existing
"periodic" and "synchronous" samples. This patch cleans things up around that
change. In particular, it cleans up TickSample, which is a mess of semi-related
things.

The patch does the following.

- It removes everything from TickSample except the register values and renames
  TickSample as Registers. Almost all the removed stuff is available in
  ThreadInfo anyway, and the patch adds a ThreadInfo argument to various
  functions. (Doing it this way wasn't possible until recently because a
  ThreadInfo wasn't available in profiler_get_backtrace() until recently.)

  One non-obvious consequence: in synchronous samples we used to use a value of
  0 for the stackTop. Because synchronous samples now use ThreadInfo directly,
  they are able to use the proper stack top value from ThreadInfo::mStackTop.
  This will presumably only improve the quality of the stack traces.

- It splits Tick() in two and renames the halves DoPeriodicSample() and
  DoSyncSample().

- It reorders arguments in some functions so that ProfileBuffer (the output) is
  always last, and inputs are passed in roughly the order they are obtained.

- It adds a comment at the top of platform.cpp explaining the three kinds of
  sample.

- It renames a couple of other things.

--HG--
extra : rebase_source : 4f1e69c605102354dd56ef7af5ebade201e1d106
2017-06-19 09:38:15 +10:00
Nicholas Nethercote 61516fe3a0 Bug 1373154 (part 2, attempt 2) - Don't call AllocPlatformData() in profiler_get_backtrace(). r=mstange.
We already have a PlatformData for the thread in its ThreadInfo.

--HG--
extra : rebase_source : 4b7a4f70c3b38f38928bfa7d10b6362ac2cc3ed6
2017-06-19 09:38:11 +10:00
Nicholas Nethercote 16b88972ff Bug 1373154 (part 1, attempt 2) - Add more comments about the profiler's critical section. r=me.
--HG--
extra : rebase_source : 16d1ba39fa04e1df82231c347fffe49251cf9f33
2017-06-19 09:09:46 +10:00
Phil Ringnalda 8f1db3dfce Backed out 3 changesets (bug 1373154) for Windows devtools timeouts
Backed out changeset ca4e62117e6a (bug 1373154)
Backed out changeset 0e89b1564ea4 (bug 1373154)
Backed out changeset 48767f3f315f (bug 1373154)

MozReview-Commit-ID: 3DhUjEjXVmn
2017-06-15 21:22:57 -07:00
Nicholas Nethercote 8179018d28 Bug 1373154 (part 3) - Overhaul TickSample and things around it. r=mstange.
Bug 1357829 added a third kind of sample, in addition to the existing
"periodic" and "synchronous" samples. This patch cleans things up around that
change. In particular, it cleans up TickSample, which is a mess of semi-related
things.

The patch does the following.

- It removes everything from TickSample except the register values and renames
  TickSample as Registers. Almost all the removed stuff is available in
  ThreadInfo anyway, and the patch adds a ThreadInfo argument to various
  functions. (Doing it this way wasn't possible until recently because a
  ThreadInfo wasn't available in profiler_get_backtrace() until recently.)

  One non-obvious consequence: in synchronous samples we used to use a value of
  0 for the stackTop. Because synchronous samples now use ThreadInfo directly,
  they are able to use the proper stack top value from ThreadInfo::mStackTop.
  This will presumably only improve the quality of the stack traces.

- It splits Tick() in two and renames the halves DoPeriodicSample() and
  DoSyncSample().

- It reorders arguments in some functions so that ProfileBuffer (the output) is
  always last, and inputs are passed in roughly the order they are obtained.

- It adds a comment at the top of platform.cpp explaining the three kinds of
  sample.

- It renames a couple of other things.

--HG--
extra : rebase_source : 61f4bf75ff5a2c331e8e39dcbb2bf3563606ebb0
2017-06-16 08:29:19 +10:00
Nicholas Nethercote 4b3df390dc Bug 1373154 (part 2) - Don't call AllocPlatformData() in profiler_get_backtrace(). r=mstange.
We already have a PlatformData for the thread in its ThreadInfo.

--HG--
extra : rebase_source : 2b943889be2afafdf6c166661ec607c3df0e9b6b
2017-06-15 22:02:08 +10:00
Nicholas Nethercote d0c2d996a1 Bug 1373154 (part 1) - Remove TickSample::mTimeStamp. r=mstange.
We can just TimeStamp::Now() directly when needed.

--HG--
extra : rebase_source : 94653b716da43c43c41cff20a26dc58ec15d1de5
2017-06-15 22:01:10 +10:00
Michael Layzell e51690c5b9 Bug 1357829 - Part 4: Remove TickController, r=njn
MozReview-Commit-ID: 2IHa6ybR9ug
2017-06-14 12:27:52 -04:00
Michael Layzell 3e295cfe16 Bug 1357829 - Part 3: Remove profiler_get_stack_top, r=njn
MozReview-Commit-ID: C4DvuOvYSrs
2017-06-14 12:27:51 -04:00
Michael Layzell 029576f19d Bug 1357829 - Part 1: Expose profiler_suspend_and_sample_thread, r=njn
This patch performs a refactoring to the internals of the profiler in order to
expose a function, profiler_suspend_and_sample_thread, which can be called from a
background thread to suspend, sample the native stack, and then resume the
target passed-in thread.

The interface was designed to expose as few internals of the profiler as
possible, exposing only a single callback which accepts the list of program
counters and stack pointers collected during the backtrace.

A method `profiler_current_thread_id` was also added to get the thread_id of the
current thread, which can then be passed by another thread into
profiler_suspend_sample_thread to sample the stack of that thread.

This is implemented in two parts:

1) Splitting SamplerThread into two classes: Sampler, and SamplerThread.

Sampler was created to extract the core logic from SamplerThread which manages
unix signals on android and linux, as well as suspends the target thread on all
platforms. SamplerThread was then modified to subclass this type, adding the
extra methods and fields required for the creation and management of the actual
Sampler Thread.

Some work was done to ensure that the methods on Sampler would not require
ActivePS to be present, as we intend to sample threads when the profiler is not
active for the Background Hang Reporter.

2) Moving the Tick() logic into the TickController interface.

A TickController interface was added to platform which has 2 methods: Tick and
Backtrace. The Tick method replaces the previous Tick() static method, allowing
it to be overridden by a different consumer of SuspendAndSampleAndResumeThread,
while the Backtrace() method replaces the previous MergeStacksIntoProfile
method, allowing it to be overridden by different consumers of
DoNativeBacktrace.

This interface object is then used to wrap implementation specific data, such as
the ProfilerBuffer, and is threaded through the SuspendAndSampleAndResumeThread
and DoNativeBacktrace methods.

This change added 2 virtual calls to the SamplerThread's critical section, which
I believe should be a small enough overhead that it will not affect profiling
performance. These virtual calls could be avoided using templating, but I
decided that doing so would be unnecessary.

MozReview-Commit-ID: AT48xb2asgV
2017-06-14 12:27:48 -04:00
Nicholas Nethercote aab625999f Bug 1370329 (part 2) - Add support for profiler labels in mozglue. r=mstange,glandium.
Profiler labels can't currently be used in mozglue, because the profiler's code
is in libxul, and mozglue cannot depend on libxul.

This patch addresses this by basically duplicating AutoProfilerLabel in
mozglue. libxul passes two callback functions to mozglue to do the actual
pushing/popping of labels.

It's an annoying amount of machinery, but it is unavoidable if we want to use
profiler labels within mozglue.

--HG--
extra : rebase_source : 4bcb6fb0f050bba42c23d92d01f9c56611f8518f
2017-06-07 12:36:26 +10:00
Nicholas Nethercote 0be77baa96 Bug 1370329 (part 1) - Clean up the profiler's RAII classes. r=mstange.
This patch does the following renamings, which increase consistency.

- GeckoProfilerInitRAII -> AutoProfilerInit
- GeckoProfilerThread{Sleep,Wake}RAII -> AutoProfilerThread{Sleep,Wake}
- GeckoProfilerTracingRAII -> AutoProfilerTracing
- AutoProfilerRegister -> AutoProfilerRegisterThread
- ProfilerStackFrameRAII -> AutoProfilerLabel
- nsJSUtils::mProfilerRAII -> nsJSUtils::mAutoProfilerLabel

Plus a few other minor ones (e.g. local variables).

The patch also add MOZ_GUARD_OBJECT macros to all the profiler RAII classes
that lack them, and does some minor whitespace reformatting.

--HG--
extra : rebase_source : 47e298fdd6f6b4af70e3357ec0b7b0580c0d0f50
2017-06-07 12:33:19 +10:00
Nicholas Nethercote 4c0ca14a86 Bug 1368915 (part 5) - Introduce MAX_JS_FRAMES. r=mstange.
--HG--
extra : rebase_source : 478043cf6e347f2eeb368cf0bcd90f7aa0c73c4e
2017-06-02 09:41:58 +10:00
Nicholas Nethercote 26d1e36a3d Bug 1368915 (part 4) - Clean up NativeStack. r=mstange.
This patch puts the arrays inside NativeStack, gives NativeStack a constructor,
and renames its fields using "mFoo" form.

The patch also moves MAX_NATIVE_FRAMES from the LUL-only code and applies it
globally. This increases the max native frame count from 256 to 1024 on the
LUL platforms, which makes things consistent with other platforms.

--HG--
extra : rebase_source : 0854ab37d101e090ea05cba7cb6d296450f8dfdc
2017-06-02 09:41:55 +10:00
Nicholas Nethercote 90133cc8f9 Bug 1368915 (part 3) - Rename aStartTime parameters as aProcessStartTime where appropriate. r=mstange.
This increases naming consistency. The remaining aStartTime parameters within
the profiler refer to a different start time than the process start time.

--HG--
extra : rebase_source : 0a07c54288f31af5a15518180b00fe59b587f784
2017-06-02 09:41:51 +10:00
Nicholas Nethercote d74c3bc157 Bug 1368915 (part 2) - Remove unnecessary mozilla:: qualifiers in plaform.cpp. r=mstange.
--HG--
extra : rebase_source : 9d88c5f5d8ee7d8bb825a92d5e22fb2c06d60d51
2017-06-02 09:41:48 +10:00
Nicholas Nethercote 53299e2c4a Bug 1368915 (part 1) - Rename a parameter of locked_register_thread(). r=mstange.
--HG--
extra : rebase_source : 6bd4cb02d0758a13b2938055052770a206893651
2017-05-31 15:14:50 +10:00
Nicholas Nethercote ede22c7534 Bug 1369612 - Remove ProfilerStackFrameDynamicRAII and profiler_call_{enter,exit}. r=mstange.
ProfilerStackFrameRAII and ProfilerStackFrameDynamicRAII are very similar; the
latter lets a dynamic string be specified as well (and lacks the
MOZ_GUARD_OBJECT stuff, for no good reason).

This patch does the following.

- Removes ProfilerStackFrameDynamicRAII, and adds a dynamic string to
  ProfilerStackFrameRAII. It also reorders the constructor's arguments to match
  the field ordering of ProfileEntry. There aren't many usage sites so these
  changes don't affect many places.

- With that done, there is only a single callsite for each of
  profiler_call_enter() and profiler_call_exit(), so the patch also inlines and
  removes them.
2017-06-02 15:38:20 +10:00
Nicholas Nethercote 1b418b1c18 Bug 1369644 - Remove use of |volatile| from ProfileEntry. r=mstange,shu,jseward,froydnj.
These annotations aren't doing anything useful. The important thing with
the PseudoStack is that, during pushes, the stack pointer incrementing happens
after the new entry is written, and this is ensured by the stack pointer being
Atomic.

The patch also improves the comments on PseudoStack.

--HG--
extra : rebase_source : 100f8a5e4b750c15fac66175550c4c284a141f16
2017-06-02 17:16:56 +10:00
Nicholas Nethercote 2b5f064d4e Bug 1369276 (part 2) - Convert ProfileEntry::Flags to Kind. r=shu.
There are three flags in ProfileEntry::Flags, which suggests there are 2**3 = 8
combinations. But there are only actually 4 valid combinations.

This patch converts the three flags to a single "kind" enum, which makes things
clearer. Note also that the patch moves the condition at the start of
AddPseudoEntry() to its callsite, for consistency with the earlier JS_OSR entry
kind check.

--HG--
extra : rebase_source : 0950769ee1530291860ef3be47d240df5939e871
2017-06-02 12:46:09 +10:00
Nicholas Nethercote 7d540d96fd Bug 1369276 (part 1) - Fix category handling in AddPseudoEntry. r=shu.
The category handling code at the end of AddPseudoEntry has two problems.

- The assertion checks |category| for the IS_CPP_ENTRY flag. This represents a
  confusion between the entry's |category| and its |flags|. They're both stored
  in a single uint32_t, but are conceptually different types. So the assertion
  is vacuously satisfied.

  Furthermore, there's no clear way to fix the assertion -- it doesn't make
  sense to check the entry's flags for IS_CPP_ENTRY, because this code can
  clearly take C++ or JS entries. So the patch just removes the assertion.

- The category is compared to zero. This also doesn't make sense, because zero
  isn't a valid category. The patch removes this comparison.

--HG--
extra : rebase_source : 16a7248ffb90ccd90e6102d597fb5bdff706312e
2017-05-31 15:03:55 +10:00
Nicholas Nethercote 3d29a20915 Bug 1347274 (part 3, attempt 2) - Make some hot profiler functions lockless. r=mstange. 2017-06-01 13:33:22 +10:00
Nicholas Nethercote 19e99ca015 Bug 1347274 (part 2, attempt 2) - Make CorePS::ProcessStartTime() lockless. r=mstange.
--HG--
extra : rebase_source : 5b8983cec8db3535b76003369f2ac6f9946a5562
2017-06-01 10:22:20 +10:00
Nicholas Nethercote 3056033889 Bug 1347274 (part 1, attempt 2) - Rename some profiler parameters. r=mstange.
--HG--
extra : rebase_source : 395a45c494573da9281f27fbd7826f7ea5c12e10
2017-06-01 10:21:58 +10:00
Markus Stange e2336b07a8 Bug 1330185 - Use a top-level PProfiler protocol to control the profiler in other processes. r=billm,njn
MozReview-Commit-ID: EROfGuYQ6a0

--HG--
extra : rebase_source : be0aa1b9c7963882e8e7d47964f2da5b670ab10a
extra : intermediate-source : e6f368f2d8741f2a9655b288d49b59fbbd6b90b7
extra : source : 51cdc2541486d5ddf2d385ec0459a9ec38b8775b
2017-05-30 15:06:14 -04:00
Markus Stange 4ee7b100b1 Bug 1330184 - Remove main-thread-only assertions. r=njn
I think all of these assertions are now unnecessary.

MozReview-Commit-ID: 9EI195QsizN

--HG--
extra : rebase_source : 4f03ef02ba6680ee6cad22d5d3f347db7d70aa9c
extra : intermediate-source : 2b8d50fcb20fc0bd808707aae00d6cbcb4536bac
extra : source : 327c145ded03d39970351a9cc01492f0541d9149
2017-05-29 15:16:34 -04:00
Markus Stange 9413af4371 Bug 1330184 - Register/unregister the IOInterposeObserver on the main thread, regardless of what thread the profiler is started / stopped on. r=njn
MozReview-Commit-ID: 8Y0rspxBJw3

--HG--
extra : rebase_source : 64def3fc572c55e2865f5adc570eb841fc759352
extra : intermediate-source : dbe452a9eebb5aff9fa30afdd402efdcb2b6ad30
extra : source : fd537bffda4b653dc7191434c42d068b1b9c65b8
2017-05-16 17:35:05 -04:00
Markus Stange 5d85a692ae Bug 1330184 - Allow StreamMetaObject to be called on a background thread, but only include startTime and version for those calls. r=njn
MozReview-Commit-ID: 3AuX0a2Brrd

--HG--
extra : rebase_source : 8c5d2b4ccacbbec92711a9561d4166e1e7c376c7
extra : intermediate-source : e13b9e798e16185e54435a0b926970e8de134804
extra : source : edfdb14bd020233fa29771bb0f78bcfc55f6cbb3
2017-05-29 13:44:28 -04:00
Markus Stange b728005923 Bug 1330184 - Allow notifying observers for profiler state changes on background threads. r=njn
MozReview-Commit-ID: GlkVwGTa2b4

--HG--
extra : rebase_source : b04504b06aa80635a50d7ce1dcec43a994d6ba8d
extra : intermediate-source : 52489c7eadaf8cab111eef93187c7ecb1482fe58
extra : source : b8c27d6137a43ecd031f0b58c62752b7a9cefacb
2017-05-30 17:07:56 -04:00
Nicholas Nethercote a062b9be51 Bug 1366650 (part 2) - In GeckoProfiler, do all pseudo-stack accesses via the PseudoStack class, instead of via raw array manipulation. r=mstange,shu.
- The profiler gives the JS engine a reference to the pseudo-stack via
  SetContextProfiilngStack(). That function now takes a |PseudoStack*| instead
  of a |ProfileEntry*| and pointer to the stack pointer.

- PseudoStack now has a |kMaxEntries| field, which is easier to work with than
  |mozilla::ArrayLength(entries)|.

- AddressOfStackPointer() is no longer needed.

- The patch also neatens up the push operations significantly. PseudoStack now
  has pushCppFrame() and pushJsFrame(), which nicely encapsulate the two main
  cases. These delegate to the updated initCppFrame() and initJsFrame()
  functions in ProfileEntry.

- Renames max_stck in testProfileStrings.cpp as peakStackPointer, which is a
  clearer name.

- Removes a couple of checks from testProfileStrings.cpp. These checks made
  sense when the pseudo-stack was accessed via raw manipulation, but are not
  applicable now because we can't artificially limit the maximum stack size so
  easily.
2017-05-26 09:51:31 +10:00
Nicholas Nethercote 0840bb61c6 Bug 1366650 (part 1) - Move PseudoStack into SpiderMonkey. r=mstange,shu.
This includes renaming its fields to match SpiderMonkey naming conventions
instead of Gecko naming conventions.

This patch is just about moving the code. The next patch will change
SpiderMonkey to actually use PseudoStack directly.

--HG--
extra : rebase_source : 27e77ddf950201eb6bdba60003218056442cf7ab
2017-05-26 09:37:28 +10:00
Phil Ringnalda 6368ef89e2 Backed out 5 changesets (bug 1330185, bug 1330184) for leaking an nsTArray_base from the plugin process on Win8
Backed out changeset e6f368f2d874 (bug 1330185)
Backed out changeset 2b8d50fcb20f (bug 1330184)
Backed out changeset dbe452a9eebb (bug 1330184)
Backed out changeset e13b9e798e16 (bug 1330184)
Backed out changeset 52489c7eadaf (bug 1330184)

MozReview-Commit-ID: 8L20BZ5E3t2
2017-05-22 19:45:35 -07:00
Markus Stange 9bf6b534a2 Bug 1330185 - Use a top-level PProfiler protocol to control the profiler in other processes. r=njn, r=billm
MozReview-Commit-ID: EROfGuYQ6a0

--HG--
extra : rebase_source : 3495ccc7700703cc587f571dfc12e46a682c29a2
extra : source : 51cdc2541486d5ddf2d385ec0459a9ec38b8775b
2017-05-22 13:47:02 -04:00
Markus Stange 001adf56c0 Bug 1330184 - Remove main-thread-only assertions. r=njn
I think all of these assertions are now unnecessary.

MozReview-Commit-ID: 9EI195QsizN

--HG--
extra : rebase_source : ddeb80dfc61ff843b6ba4b35f73d005ca060e429
extra : source : 327c145ded03d39970351a9cc01492f0541d9149
2017-05-21 14:29:12 -04:00
Markus Stange 1c59e2f54d Bug 1330184 - Register/unregister the IOInterposeObserver on the main thread, regardless of what thread the profiler is started / stopped on. r=njn
MozReview-Commit-ID: 8Y0rspxBJw3

--HG--
extra : rebase_source : a3fff1f5d94f7071200b7adc7010c11a1198661f
extra : source : fd537bffda4b653dc7191434c42d068b1b9c65b8
2017-05-16 17:35:05 -04:00
Markus Stange fe9d6d3008 Bug 1330184 - Allow StreamMetaObject to be called on a background thread, but only include startTime and version for those calls. r=njn
MozReview-Commit-ID: 3AuX0a2Brrd

--HG--
extra : rebase_source : 9af9870a3f150d1d975b71e214c84bdf02b6cf62
extra : source : edfdb14bd020233fa29771bb0f78bcfc55f6cbb3
2017-05-04 17:24:56 -04:00
Markus Stange f83374a5e5 Bug 1330184 - Allow notifying observers for profiler state changes on background threads. r=njn
If NotifyObservers is called on a background thread, dispatch a runnable to
the main thread which will send the observer notification. This can result in
awkward orders of the notifications if the profiler functions are called in
quick succession on both the main thread and another thread, but I'm not sure
what to do about that.

MozReview-Commit-ID: GlkVwGTa2b4

--HG--
extra : rebase_source : 628ae91c3adef85c7fb07441b6573eda55e7ba48
extra : intermediate-source : 8c96ac2d762fbed161b6e577f845c1b58ec8bc17
extra : source : b8c27d6137a43ecd031f0b58c62752b7a9cefacb
2017-05-15 19:43:08 -04:00
Nicholas Nethercote d1e495344b Bug 1365854 - Remove FRAME_LABEL_COPY. r=mstange,shu.
ProfileEntry has |string|, which can be static or dynamic, and |dynamicString|.
If |string| is dynamic, the FRAME_LABEL_COPY flag must be set, and it will be
copied into profiler output.

But there is only one place that uses dynamic |string| values, in SpiderMonkey.
And that place doesn't use |dynamicString|. So this patch changes that place to
use an empty |string| and put the old dynamic |string| value in
|dynamicString|. This in turn removes the need for FRAME_LABEL_COPY.

One minor wrinkle is that when |dynamicString| is used the old code put a space
between |string| and |dynamicString|. The new code omits the space if |string|
is empty.

The patch also renames ProfileEntry::string as ProfileEntry::label_, which
better matches how it's used, and ProfileEntry::dynamicString as
ProfileEntry::dynamicString_ so the getter can be renamed dynamicString().
2017-05-18 17:17:46 +10:00
Nicholas Nethercote cbb477c02f Bug 1365515 (part 2, attempt 2) - Remove tick_context_t. r=jseward.
--HG--
extra : rebase_source : 1d9774d694383bdbf25c3c389351c4b7bf3b398a
2017-05-17 17:29:59 +10:00
Nicholas Nethercote f897ce8673 Bug 1365515 (part 1, attempt 2) - Remove profiler support for x86/Darwin. r=mstange.
--HG--
extra : rebase_source : 47f20e763d62c5e3dd0ba662da0822f9cf3e1526
2017-05-17 17:28:59 +10:00
Nicholas Nethercote 282086d9d5 Bug 1366171 - Fix misplaced PSAutoLock. r=mstange.
profiler_resume() mistakenly has the PSAutoLock outside the scope created
specially for it. This patch move the PSAutoLock inside the scope, making it
the same as profiler_pause().
2017-05-19 16:30:06 +10:00
Markus Stange 42b5d166ec Back out bug 1330184 and bug 1330185 because of test failures.
MozReview-Commit-ID: ILD4mevlSU6
2017-05-21 15:11:15 -04:00
Markus Stange b5fdcd479d Bug 1330185 - Use a top-level PProfiler protocol to control the profiler in other processes. r=njn, r=billm
MozReview-Commit-ID: EROfGuYQ6a0

--HG--
extra : rebase_source : de266bda4fc2d6532ff45a6d548b13cd0b4f7206
extra : histedit_source : ad5c4e140c068f17c51d5085fd88ac691e50ab4f
2017-05-21 14:06:50 -04:00
Markus Stange 3bf894099b Bug 1330184 - Remove main-thread-only assertions. r=njn
I think all of these assertions are now unnecessary.

MozReview-Commit-ID: 9EI195QsizN

--HG--
extra : rebase_source : 2a9969dd9e48873f6ec333a5ddfa32b6d938de80
extra : histedit_source : ea4dab2b111e465d3a1e29996cc7f10eb8cdbb67%2C8ab59878e4b1b5a715e0738408c26ac3aa0501e7
2017-05-21 14:29:12 -04:00
Markus Stange cff8ee519e Bug 1330184 - Register/unregister the IOInterposeObserver on the main thread, regardless of what thread the profiler is started / stopped on. r=njn
MozReview-Commit-ID: 8Y0rspxBJw3

--HG--
extra : rebase_source : f88773d3f62a6399299101f84b890d3e253d664c
extra : histedit_source : 4c9a8264e015205a68394fa4e5030082244594f1
2017-05-16 17:35:05 -04:00
Markus Stange 11d48ea717 Bug 1330184 - Allow StreamMetaObject to be called on a background thread, but only include startTime and version for those calls. r=njn
MozReview-Commit-ID: 3AuX0a2Brrd

--HG--
extra : rebase_source : 35f0280c1dcbbcee6e1a8c0c1239f22e817ca1b9
extra : histedit_source : 4f0da56858ced5e3dcc88c34806228f75a25a875
2017-05-04 17:24:56 -04:00
Markus Stange eede579636 Bug 1330184 - Allow notifying observers for profiler state changes on background threads. r=njn
If NotifyObservers is called on a background thread, dispatch a runnable to
the main thread which will send the observer notification. This can result in
awkward orders of the notifications if the profiler functions are called in
quick succession on both the main thread and another thread, but I'm not sure
what to do about that.

MozReview-Commit-ID: GlkVwGTa2b4

--HG--
extra : rebase_source : 30537a31cc828ad7828e41c2885d84a8299a5e70
extra : source : b8c27d6137a43ecd031f0b58c62752b7a9cefacb
extra : histedit_source : f1340ef14acde098de281b81d5ea89e386e7ab42
2017-05-15 19:43:08 -04:00
Nicholas Nethercote 7d44af05e2 Bug 1365824 - Remove STORE_SEQUENCER. r=froydnj.
It's a software memory barrier, and not a very strong one. If the values it is
protecting are Atomic, that provides a stronger hardware memory barrier.

This patch removes it, and changes one of the values it was protecting from
|volatile| to Atomic. (The other value it was protecting was already Atomic.)
2017-05-18 13:24:13 +10:00
Iris Hsiao 02cae69058 Backed out 4 changesets (bug 1357829) for build bustage in xpcshell\selftest.py on windows 8 x64 opt. a=backout
Backed out changeset 8ea202bb1103 (bug 1357829)
Backed out changeset cebe4d7abeda (bug 1357829)
Backed out changeset 378d473c9619 (bug 1357829)
Backed out changeset 86ebe868d443 (bug 1357829)
2017-05-19 11:27:38 +08:00
Michael Layzell 8a302e6be2 Bug 1357829 - Part 4: Remove TickController, r=njn
MozReview-Commit-ID: 2IHa6ybR9ug
2017-05-18 13:56:20 -04:00
Michael Layzell e62bfa945f Bug 1357829 - Part 3: Remove profiler_get_stack_top, r=njn
MozReview-Commit-ID: C4DvuOvYSrs
2017-05-18 13:56:20 -04:00
Michael Layzell dd07e2a56b Bug 1357829 - Part 1: Expose profiler_suspend_and_sample_thread, r=njn
This patch performs a refactoring to the internals of the profiler in order to
expose a function, profiler_suspend_and_sample_thread, which can be called from a
background thread to suspend, sample the native stack, and then resume the
target passed-in thread.

The interface was designed to expose as few internals of the profiler as
possible, exposing only a single callback which accepts the list of program
counters and stack pointers collected during the backtrace.

A method `profiler_current_thread_id` was also added to get the thread_id of the
current thread, which can then be passed by another thread into
profiler_suspend_sample_thread to sample the stack of that thread.

This is implemented in two parts:

1) Splitting SamplerThread into two classes: Sampler, and SamplerThread.

Sampler was created to extract the core logic from SamplerThread which manages
unix signals on android and linux, as well as suspends the target thread on all
platforms. SamplerThread was then modified to subclass this type, adding the
extra methods and fields required for the creation and management of the actual
Sampler Thread.

Some work was done to ensure that the methods on Sampler would not require
ActivePS to be present, as we intend to sample threads when the profiler is not
active for the Background Hang Reporter.

2) Moving the Tick() logic into the TickController interface.

A TickController interface was added to platform which has 2 methods: Tick and
Backtrace. The Tick method replaces the previous Tick() static method, allowing
it to be overridden by a different consumer of SuspendAndSampleAndResumeThread,
while the Backtrace() method replaces the previous MergeStacksIntoProfile
method, allowing it to be overridden by different consumers of
DoNativeBacktrace.

This interface object is then used to wrap implementation specific data, such as
the ProfilerBuffer, and is threaded through the SuspendAndSampleAndResumeThread
and DoNativeBacktrace methods.

This change added 2 virtual calls to the SamplerThread's critical section, which
I believe should be a small enough overhead that it will not affect profiling
performance. These virtual calls could be avoided using templating, but I
decided that doing so would be unnecessary.

MozReview-Commit-ID: AT48xb2asgV
2017-05-18 13:56:20 -04:00
David Major 519ddbd6c7 Bug 1349801: Allow sub-millisecond profiler intervals with a busy wait on Windows. r=mstange
Given that this basically hogs a core per Firefox process, this code only kicks in if you explicitly select a sub-millisecond resolution.

--HG--
extra : rebase_source : 58ca6f8f6537bc4b809e1634ed177c5d47fd499c
2017-05-16 11:07:28 -04:00
David Major 546b2aa408 Bug 1349801: Make aMicroseconds unsigned to avoid a bunch of checks. r=mstange
We already do a max(0,...) before calling anyway.

--HG--
extra : rebase_source : 6cb3fa135e87cb12152e5b2cc8c2a7640489a0c4
2017-05-16 11:06:18 -04:00
David Major 8184a04278 Bug 1349801: Make SleepMicro a method of SamplerThread. r=mstange
So that I can use mIntervalMicroseconds in a later patch.

--HG--
extra : rebase_source : bd7f3de95ca06c19b3572f20fed8f679600ebacb
2017-05-16 11:03:33 -04:00
Carsten "Tomcat" Book e83697008e merge mozilla-inbound to mozilla-central a=merge 2017-05-16 15:04:38 +02:00
Nicholas Nethercote add1b59694 Bug 1362894 - Make profiler_call_{enter,exit} |inline|. r=mstange.
Bug 1359000 moved these functions from GeckoProfiler.h to platform.cpp, which
allowed a lot of follow-up simplifications. But it hurt performance.

This patch moves them back to GeckoProfiler.h and makes them |inline| again.
This required adding a second TLS pointer, sPseudoStack. Comments in the patch
explain why.

--HG--
extra : rebase_source : 4198e32b9e251f4014bce890936f4f85dabeb8ab
2017-05-10 20:13:21 +10:00
Kris Maglione d7d1812e8e Bug 1348031: Part 1 - Allow specifying fractional-millisecond startup profiling interval. r=mstange
MozReview-Commit-ID: Ga1ebO03gp5

--HG--
extra : rebase_source : caaff059a1efd1f15660003124dfac324e6b9c93
2017-05-15 14:19:12 -07:00
Ehsan Akhgari 8a04849cee Bug 1362814 - Part 2: Move GeckoProfilerReporter to its own header; r=mstange
This allows us to get rid of the nsIMemoryReporter.h inclusion in GeckoProfiler.h.
That brings XPCOM string headers with it.
2017-05-12 02:35:09 -04:00
Markus Stange be06502b38 Bug 1363475 - Fix TaskTracer build failure. r=njn
MozReview-Commit-ID: 7ENK05KNcGn

--HG--
extra : source : dad7932cef06e7ac999a55c76d14d5f8d8a721f6
2017-05-04 17:26:54 -04:00
Steve Fink 7ef280069e Bug 1322560 - Record minor GC timings in profiles, r=jonco, mccr8, mstange
--HG--
extra : rebase_source : 073eceb4216b0505f8cbce0947e3e5091626ead1
2017-04-25 13:24:34 -07:00
Steve Fink 4b00aab714 Bug 1322560 - Inject detailed GC timing info into profiles, r=mstange
--HG--
extra : rebase_source : fdd7f21bbb783ee759d3b0b614264d078fa2213f
extra : source : 5fe280e53d4f474f5f16ff834e0b9cf55745d746
2017-05-02 16:13:49 -07:00
Nicholas Nethercote 5d0d883f35 Bug 1361009 - Remove MOZ_WIDGET_GONK from the profiler. r=jseward.
This removes the need for PROFILER_LIKELY_MEMORY_CONSTRAINED.

The patch also removes PROFILE_JAVA, USE_FAULTY_LIB, CONFIG_CASE_1,
CONFIG_CASE_2 and replaces all their uses with GP_OS_linux or GP_OS_android.

Finally, the patch removes a bogus |defined(GP_OS_darwin)| condition in
platform-linux-lul.cpp.

--HG--
extra : rebase_source : 77d1c625d65ddf551ab8cd4b962ae48c1a54466c
2017-05-08 07:09:33 +10:00
Nicholas Nethercote ea25e62e3c Bug 1360471 (part 4) - Use a bitfield to represent profiler features. r=mstange.
Currently the profiler mostly uses an array of strings to represent which
features are available and in use. This patch changes the profiler core to use
a uint32_t bitfield, which is a much simpler and faster representation.
(nsProfiler and the profiler add-on still use the array of strings, alas.) The
new ProfilerFeature type defines the values in the bitfield.

One side-effect of this change is that profiler_feature_active() now can be
used to query all features. Previously it was just a subset.

Another side-effect is that profiler_get_available_features() no longer incorrectly
indicates support for Java and stack-walking when they aren't supported. (The
handling of task tracer support is unchanged, because the old code handled it
correctly.)
2017-05-01 14:23:34 +10:00
Nicholas Nethercote cc78872f8c Bug 1360471 (part 3) - Rename various "thread name filters" identifiers as "filters". r=mstange.
The new names are more concise and matches common usage elsewhere (e.g.
profiler_start() arguments).

This patch is similar to bug 1358074 part 5.
2017-05-01 13:42:53 +10:00
Nicholas Nethercote ebe44f1856 Bug 1360471 (part 2) - Rename profiler_get_features() as profiler_get_available_features(). r=mstange.
It clarifies that it's not just the features chosen in profiler_start().
2017-05-01 12:07:17 +10:00
Jim Chen 7041014748 Bug 1360322 - 2. Add initial AArch64 support to Gecko profiler; r=mstange
Add enough AArch64-specific code for the Gecko profiler to build.
2017-05-03 11:36:18 -04:00
David Major f7b2b2533f Bug 1360575: Use PR_SetCurrentThreadName to set the sampler thread's name on all platforms. r=mstange 2017-05-01 22:56:47 -04:00
David Major 8040b396bd Bug 1351838: Don't sprintf within the profiler since it may take a lock. r=froydnj
--HG--
extra : rebase_source : 8d5f8c4fc5a5f205653db12fb34f9cd51fddfc65
2017-05-01 17:57:12 -04:00
David Major e5d98f2a57 Bug 1360642: Increase SAMPLER_MAX_STRING_LENGTH to capture more URLs. r=mstange
--HG--
extra : rebase_source : b4cbbce0b1240190d93488daa06456536588cf55
2017-05-01 16:26:39 -04:00
Michael Layzell 58464c1919 Bug 1346415 - Use FramePointerStackWalk for less deadlocking when stackwalking on x86, r=njn
MozReview-Commit-ID: CAHarvGSuTY
2017-05-01 13:40:37 -04:00
Nicholas Nethercote 31a9d19faa Bug 1360442 - Fix up macros in GeckoProfiler.h. r=mstange.
- Use PROFILER_ consistently as the prefix for macros in this file. (As opposed
  to PROFILE_ or SAMPLE_ or SAMPLER_ or MOZ_ or PLATFORM_ or no prefix.)

- Split overly long macros across multiple lines.

- Fix some macro indenting.
2017-04-28 15:57:03 +10:00
Nicholas Nethercote d79729cfc6 Bug 1359717 - Remove unnecessary SetIsPaused() calls. r=mstange.
We pause/unpause the profiler before/after some streaming operations. But these
pause/unpause pairs occur with gPSMutex locked, and ActivePS::IsPaused() also
requires that gPSMutex be locked. Therefore these pause/unpause pairs cannot
be observed, and so this patch removes them.
2017-04-27 15:57:35 +10:00
Nicholas Nethercote 93b0b152aa Bug 1123754 (part 2) - Move ProfilerMarker into ProfilerMarker.h. r=mstange.
ProfilerMarker is simple enough that it's best to fully define it in
ProfilerMarker.h, without introducing a ProfilerMarker.cpp.

This requires moving STORE_SEQUENCER() into its own header, StoreSequencer.h.

As a result, the following types are no longer visible outside the profiler:
ProfilerMarker, ProfilerLinkedList, ProfilerMarkerLinkedList,
ProfilerSignalSafeLinkedList. (PseudoStack.h now contains the PseudoStack class
and nothing else.)

The patch also makes the following non-obvious changes.

- It changes ProfilerMarker::{mMarkerName,mPayload} to unique pointers, which
  removes the need for an explicit ~ProfilerMarker().

- It removes ProfilerMarker::GetMarkerName(), because that method is only used
  within ProfilerMarker itself.

--HG--
extra : rebase_source : 22bdfb1c9c30751253ed66352d7edd51d308152d
2017-04-27 07:36:22 +10:00
Nicholas Nethercote 273ec65c56 Bug 1123754 (part 1) - Rename ProfilerMarkers.{h,cpp} as ProfilerMarkerPayload.{h,cpp}. r=mstange.
Because ProfilerMarkerPayload is the main type defined in these files, and
because the next patch is going to introduce ProfilerMarker.{h,cpp}, which
would be confusingly similar to the old names.

--HG--
rename : tools/profiler/core/ProfilerMarkers.cpp => tools/profiler/core/ProfilerMarkerPayload.cpp
rename : tools/profiler/public/ProfilerMarkers.h => tools/profiler/public/ProfilerMarkerPayload.h
extra : rebase_source : df22a2ab3867650348ae78fe959ff0366aff230b
2017-04-27 07:36:19 +10:00
Nicholas Nethercote 4e6950332a Bug 1359000 (part 7) - Move mContext and mJSSampling from RacyThreadInfo to ThreadInfo. r=mstange.
None of the accesses to these fields occur in hot operations, so it's
reasonable to do them with gPSMutex held. As a result, mJSSampling doesn't need
to be Atomic<>, and mContext's lack of Atomic-ness is no longer a cause for
concern.

This required adding an extra field, mJSContext, to TickSample.

--HG--
extra : rebase_source : 1485de5e493cef655233507248006574d0ab6ebd
2017-04-27 07:36:17 +10:00
Nicholas Nethercote 93d021e19b Bug 1359000 (part 6) - Split off RacyThreadInfo from PseudoStack. r=mstange.
PseudoStack is misnamed: it contains the pseudo-stack plus other stuff that is
accessed via TLS.

This patch moves the non-pseudo-stack parts of PseudoStack into a new type
called RacyThreadInfo, which is a subclass of PseudoStack. The patch also
capitalizes the first letter of the names of methods that it moves.

This means that PseudoStack is now accurately named. Also non-pseudo-stack
parts are now no longer visible outside the profiler, which is nice.

--HG--
extra : rebase_source : c110acfb6d2a1527ed33cc073fab3fb188851b22
2017-04-27 07:36:15 +10:00
Nicholas Nethercote 9a52c4f399 Bug 1359000 (part 5) - Introduce TLSInfo. r=mstange.
Currently a reference to each thread's PseudoStack is stored in tlsPseudoStack.
This patch changes the TLS reference to refer to the enclosing ThreadInfo
instead. This allows profiler_clear_js_context() to access the current thread's
ThreadInfo via TLs, rather than searching with FindLiveThreadInfo().

The patch also encapsulates the TLS within a new class called TLSInfo. This
class allows access to the PseudoStack without protection from gPSMutex, but
access to the enclosing ThreadInfo requires a PSLockRef. This maintains the
current access regime.

--HG--
extra : rebase_source : de9967f6c055061bb65930ffd02e369703b1362e
2017-04-27 07:36:13 +10:00
Nicholas Nethercote 9471adc672 Bug 1359000 (part 4) - De-inline profiler_call_{enter,exit}. r=mstange.
This possibly incurs an extra function call (depends on exactly how much inling
the compiler does). But it helps enormously with subsequent refactorings,
because PseudoStack (and related types) don't need to be visible in
GeckoProfiler.h, which is exported outside the profiler.

--HG--
extra : rebase_source : f2dc5952d7444dfe12e627e86e6d37632b283107
2017-04-27 07:36:11 +10:00
Nicholas Nethercote 0510e9b058 Bug 1359000 (part 3) - Rename some "stack" variables as "pseudoStack". r=mstange.
"pseudoStack" more closely matches the type name, and is more specific.

--HG--
extra : rebase_source : 4605c66925f29fae0a4c800a4459a7904a6187ab
2017-04-27 07:36:09 +10:00
Nicholas Nethercote 7fc314e4d2 Bug 1359000 (part 2) - Tweak manual polling of profiler threads. r=mstange.
This patch moves the manual polling up into the preceding loops, which is a
better place for it.

--HG--
extra : rebase_source : c95932d8f66635b9ca435f30bae78585dd7e04ca
2017-04-24 09:49:28 +10:00
Wes Kocher 2aa72d4cdc Merge inbound to central, a=merge
MozReview-Commit-ID: HZUHBRK4UmL
2017-04-27 13:00:07 -07:00
Nicholas Nethercote 22e24ef94a Bug 1358074 (part 7) - Split PS in two. r=mstange.
PS contains some state that is always valid, and some state that is only valid
when the profiler is active. This patch does the following.

- Splits PS into two parts for the two kinds of state: CorePS and ActivePS.

- Moves gPS (now split in two) into CorePS and ActivePS, as static instances,
  to improve encapsulation. This required changing all the state getters and
  setters into static methods.

- Existence tests for CorePS and ActivePS are now done via the Exists()
  methods.

Advantages of this change:

- It's now clear which parts of the global state (most of it!) are valid only
  when the profiler is active, and we don't have to invalidate those parts with
  zero/null/false when the profiler stops.

- Better OOP: more use of constructors and destructors, and more |const| to
  indicate what state is immutable.

- With the old code there were some places where the order of things required
  care, but with the new code it's not possible to get the order wrong.

--HG--
extra : rebase_source : dba177acb41e4dc2103ace2212ab5ae1f7b418ce
2017-04-21 13:28:23 +10:00
Carsten "Tomcat" Book e1e203f1f5 Merge mozilla-central to autoland 2017-04-27 16:36:41 +02:00
Wes Kocher 226702fd85 Merge m-c to autoland a=merge
MozReview-Commit-ID: LOGgOErcV9L
2017-04-26 17:43:38 -07:00
Carsten "Tomcat" Book 68e9a2dfd5 Merge mozilla-central to mozilla-inbound 2017-04-26 09:04:59 +02:00
Carsten "Tomcat" Book 8f4e4ca99b merge mozilla-inbound to mozilla-central a=merge 2017-04-26 08:41:31 +02:00
Nicholas Nethercote bc1d6a21a2 Bug 1358320 - Make TimeStamp::ProcessCreation()'s outparam optional. r=gsvelto.
TimeStamp::ProcessCreations()'s aIsInconsistent outparam is ignored by the
majority of its caller. This patch makes it optional. Notably, this makes
ProcessCreation() easier to use in a constructor's initializer list.
2017-04-26 14:55:54 +10:00
Nicholas Nethercote 213518b7e8 Bug 1358074 (part 6, attempt 2) - Don't use mWasPaused on Android. r=mstange.
--HG--
extra : rebase_source : 99da4bfb335d27b5ea35ce10a149c82abd13ca77
2017-04-21 13:27:59 +10:00
Nicholas Nethercote 42226dcae0 Bug 1358074 (part 5, attempt 2) - Rename mThreadNameFilters as mFilters. r=mstange.
--HG--
extra : rebase_source : 4d26f553136268ac0b20448708254bdbf972f411
2017-04-21 13:27:55 +10:00
Nicholas Nethercote f51b56128c Bug 1358074 (part 4, attempt 2) - Rename PS::{Mutex,AutoLock,LockRef} as PS{Mutex,AutoLock,LockRef}. r=mstange.
--HG--
extra : rebase_source : e1ea40df9197658b9c3b950e5f259206c6a3785b
2017-04-21 13:27:53 +10:00
Nicholas Nethercote c28a0c41b5 Bug 1358074 (part 3, attempt 2) - Don't measure process creation time on every profiler_start() call. r=mstange.
--HG--
extra : rebase_source : 588969b00e56cd7b65904a8d0baf712ea1b57ca5
2017-04-21 13:23:34 +10:00
Nicholas Nethercote 2c0ca9635a Bug 1358074 (part 2, attempt 2) - Unexport and rename ProfilerState. r=mstange.
--HG--
extra : rebase_source : 5b3e049f24d7d4f2e45989e9ee7f05c0258b1280
2017-04-21 13:23:34 +10:00
Nicholas Nethercote 33655a895b Bug 1358074 (part 1, attempt 2) - Fix some bad indentation in platform.cpp. r=mstange.
--HG--
extra : rebase_source : f572f23eeb8a290aae68b5e77dae52d885729e11
2017-04-19 14:47:18 +10:00
Julian Seward 62e5c659b4 Bug 1357777 - LUL on x86_64-linux: recover frames by following the frame pointer chain. r=froydnj,jandem.
On x86_64-Linux, LUL currently can only unwind frames for which CFI unwind data
is available.  This causes a noticeable number of junk samples in the profiler,
characterised by failures at transition points between JIT and native frame
sequences.  This patch allows LUL to try recovering the previous frame using
frame pointer chasing in the case where CFI isn't present.  This allows LUL to
unwind through or jump over interleaved JIT frames, because, respectively:

* The baseline JIT produces frame-pointerised code.

* If the profiler is enabled, IonMonkey doesn't produce frame-pointerised code,
  but also doesn't change the frame pointer register value.  It can use the
  frame pointer if profiling is disabled, but that's irrelevant here.

The patch also adds counts of FP-recovered frames to LUL's statistics printing,
to make it possible to assess how often this feature is used.

--HG--
extra : rebase_source : eadc54393788693b0e3f8d5129d48aaaad143a0b
2017-04-25 08:14:23 +02:00
Greg Tatum 778111225d Bug 1357849 - Instrument performance.measure with markers; r=baku,mstange
MozReview-Commit-ID: KQcQgxYyEYi

--HG--
extra : rebase_source : bc26048ca4317d11ab22a5a54064fa2c031a9fdc
2017-04-24 10:15:11 -05:00
Nicholas Nethercote 5106aa14b9 Bug 1359007 - Remove js::ProfilingGetPC(). r=shu.
AddPseudoEntry() has a single callsite which always passes nullptr for the
last argument. This means that js::ProfilingGetPC() is never called, and so can
be removed. (Even if it was called, it always returns nullptr because ipToPC()
always returns nullptr!)

--HG--
extra : rebase_source : 1260d726c79bf5116143da9904d39b38e3c93837
2017-04-26 14:32:26 +10:00
Markus Stange aeb36a2713 Bug 1358360 - Correctly fill in SharedLibrary fields for the main executable. r=jseward
MozReview-Commit-ID: 3ZJ8FB2Zjs8

--HG--
extra : rebase_source : 1119844c78c0d60d97edccf2511df9660a7a6427
2017-04-21 14:30:18 -04:00
Nicholas Nethercote 625d4520a7 Bug 1357298 - Remove the 'layers.frame-counter' option. r=mstange,mattwoodrow.
This option turns on a frame counter that is shown in the top left corner via a
QR code. It was designed to be used in video recordings of B2G phones.

It no longer seems useful, so this patch removes it.
* * *
Bug 1357298 - Remove all traces of frame numbers and power from the profiler output. r=mstange.

--HG--
extra : rebase_source : 0ce87963ce375df64bb8d80ef2b5d40ea507bc7c
2017-04-18 15:40:24 +10:00
Nicholas Nethercote 28f7ae49bb Bug 1357936 - Don't leak ProfilerIOInterposeObserver. r=mstange.
The patch adds a missing |delete|. (This leak only occurred when the
"mainthreadio" feature was enabled, which is not the default.)

The patch also makes the unregistering of the interpose observer conditional on
there being one in the first place, avoiding a harmless but useless
unregistering of |nullptr|.

--HG--
extra : rebase_source : 7cc3679192e3effa8d86edad5374643d2e2b8948
2017-04-20 09:24:17 +10:00
Julian Seward 5e2ec6a4bc Bug 1356215 - LUL: increase size of unwound stack to 160k. r=froydnj.
For reasons related to the architecture of the Gecko Profiler in previous years,
which are no longer relevant, LUL will only unwind through the first 32KB of
stack.  This is mostly harmless, since most stacks are smaller than 4KB, per
measurements today, but occasionally they go above 32KB, causing unwinding to
stop prematurely.

This patch changes the max size to 160KB, and documents the rationale for
copying the stack and unwinding, rather than unwinding in place.  160KB is big
enough for all stacks observed in several minutes of profiling all threads at
1KHz.

--HG--
extra : rebase_source : a1d5526aff50345be8b965c2b6b01c66b40fd0d8
2017-04-18 10:30:14 +02:00
Carsten "Tomcat" Book bb87f43c09 merge mozilla-inbound to mozilla-central a=merge 2017-04-18 10:21:31 +02:00
Nicholas Nethercote 4a55f047a5 Bug 1356249 - Fix assertion in profiler_set_frame_number(). r=mstange.
This function can run off the main thread when 'layers.frame-counter' is
enabled.

--HG--
extra : rebase_source : f3db0fd01c636d5af97109761bb0b57b57c79293
2017-04-18 14:40:00 +10:00
Markus Stange 618a091371 Bug 830990 - Stop dispatching CheckResponsivenessEvents when the profiler is stopped. r=njn
MozReview-Commit-ID: 4MnRGqE2sEK

--HG--
extra : rebase_source : 2e6e8b354983240a6f8a177f90d5a59d1e58b94c
2017-04-16 14:48:24 -04:00
Markus Stange 180a94d4c2 Bug 1346592 - When stopping the profiler, mark all ThreadInfos as not being profiled. r=njn
This also renames HasProfile() to IsBeingProfiled().

MozReview-Commit-ID: 70RGHNbyZG3

--HG--
extra : rebase_source : 64f1df6985f41ae52d2385edcfd7822d16fd1e00
2017-04-17 22:46:54 -04:00
Iris Hsiao 063f52934e Backed out changeset 1b277ae21ba5 (bug 1346592)
CLOSED TREE
2017-04-18 11:05:12 +08:00
Iris Hsiao 82a868141d Backed out changeset 9d86f0c3ddd4 (bug 830990) for build bustage
CLOSED TREE
2017-04-18 11:05:00 +08:00
Markus Stange e6bcc1a69f Bug 830990 - Stop dispatching CheckResponsivenessEvents when the profiler is stopped. r=njn
MozReview-Commit-ID: 4MnRGqE2sEK

--HG--
extra : rebase_source : 10078745ac3839ea80879a6ebe710a0f4973f25d
2017-04-16 14:48:24 -04:00
Markus Stange b1002e6197 Bug 1346592 - When stopping the profiler, mark all ThreadInfos as not being profiled. r=njn
This also renames HasProfile() to IsBeingProfiled().

MozReview-Commit-ID: 70RGHNbyZG3

--HG--
extra : rebase_source : fbe6faf0ed9ee7273e77f1f81b79915800772212
2017-04-16 13:41:32 -04:00
Sebastian Hengst 8bd051237a merge mozilla-inbound to mozilla-central. r=merge a=merge
MozReview-Commit-ID: JpAhOPjgvkF
2017-04-15 19:59:24 +02:00
Markus Stange dcfba9f179 Bug 1321617 - Call profiler_stream_json_for_this_process in ProfileGatherer::Finish() and get rid of the 'profile-subprocess' notification indirection. r=njn
MozReview-Commit-ID: CnE0SJBsfDN

--HG--
extra : rebase_source : 59f4201d3d8b8fb0d5bc7743f9dafd60789d916a
extra : histedit_source : 5b8b9b26ac87d22d118891868a8a07fe225e85b2
2017-04-12 16:40:03 -04:00
Markus Stange 4a1b5c4027 Bug 1321617 - Reduce the scope of the lock in profiler_get_profile. r=njn
MozReview-Commit-ID: 5OmVMwy1yMl

--HG--
extra : rebase_source : 9cebf6f6ff860fc6b0750e9e4d9eaf23773ccc19
extra : histedit_source : cbd1321ea17a26553384efb6ee7511d800878b84
2017-04-12 16:45:28 -04:00
Markus Stange a951919765 Bug 1321617 - Move parts of StreamJSON out into the callers and rename it to locked_profiler_stream_json_for_this_process. r=njn
MozReview-Commit-ID: 239BJOa2bix

--HG--
extra : rebase_source : 36f248d60bf4c82deb2a62c5a45d9c1c3c44af2e
extra : histedit_source : e5b2b4cb5f19e6efb69ff8e2d391199d3dbaf3ea
2017-04-08 21:07:52 -04:00
Markus Stange dc05eb93fd Bug 1329114 - Put profiles from other processes into a 'processes' array, not into the threads array, and don't stringify them. r=njn
MozReview-Commit-ID: Ccl6JIbRMyX

--HG--
extra : rebase_source : 1b9a5bbff6da5b1dbfb907630900526e95981a28
extra : histedit_source : 8c830a0178c14fdb044dea2c7323025d3892454b
2017-04-08 16:00:30 -04:00
Markus Stange eb07a56986 Bug 1356752 - Fix --enable-tasktracer build by adding the missing aWriter argument. r=njn
MozReview-Commit-ID: L87KE3BmYRB

--HG--
extra : rebase_source : 09e34cc04ea7f76a07419e0e75cc0b097c001b6b
2017-04-15 00:22:07 -04:00
Nicholas Nethercote 1fbc5e1dab Bug 1355807 - Fix condition guarding stopJSSampling() calls. r=jseward.
PseudoStack requires that startJSSampling() and stopJSSampling() calls be
interleaved. But currently the conditions guarding those calls don't match:
startJSSampling() is guarded by ShouldProfileThread(), and stopJSSampling() is
guarded by HasProfile().

It's possible for HasProfile() to be true when ShouldProfileThread() is not
true -- e.g. profile many threads, then restart and profile fewer threads, and
we end up with live threads that have a profile but aren't being profiled right
now -- which leads to assertion failures in stopJSSampling().

This patch makes the stopJSSampling() condition use ShouldProfileThread(), just
like the startJSSampling() condition, which fixes the assertion failure.

--HG--
extra : rebase_source : e9931928c8ac1301f5018f9da319bc478722b98e
2017-04-13 09:34:42 +10:00
Julian Seward 553b8e9b10 Bug 1354546 - Make LUL read CFI from the main executable on x86_64-Linux. r=n.nethercote.
LUL doesn't read CFI from the main executable on x86_64-linux, and possibly
other Linux variants, because SharedLibraryInfo::GetInfoForSelf() doesn't
produce a name for the main executable object, even though it does notice the
mapping.

This causes noticeable unwind breakage because the main executable on Linux
contains various wrapper functions pertaining to memory allocation and locking,
such as

  moz_xmalloc, moz_xcalloc, moz_xrealloc
  mozilla::detail::MutexImpl::lock, mozilla::detail::MutexImpl::unlock

and is generally observable on x86_64-Linux as unwinding failures out of
functions with addresses around 0x40xxxx, since that's the traditional load
address for the main executable.

This patch modifies the Linux implementation of GetInfoForSelf() so as to
harvest the main executable's name from /proc/self/maps.  This is then added
into the information acquired from dl_iterate_phdr.  As a result
GetInfoForSelf() does correctly report the executable name, so LUL reads Dwarf
unwind info from it, and the abovementioned unwinding failures disappear.

--HG--
extra : rebase_source : 267c6d7c3967a4d29f8ff0b4a91d339a6625085d
2017-04-12 07:56:58 +02:00
Nicholas Nethercote 32998fa82c Bug 1347258 - Pass TickSample as a reference, not a pointer. r=mstange.
--HG--
extra : rebase_source : cec4e4435b5e67b4bbf29c5f0637f5ebe3a37fca
2017-04-12 14:56:41 +10:00
Nicholas Nethercote 02ad712a35 Bug 1355357 (part 3) - Construct nativeStack with the right count. r=jseward.
--HG--
extra : rebase_source : 1f619c7fd3af728d34d1f0d350e0d94fa618b5d0
2017-04-11 18:49:00 +10:00
Nicholas Nethercote 2ce4e19d9c Bug 1355357 (part 2) - Avoid a GetThreadHandle() call. r=jseward.
Using ProfiledThread() instead avoids a cast.

--HG--
extra : rebase_source : ddd6b75bc741fc04aa94d0ec2494eb24a2ef9fca
2017-04-11 18:48:02 +10:00
Nicholas Nethercote e64832b7ec Bug 1355357 (part 1) - Rename profiled_thread_ and profiled_thread() in PlatformData. r=jseward.
--HG--
extra : rebase_source : e223ab428aeeb0e711c31dc47a19d5d1bcc471ed
2017-04-11 18:47:15 +10:00
Julian Seward ac843f7319 Bug 1355052 - Tidy up shared-linux-libraries.cc. r=n.nethercote.
shared-linux-libraries.cc is a maze of ifdefs which is hard to navigate, hard to
reason about and gets in the way of making a proper fix for bug 1354546.  This
bug is for cleanup only.  It should not change any functionality.

The following changes are made:

* adds emacs/vi tab-width lines

* removes the ARRAY_SIZE macro as it appears to be unused

* documents the 3 different configurations, splits #includes accordingly

* comments SharedLibraryInfo::GetInfoForSelf accordingly

* wraps some long lines

* documents in which cases dl_iterate_phdr is used and in which cases
  /proc/<pid>/maps is used

* Puts /proc/<pid>/maps reading in its own scope

* Makes the LOG messages on failure clearer
2017-04-11 18:11:16 +02:00
Kan-Ru Chen da0e46ae95 Bug 1355123 - Initialize gecko profiler properly for IPDL test runner. r=mstange,njn
MozReview-Commit-ID: C9hkZPj3SVL
2017-04-11 10:56:58 -04:00
Nicholas Nethercote d8427b066c Bug 1354436 - Fix crash when MOZ_PROFILER_HELP is specified. r=jseward.
--HG--
extra : rebase_source : 86bedf7edc2b0bfce3b75f8828f3c4fb5015a16c
2017-04-10 14:52:05 +10:00
Nicholas Nethercote 632b8b594d Bug 1353630 (part 5) - Allocate PseudoStack within ThreadInfo's constructor. r=jseward. 2017-04-06 09:40:28 +10:00
Nicholas Nethercote bd098b6cbc Bug 1353630 (part 4) - Separate ThreadInfos for live and dead threads. r=jseward.
Currently, ThreadInfos for live and dead threads are stored in a single vector.
This patch separates them into two separate vectors.

This ensures that the two kinds of ThreadInfos can't be mixed up. It also means
ThreadInfo::mPendingDelete can be removed.
2017-04-03 10:40:23 +10:00
Nicholas Nethercote 3bd73aaa4b Bug 1353630 (part 3) - Don't hold onto ThreadInfos for dead threads that aren't being profiled. r=jseward.
Currently, when the profiler is active we hold onto the ThreadInfo of all
threads that die. Then when capturing a profile we ignore all threads that
aren't being profiled.

This patch changes things so we only hold onto the ThreadInfos of threads that
die if they are being profiled. In effect it removes state 3 from the following
list of possible ThreadInfo states:

  1. !PendingDelete + !HasProfile
  2. !PendingDelete + HasProfile
  3. PendingDelete + !HasProfile  (no longer used)
  4. PendingDelete + HasProfile
2017-04-03 10:40:23 +10:00
Nicholas Nethercote 76d203f1da Bug 1353630 (part 2) - Replace MaybeSetProfile() with ShouldProfileThread(). r=jseward.
MaybeSetProfile() does a check and then sets on success. By separating the
check from the set, we can avoid some subsequent HasProfile() checks.
2017-04-06 07:44:59 +10:00
Nicholas Nethercote 9c349c7a6c Bug 1353630 (part 1) - Refactor ThreadResponsiveness use in ThreadInfo. r=mstange.
Now that ThreadResponsiveness is only used on the main thread, we can refactor
ThreadInfo a bit. This patch does the following.

- Removes ThreadInfo::mThread, which is unused.

- Changes ThreadInfo::mRespInfo to a Maybe<>, and moves the is-main-thread
  checking outside of ThreadInfo and ThreadResponsiveness.

- Renames {ThreadInfo,TickSample}::mRespInfo as mResponsiveness, to better
  match the class name.
2017-04-05 15:53:13 +10:00
Nicholas Nethercote df889bc9f6 Bug 1350967 (part 2) - Remove profiler_get_profile_jsobject_async() and profiler_save_profile_to_file_async(). r=mstange.
The state management is better done within nsProfiler::GetProfileDataAsync()
and nsProfiler::DumpProfileToFileAsync(). (The latter function is new in this
patch.)

This fixes a deadlock.

Other notes:

- The patch moves ProfileGatherer from ProfilerState to nsProfiler. This is
  nice because the former is shared between threads but the latter is main
  thread only. (This is how the deadlock is avoided.)

- ProfilerStateMutex and PSLockRef are no longer required in platform.h. Those
  types and variables are now only used in platform.cpp and platform-*.cpp.

- ProfilerGatherer now calls profiler_get_profile() instead of ToJSON(). Which
  means that ToJSON() now has a single caller, so the patch inlines it at the
  callsite and removes it.

- profiler_save_profile_to_file_async() dispatched a Runnable to the main
  thread. But this wasn't necessary, because it always ran on the main thread
  itself. So the new function nsProfiler::DumpProfileToFileAsync() doesn't do
  that.

- profiler_will_gather_OOP_profile(), profiler_gathered_OOP_profile(), and
  profiler_OOP_exit_profile() are all moved into nsProfiler as well. This
  removes the need for the horrible fake lock in
  profiler_will_gather_OOP_profile(), hooray!
2017-03-29 15:48:13 +11:00
Nicholas Nethercote 445b5b7145 Bug 1350967 (part 1) - Remove profiler_get_profile_jsobject. r=mstange.
The conversion to a JSObject is better done within
nsProfiler::GetProfileData().

--HG--
extra : rebase_source : 4a0ba97d99681fca96f2d26b609bafe188095787
2017-03-29 14:02:37 +11:00
Nicholas Nethercote f91e7e7672 Bug 1351963 (part 9) - Improve SetSampleContext(). r=jseward.
SetSampleContext() sets the TickSample's register fields, and the two callers
of SetSampleContext() set the TickSample's mContext.

This patch changes SetSampleContext() so it sets all the fields in one place.
It also renames SetSampleContext() as FillInSample(), because it sets more than
just the context.

--HG--
extra : rebase_source : 9b9f749fe3de687a7fd32f5c38e2321c2abebfdc
2017-03-31 11:13:28 +11:00
Nicholas Nethercote c29e97d66d Bug 1351963 (part 8) - Simplify PseudoStack ownership. r=jseward.
Currently each live thread has a PseudoStack that is owned by tlsPseudoStack,
and a ThreadInfo that has a non-owning pointer to the same PseudoStack.
Then, if the profile is active when the thread dies, ownership of the
PseudoStack is transferred to the ThreadInfo.

This patch simplifies the ownership rules. Every ThreadInfo now always owns its
PseudoStack and is responsible for destroying it. tlsPseudoStack is a
non-owning pointer, and so must be cleared when a PseudoStack is destroyed.
This simplifies the code in a few places.

--HG--
extra : rebase_source : 1012b6590380091d60eff98b4e0c5b1ba946cc7e
2017-03-31 11:01:50 +11:00
Nicholas Nethercote 00f3bc4e23 Bug 1351963 (part 7) - Factor out repeated thread-finding code. r=jseward.
The patch also adds a MOZ_RELEASE_ASSERT in profiler_unregister_thread() for
the case where the ThreadInfo isn't found, which is informative.

--HG--
extra : rebase_source : 11a86914db235e4a60955ff1c9b77d46109af548
2017-03-24 09:24:45 +11:00
Nicholas Nethercote 28cde67779 Bug 1351963 (part 6) - Remove ThreadInfo from TickSample. r=jseward.
This avoids the need for the fake ThreadInfo in profiler_get_backtrace(). It
requires adding a few extra fields to TickSample.

--HG--
extra : rebase_source : c28e5493edc7db96a7160e78b297ae09dc05ca7c
2017-03-31 10:49:36 +11:00
Nicholas Nethercote f76f4f4892 Bug 1351963 (part 5) - Improve TickSample. r=jseward.
This patch does the following.

- Splits TickSample's constructor in two, one for the periodic sample case, and
  one for the synchronous sample case, and initializes more stuff in them. (The
  two constructors aren't that different right now, but they will become more
  different when I remove TickSample::mThreadInfo.)

- Makes all the constructor-filled fields in TickSample |const|.

- Reorders the fields so that the constructor-filled ones are before the ones
  that get filled in later.

- Omits mContext on Mac via conditional compilation, to make the omission
  clearer.

--HG--
extra : rebase_source : f3e392c4cf777df5b9f39577af82615890137018
2017-03-31 10:35:54 +11:00
Nicholas Nethercote 25993378b9 Bug 1351963 (part 4) - Make the LastSample argument to addTagThreadId optional. r=jseward.
LastSample only makes sense for periodic samples, which are written to the
global ProfileBuffer. It doesn't make sense for synchronous samples which are
written to their own unshared buffer. At the moment it doesn't hurt to use
them in this nonsensical way, but the ThreadInfo profiler_get_backtrace()
will be removed soon, and we won't even have a LastSample to use nonsensically.

So this patch makes the LastSample argument to addTagThreadId() optional. Which
means we have to pass in a ThreadId, so there's no longer much point
duplicating the ThreadId in LastSample, so the patch removes that field too.
This avoids the possibility of the duplicate ThreadId failing to match, which
is nice.

--HG--
extra : rebase_source : dad76ff8b33663398e6f45f85da500b0fd7a598f
2017-03-31 10:13:13 +11:00
Nicholas Nethercote f9ffeeb27b Bug 1351963 (part 3, attempt 2) - Remove ThreadInfo from ProfilerBacktrace. r=mstange. 2017-04-04 09:41:53 +10:00
Nicholas Nethercote 44c0cb1064 Bug 1351963 (part 2, attempt 2) - Move StreamSamplesAndMarkers() out of ThreadInfo. r=mstange. 2017-04-04 09:41:11 +10:00
Carsten "Tomcat" Book 8d910c41e3 merge mozilla-inbound to mozilla-central a=merge 2017-04-03 12:13:46 +02:00
Carsten "Tomcat" Book ac161c6904 Backed out changeset d9ce5cdb4e5a (bug 1351963) for hopefully fix the dt leaks 2017-04-03 08:19:22 +02:00
Carsten "Tomcat" Book b9e48685b2 Backed out changeset 016c13131fff (bug 1351963) 2017-04-03 08:18:55 +02:00
Nicholas Nethercote 5ed484057c Bug 1351963 (part 3) - Remove ThreadInfo from ProfilerBacktrace. r=mstange.
At this point the only things in the ThreadInfo it uses are the thread name and
id, which are easy to store instead. This gets a step closer to avoiding the
use of ThreadInfo in profiler_get_backtrace().

--HG--
extra : rebase_source : f4feb08ec9fe7880ee43f784c6878c1c04fd3294
2017-03-31 09:41:42 +11:00
Nicholas Nethercote 9fe90f9b94 Bug 1351963 (part 2) - Move StreamSamplesAndMarkers() out of ThreadInfo. r=mstange.
StreamSamplesAndMarkers() is the only ThreadInfo method called on
ProfilerBacktrace::mThreadInfo. Furthermore, it doesn't use all that much stuff
from ThreadInfo, and what stuff it does use we can instead pass in as
arguments.

This patch moves StreamSamplesAndMarkers() out of the class. It's a little
ugly, but a necessary precursor for removing ProfilerBacktrace::mThreadInfo and
all the subsequent improvements.

--HG--
extra : rebase_source : 417bda4f29a27c525f7240d3427494dd86b9a868
2017-03-31 09:37:24 +11:00
Nicholas Nethercote c6942af645 Bug 1351963 (part 1) - Tidy up ThreadInfo. r=mstange.
It doesn't need any virtual methods, nor the FRIEND_TEST declarations.

--HG--
extra : rebase_source : 973c01f43737d5672b0257bb40e029894857a90d
2017-03-31 09:28:41 +11:00
Nicholas Nethercote 8a81f4a587 Bug 1351136 - Write a gtest for basic features of the Gecko Profiler. r=mstange.
This required a tweak to DoNativeBacktrace() to work around an ASAN false
positive.

--HG--
extra : rebase_source : 2e21ae4c132db812150f42c26aa708aefce311be
2017-03-29 15:49:44 +11:00
Markus Stange 353da4ad55 Bug 1351920 - Check privacy mode during sampling, not during PROFILER_LABEL_DYNAMIC. r=njn
When the profiler is running in privacy mode, we don't want to include dynamic
strings from PROFILER_LABEL_DYNAMIC to end up in the profile.
Rather than checking this every time we enter a scope marked with
PROFILER_LABEL_DYNAMIC, with this patch we will push the dynamic string into
the pseudo stack entry regardless, and then check the privacy mode during
sampling and ignore the dynamic string as necessary.
This way we can avoid taking the profiler state lock in PROFILER_LABEL_DYNAMIC
and also save a branch.

MozReview-Commit-ID: 5dXrtMuFJ5r

--HG--
extra : rebase_source : 1c2057e7ced332d9001137b5b280feab77a712e5
2017-03-30 12:41:04 -04:00
Nicholas Nethercote 6e2f13d8c2 Bug 1351946 (part 2) - Inline and remove GetEntries() and GetInterval(). r=mstange.
--HG--
extra : rebase_source : 127ff560940a93bf9bd5298ac6ab92812bdd94c7
2017-03-30 17:49:27 +11:00
Nicholas Nethercote 35bc116a65 Bug 1351946 (part 1) - Remove SigstartHandler from the profiler. r=mstange.
It was only needed for B2G.

--HG--
extra : rebase_source : 2063f1560503989d0ae0d3f2609e031bd06851a9
2017-03-30 16:27:20 +11:00
Nicholas Nethercote ecaa485dee Bug 1348024 - Make the env vars MOZ_PROFILER_{ENTRIES,INTERVAL} specific to startup. r=mstange.
The patch also renames profiler_usage() as PrintUsageThenExit().

--HG--
extra : rebase_source : 28b49f9f99d760ef1fcd1d56f8035caa0c5f2192
2017-03-23 13:44:15 +11:00
Nicholas Nethercote 2a3ba6e9fa Bug 1351528 (part 2) - Rename TracingMetadata as TracingKind. r=mstange.
"Metadata" regularly confuses me, because it suggests something complicated
rather than a simple enum.

This change also has the benefit of removing inconsistent capitalization
("Metadata" vs. "MetaData").

--HG--
extra : rebase_source : b651e124142c8d93139d22dae1c993c899be4d7a
2017-03-29 13:56:14 +11:00
Nicholas Nethercote 4285c8907d Bug 1351528 (part 1) - Streamline TracingMetadata. r=mstange.
This patch:

- Removes TRACING_EVENT_BACKTRACE, which is unused.

- Removes TRACING_DEFAULT and replaces all its uses with TRACING_EVENT, because
  there is no difference in how those two are used.

- Removes TRACING_TIMESTAMP, which is unused and also doesn't do anything
  different to TRACING_EVENT.

--HG--
extra : rebase_source : 69af1c53aa918798d8050e6b9d1a2658a0902af5
2017-03-29 13:52:47 +11:00
Nicholas Nethercote 37a83290da Bug 1351523 - Reorder profiler_get_start_params() arguments. r=mstange.
profiler_start() and nsProfilerStartParams() both have features before filters.
This patch makes profiler_get_start_params() follow suit.
2017-03-29 13:22:29 +11:00
Nicholas Nethercote a8a6c5c4ba Bug 1348776 (part 2) - Fix up HAVE_NATIVE_UNWIND. r=mstange.
This patch simplifies and increases the consistency of how HAVE_NATIVE_UNWIND
is used.

- Its definition is moved from platform.h to platform.cpp, because the latter
  is the only file that uses it.

- It's now defined in the same place as USE_{NS,EHABI,LUL}_STACKWALK, and used
  in preference to those, where possible. Also, it's now defined on Linux and
  Android even if MOZ_PROFILING is not.

- HAVE_NATIVE_UNWIND is now used consistently and by itself for all relevant
  conditions, including when defining the presence and use of the "stackwalk"
  feature.

- The patch inlines and removes is_native_unwinding_avail().

Note that MOZ_PROFILING must be defined for HAVE_NATIVE_UNWIND to be true on
Windows and Mac, but not on Linux and Android.

--HG--
extra : rebase_source : 5be3e5fe65706a15179a2cf46ba9451f68fff815
2017-03-27 17:04:56 +11:00
Nicholas Nethercote 399c98ac3c Bug 1348776 (part 1) - Fix a crash in the profiler when MOZ_PROFILING is undefined. r=mstange.
Bug 1339695 part 8 unintentionally changed behaviour in profiler_init() when
MOZ_PROFILING is undefined. This patch undoes that change.

--HG--
extra : rebase_source : 16e992382e06fbc673555c87499c236e2b39bc7f
2017-03-27 16:49:41 +11:00
Nicholas Nethercote 32c944de0f Bug 1350212 - Improve TickSample. r=jseward.
This patch does the following.

- Renames TickSample's members to mFoo style.

- Changes TickSample's constructor to set mTimeStamp.

- Moves TickSample creation from
  SamplerThread::SuspendAndSampleAndResumeThread() to SamplerThread::Run(), so
  it's not repeated for each platform.

- Changes TickSample::PopulateContext() so it takes a |tick_context_t*|
  parameter, which avoids having to cast from |void*|.
2017-03-24 15:09:05 +11:00
Nicholas Nethercote 56501f9f6f Bug 1350211 - Re-enable native stack walking on Android. r=mstange.
Bug 1339695 part 8 accidentally disabled native stack walking on Android by
using GP_arm_android instead of GP_PLAT_arm_android in a #if. This patch fixes
that. It also fixes a couple of compile errors that crept into the relevant
code while it was disabled.

--HG--
extra : rebase_source : a7a94b018b8de7a7ca3c621a2b662859a65e69c1
2017-03-24 17:02:54 +11:00
Nicholas Nethercote e0caeb137c Bug 1346132 (part 5) - Remove ThreadInfo::CanInvokeJS. r=jseward.
It's unused.

--HG--
extra : rebase_source : 37483099d82004ba1d66cf7a3bb60d5cefd3f03d
2017-03-23 12:42:55 +11:00
Nicholas Nethercote be676c67d2 Bug 1346132 (part 4) - Improve the profiler's logging output. r=jseward.
This patch adds logging to some important functions that currently lack it.
Thread registration/unregistration is done with DEBUG_LOG because it's
more verbose than the other profiler logging, but less verbose than LUL's
logging.

The patch also scraps the BEGIN/END logging pairs because they bloat the output
for little gain. Now it just logs on function entry.

--HG--
extra : rebase_source : 3ef3d263c19cda03198e8b3a9ab89866f74ed1cd
2017-03-15 10:56:50 +11:00
Nicholas Nethercote f1d3df720c Bug 1346132 (part 3) - Remove the profiler's bespoke logging system in favour of MOZ_LOG. r=erahm,jseward.
The profiler will use level 3 (Info) and 4 (Debug) logging, though this patch
only uses level 3. LUL will use level 5 (Verbose) debugging.

The patch also tweaks parts of the the usage message, including adding
MOZ_PROFILER_{STARTUP,SHUTDOWN} to it.

--HG--
extra : rebase_source : f43a023912fbce993ed367cdd26b8f25f25381de
2017-03-14 16:49:12 +11:00
Nicholas Nethercote e105cad299 Bug 1346132 (part 2) - Remove set_stderr_callback(). r=mstange.
It's a very general mechanism for replacing the implementation of
printf_stderr().

It's primarily used by the profiler, sparingly, and not in an important way.
Worse, it prevents us from using MOZ_LOG in the profiler, which is something I
want. Because if any code that locks gPSMutex also calls MOZ_LOG, that then
calls printf_stderr(), which calls profiler_log(), which locks gPSMutex, which
deadlocks.

The only other use of set_stderr_callback() is for the ultra-hacky,
for-local-use-only copy_stderr_to_file() function, which was added for B2G
debugging and is no longer necessary.

This patch removes set_stderr_callback() altogether.

--HG--
extra : rebase_source : d31ecb482fe5899f62dc56a38e87d91f9271bab0
2017-03-16 08:17:56 +11:00
Julian Seward 31acb1259a Bug 1344169 - Factor out the common parts of SamplerThread::Run(). r=n.nethercote.
All three platform-*.cpp files have similar structure, most especially for
SamplerThread::Run(), with considerable duplication.  This patch factors out
the common parts into a single implementation in platform.cpp.

* The top level structure of class SamplerThread has been moved to
  platform.cpp.

* The class has some target-dependent fields, relating to signal handling and
  thread identity.

* There's a single implementation of Run() in platform.cpp.

* AllocPlatformData() and PlatformDataDestructor::operator() have also been
  commoned up and moved into platform.cpp.

* Time units in SamplerThread have been tidied up.  We now use microseconds
  throughout, except in the constructor.  All time interval field and variable
  names incorporate the unit (microseconds/milliseconds) for clarity.  The
  Windows uses of such values are scaled up/down by 1000 accordingly.

* The pre-existing MacOS Run() implementation contained logic that attempted
  to keep "to schedule" in the presence of inaccuracy in the actual sleep
  intervals.  This now applies to all targets.  A couple of comments on this
  code have been added.

* platform-{win32,macos,linux-android}.cpp have had their Run() methods
  removed, and all other methods placed in the same sequences, to the extent
  that is possible.

* In the Win32 and MacOS implementations, Thread::SampleContext has been
  renamed to Thread::SuspendSampleAndResumeThread as that better describes
  what it does.  In the Linux/Android implementation there was no such
  separate method, so one has been created.

* The three Thread::SuspendSampleAndResumeThread methods have been commented
  in such a way as to emphasise their identical top level structure.

* The point in platform.cpp where platform-{win32,macos,linux-android}.cpp are
  #included has been moved slightly earlier in the file, into the
  SamplerThread encampment, as that seems like a better place for it.

--HG--
extra : rebase_source : 0f93e15967b810c09e645fa593dbf85f94b53a9b
2017-03-10 16:10:14 +01:00
Carsten "Tomcat" Book 492970c342 merge mozilla-inbound to mozilla-central a=merge 2017-03-23 13:44:09 +01:00
Julian Seward 660aaef3f5 Bug 1345032 - Further cost reductions for ProfileBuffer::FindLastSampleOfThread. r=n.nethercote.
ProfileBuffer::FindLastSampleOfThread currently involves a linear search
backwards through the sample buffer.  Profiling showed that to be the largest
profiler cost by far, at least on Linux.  Bugs 1344118 and 1344258
significantly improve the situation, collectively reducing the cost by a
factor of at least 5 and often much more.  But the linear search is still
present and still dominant.  The worst of it is that it's unnecessary: we
could achieve the same by recording the start point of the most recent sample
for each thread in that thread's ThreadInfo record.

This patch does exactly that, adding the type ProfileBuffer::LastSample to
store the start points.  LastSample also includes the ID of the thread it
pertains to as a read-only field, as that is needed in various places.

addTag doesn't check whether we're overwriting buffer entries containing start
points.  Instead, FindLastSample checks whether the entry pointed to the
LastSample it is given still contains a marker.

--HG--
extra : rebase_source : 2987ec744a5c16e8b6814abe7efb507fc7280605
2017-03-22 11:18:31 +01:00
Luke Wagner 2164377bd8 Bug 1334504 - Baldr: maintain fp register instead a virtual fp (r=bbouvier)
MozReview-Commit-ID: 2Mi60u3DyJg

--HG--
extra : rebase_source : 155ce830bcd55e7f9fdf890d4da4b1c12377f12b
2017-03-22 17:26:05 -05:00
Markus Stange 730b4fc829 Bug 1339897 - Rename PROFILER_LABEL_PRINTF to PROFILER_LABEL_DYNAMIC and make it really cheap. r=Ehsan,njn
Instead of copying and concatenating strings into an mDest buffer in
SamplerStackFramePrintfRAII, require callers to keep the string buffer alive
for the duration of the current scope, and store the pointer to the annotation
string in the ProfileEntry. During stackwalking, concatenate the label and the
annotation (separated by a space) and store the resulting string in the
profile buffer.

MozReview-Commit-ID: GEjcLrhhdvb

--HG--
extra : rebase_source : 683749421ee2122805a249cf413e882ee5f33331
2017-03-22 19:37:33 -04:00
Nicholas Nethercote fa5cfb7c00 Bug 1348374 - Remove paf_child(). r=jseward.
It's not necessary and causes hangs.

The patch also inlines setup_atfork() and moves the Linux-only code closer to
the Linux-only PlatformInit(), and tweaks the comments a bit.

--HG--
extra : rebase_source : 0db23d649d9468b9308b881c0bbf5ea25a95ea13
2017-03-21 09:52:15 +11:00