Commit Graph
224 Commits
Author SHA1 Message Date
David Major 342f4b3c88 Bug 1349801: Make aMicroseconds unsigned to avoid a bunch of checks. r=mstange
We already do a max(0,...) before calling anyway.
2017-05-16 11:06:18 -04:00
David Major b951e466a8 Bug 1349801: Make SleepMicro a method of SamplerThread. r=mstange
So that I can use mIntervalMicroseconds in a later patch.
2017-05-16 11:03:33 -04:00
Carsten "Tomcat" Book d4006b93b2 merge mozilla-inbound to mozilla-central a=merge 2017-05-16 15:04:38 +02:00
Nicholas Nethercote 209adb45c8 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.
2017-05-10 20:13:21 +10:00
Kris Maglione f6271722fc Bug 1348031: Part 1 - Allow specifying fractional-millisecond startup profiling interval. r=mstange
MozReview-Commit-ID: Ga1ebO03gp5
2017-05-15 14:19:12 -07:00
Ehsan Akhgari ee496dbb18 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 8939558368 Bug 1363475 - Fix TaskTracer build failure. r=njn
MozReview-Commit-ID: 7ENK05KNcGn
2017-05-04 17:26:54 -04:00
Nicholas Nethercote a6a675932c 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.
2017-05-08 07:09:33 +10:00
Nicholas Nethercote a7e5660c91 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 da42e4205e 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 7ff73e9647 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
David Major 3f9cd96dfc 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 001a43109f Bug 1351838: Don't sprintf within the profiler since it may take a lock. r=froydnj 2017-05-01 17:57:12 -04:00
David Major d1278b6a61 Bug 1360642: Increase SAMPLER_MAX_STRING_LENGTH to capture more URLs. r=mstange 2017-05-01 16:26:39 -04:00
Michael Layzell 81d95ba1f5 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 34968a40ec 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 58a28f63c7 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 bc85888835 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.
2017-04-27 07:36:22 +10:00
Nicholas Nethercote 3dbdcca05c 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.
2017-04-27 07:36:19 +10:00
Nicholas Nethercote 4131aa3b69 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.
2017-04-27 07:36:17 +10:00
Nicholas Nethercote 135bba3f1f 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.
2017-04-27 07:36:15 +10:00
Nicholas Nethercote edda79d96d 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.
2017-04-27 07:36:13 +10:00
Nicholas Nethercote c4b55083ae 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.
2017-04-27 07:36:11 +10:00
Nicholas Nethercote 43a4a5e777 Bug 1359000 (part 3) - Rename some "stack" variables as "pseudoStack". r=mstange.
"pseudoStack" more closely matches the type name, and is more specific.
2017-04-27 07:36:09 +10:00
Nicholas Nethercote c9bc75f7fd 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.
2017-04-24 09:49:28 +10:00
Nicholas Nethercote d04947e2bf 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.
2017-04-21 13:28:23 +10:00
Nicholas Nethercote 518b61128f 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.
2017-04-18 15:40:24 +10:00
Nicholas Nethercote c768a954ae 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 b2c96e3507 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!)
2017-04-26 14:32:26 +10:00
Nicholas Nethercote ac5af9ea94 Bug 1358074 (part 6, attempt 2) - Don't use mWasPaused on Android. r=mstange. 2017-04-21 13:27:59 +10:00
Nicholas Nethercote 4da67d7fcf Bug 1358074 (part 5, attempt 2) - Rename mThreadNameFilters as mFilters. r=mstange. 2017-04-21 13:27:55 +10:00
Nicholas Nethercote 60cdc6d052 Bug 1358074 (part 4, attempt 2) - Rename PS::{Mutex,AutoLock,LockRef} as PS{Mutex,AutoLock,LockRef}. r=mstange. 2017-04-21 13:27:53 +10:00
Nicholas Nethercote ea3673c475 Bug 1358074 (part 3, attempt 2) - Don't measure process creation time on every profiler_start() call. r=mstange. 2017-04-21 13:23:34 +10:00
Nicholas Nethercote f172d6ec32 Bug 1358074 (part 2, attempt 2) - Unexport and rename ProfilerState. r=mstange. 2017-04-21 13:23:34 +10:00
Nicholas Nethercote 0196120d08 Bug 1358074 (part 1, attempt 2) - Fix some bad indentation in platform.cpp. r=mstange. 2017-04-19 14:47:18 +10:00
Julian Seward 9938eb3085 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.
2017-04-25 08:14:23 +02:00
Iris Hsiao da75e076c9 Backed out 6 changesets (bug 1358074) for Assertion failure: NS_IsMainThread and valgrind failures
Backed out changeset c3f35f8a1f21 (bug 1358074)
Backed out changeset 1d214f8ac8fd (bug 1358074)
Backed out changeset 3221b215b080 (bug 1358074)
Backed out changeset adec21069065 (bug 1358074)
Backed out changeset 9baa76979a71 (bug 1358074)
Backed out changeset 8375b7a4be08 (bug 1358074)
2017-04-24 16:50:50 +08:00
Nicholas Nethercote cf3f6fd570 Bug 1358074 (part 6) - Don't use mWasPaused on Android. r=mstange.
It's not needed.
2017-04-21 13:27:59 +10:00
Nicholas Nethercote 4d65b86223 Bug 1358074 (part 5) - Rename mThreadNameFilters as mFilters. r=mstange.
The new name is more concise and matches common usage elsewhere (e.g.
profiler_start() arguments).
2017-04-21 13:27:55 +10:00
Nicholas Nethercote 030283e8a9 Bug 1358074 (part 4) - Rename PS::{Mutex,AutoLock,LockRef} as PS{Mutex,AutoLock,LockRef}. r=mstange.
A subsequent patch is going to split PS into two classes, and both classes will
need access to these types. So this patch moves them to the top level.
2017-04-21 13:27:53 +10:00
Nicholas Nethercote c8c5be712a Bug 1358074 (part 3) - Don't measure process creation time on every profiler_start() call. r=mstange.
We measure it in profiler_init(); there's not point overwriting it with the
same value every time profiler_start() is called!

The patch also renames mStartTime as mProcessStartTime to make things clearer.
2017-04-21 13:23:34 +10:00
Nicholas Nethercote b9a7e07c18 Bug 1358074 (part 2) - Unexport and rename ProfilerState. r=mstange.
gPS is declared in GeckoProfiler.h so that it can be tested as non-null in a
couple of functions.

- These checks are of little value, so this patch removes them.

- That lets us remove the ProfilerState and gPS declarations from
  GeckoProfiler.h.

- And, because ProfilerState is now only used within platform.cpp, that lets us
  rename it as PS, which is how we currently refer to it (via a typedef) within
  platform.cpp anyway.
2017-04-21 13:23:34 +10:00
Nicholas Nethercote 5f8d566280 Bug 1358074 (part 1) - Fix some bad indentation in platform.cpp. r=mstange. 2017-04-19 14:47:18 +10:00
Nicholas Nethercote 81d74b72c9 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|.
2017-04-20 09:24:17 +10:00
Julian Seward 7184ef6faa 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.
2017-04-18 10:30:14 +02:00
Carsten "Tomcat" Book a76fde59da merge mozilla-inbound to mozilla-central a=merge 2017-04-18 10:21:31 +02:00
Nicholas Nethercote 46549c8339 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.
2017-04-18 14:40:00 +10:00
Markus Stange 09dea9f2ae 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
2017-04-17 22:46:54 -04:00
Iris Hsiao 25bc12c9fe Backed out changeset 1b277ae21ba5 (bug 1346592)
CLOSED TREE
2017-04-18 11:05:12 +08:00
Markus Stange ef0f911e91 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
2017-04-16 13:41:32 -04:00