Commit Graph
104 Commits
Author SHA1 Message Date
Nicholas Nethercote 5f9f77b7cc Bug 1328378 (part 6) - Eliminate SyncProfile. r=mstange.
It's now a very thin wrapper around ThreadInfo, and so can be removed.

The patch also has the bonus of setting mIsMainThread correctly for the
ThreadInfos that used to be SyncProfiles (i.e. the ones created in
profiler_get_backtrace()). As far as I can tell this has only one very minor
effect, because that field is only used for those objects to determine how
ThreadResponsiveness::Update() dispatches its runnables.
2017-02-27 12:56:42 +11:00
Nicholas Nethercote aace96c23d Bug 1328378 (part 5) - Simplify ProfileBuffer handling. r=mstange.
Currently ThreadInfo objects all share gBuffer, while SyncProfile objects each
get their own ProfileBuffer.

This patch removes ThreadInfo::mBuffer to reduce this difference, taking us a
step towards eliminating SyncProfile.

To support this, the patch:

- passes in a buffer as an additional argument in a bunch of places where the
  buffer used to be obtained from a ThreadInfo;

- adds an mBuffer field to ProfilerBacktrace;

- changes ThreadInfo::SetProfile() to SetHasProfile();

- removes ThreadInfo::{addTag,StoredMarker,bufferGeneration}(), all of which
  just redirected to ThreadInfo anyway;

- changes ProfileBuffer so it's no longer refcounted, which is unnecessary now
  that gBuffer and ProfilerBacktrace::mBuffer don't have multiple references,
  which makes their lifetimes obvious.

The patch also removes some ThreadInfo& args in functions in platform.cpp, in
places where that ThreadInfo is available within the accompanying TickSampler*
arg.
2017-02-27 12:34:59 +11:00
Nicholas Nethercote 3d68049002 Bug 1328378 (part 3) - Remove unnecessary locking in profiler_get_backtrace(). r=mstange.
There's no need to lock when calling Tick() on a local TickSample that uses a
fresh SyncProfile with its own fresh ProfileBuffer -- none of that data can
be touched by another thread.
2017-02-27 12:32:18 +11:00
Nicholas Nethercote 7f32135318 Bug 1328378 (part 2) - Remove BeginUnwind() and EndUnwind(). r=mstange.
Both of these functions are now trivial and identical in both ThreadInfo and
SyncProfile. This patch inlines and removes them.
2017-02-27 12:31:44 +11:00
Julian Seward c3547e1c36 Bug 1341255 - Profiler tidyups: remove StackEntry, rename ProfileEntry to ProfileBufferEntry (part 2: rename ProfileEntry). r=n.nethercote. 2017-02-23 23:05:23 +01:00
Julian Seward eb67afc06a Bug 1341255 - Profiler tidyups: remove StackEntry, rename ProfileEntry to ProfileBufferEntry (part 1: remove StackEntry). r=n.nethercote. 2017-02-23 23:04:13 +01:00
Nicholas Nethercote 5855c0f88a Bug 1340928 (part 16) - Clean up profiler env var handling. r=mstange.
This patch does the following.

- Uses "entries" consistently for the name of the value that is obtained from
  MOZ_PROFILER_ENTRIES and is the first argument to profiler_start(). (I.e. not
  "entry" or "entrySize".)

- Removes variables (e.g. PROFILER_HELP) holding env var names and uses the
  names (e.g. "MOZ_PROFILER_HELP") directly. Some of the names are already used
  directly and I think the slight repetition isn't harmful. It's unlikely that
  we'd want to change these names the way we might need to change a numeric
  value, and they're perfectly descriptive.

- Changes the "MOZ_PROFILING_FEATURES" string in the weird Android-only startup
  code to be "MOZ_PROFILER_FEATURES", for consistency.

- Renames gUnwindInterval and gProfileEntries as gEnvVarInterval and
  gEnvVarEntries to make it clearer that they come from environment variables,
  but otherwise are parallel to gInterval and gEntries.

- Puts entries before intervals in most places, to match the profiler_start()
  argument order.

- Changes profiler_usage() so that (a) it always prints, no matter the
  verbosity, (b) it exits at its end, and (c) doesn't double-print "Profiler: "
  at the start of each line.
2017-02-23 14:26:46 +11:00
Nicholas Nethercote 6ee7bc83fa Bug 1340928 (part 15) - Inline and remove ToJSObject(). r=mstange.
It has a single call site.
2017-02-22 13:42:14 +11:00
Nicholas Nethercote ea1ea2233a Bug 1340928 (part 12) - Remove profiler_get_gatherer(). r=mstange.
profiler_get_gatherer() exposes ProfileGatherer to the outside world in a way
that makes future changes difficult.

This patch:

- Removes ProfileGatherer.h from the list of headers exported from the
  profiler.

- Removes nsIProfiler.profileGatherer and nsProfiler::GetProfileGatherer().

- Replaces profiler_get_gatherer() with three new functions that provide
  minimal but sufficient access to ProfileGatherer:
  profiler_will_gather_OOP_profile(), profiler_gathered_OOP_profile(), and
  profiler_OOP_exit_profile().

  These functions provide access to the ProfileGatherer in a similar fashion to
  the pre-existing functions profiler_get_profile_jsobject_async() and
  profiler_save_profile_to_file_async()

This significantly reduces the size of the profiler's API surface.
2017-02-22 10:19:53 +11:00
Nicholas Nethercote 8d16d91822 Bug 1340928 (part 9) - Remove MOZ_PROFILER_STACK_SCAN env var. r=mstange.
It's used to set gUnwindStackScan, which is never used.
2017-02-21 13:53:19 +11:00
Nicholas Nethercote b568af9a69 Bug 1340928 (part 8) - Pass gStartTime to DuplicateLastSample(). r=mstange.
This removes the one use of gStartTime outside of platform*.cpp, which lets us
restrict its visibility to just that compilation unit.
2017-02-21 10:18:51 +11:00
Nicholas Nethercote 7176376740 Bug 1340928 (part 7) - Factor out gIsActive handling in platform-*.cpp. r=mstange.
PlatformStart() and PlatformStop() are currently responsible for setting and
clearing gIsActive, but it's better if we do it in profiler_{start,stop}().

The patch also does the following.

- Adds some missing emacs/vim modelines.

- Makes Platform{Start,Stop}() crash if they have failures. I'm not at all
  confident that ignoring the errors as is currently done will result in
  sensible behaviour, so brittleness is better.
2017-02-16 15:08:07 +11:00
Nicholas Nethercote 12d5ba6d85 Bug 1340928 (part 6) - Clean up profiler code relating to env vars. r=mstange.
This patch mostly does formatting fixes.

It also removes some declarations from platform.h that are no longer necessary
now that platform-linux-android.cpp is in the same compilation unit as
platform.cpp (due to it being #include-d directly); this required reordering
some things.
2017-02-16 13:59:35 +11:00
Nicholas Nethercote f97f7d0682 Bug 1340928 (part 5) - Pass the interval to PlatformStart(). r=mstange.
This avoids the need for platform-linux-android.cpp to read gInterval off the
main thread in an awkward spot. It also makes platform-linux-android.cpp
more like platform-{win32,macos}.cpp.
2017-02-15 14:44:12 +11:00
Nicholas Nethercote fde9459682 Bug 1340928 (part 4) - Remove redundant PlatformStop() call in profiler_stop(). r=mstange.
There is another PlatformStop() call earlier in the function, and gIsActive is
always false by the time we reach the removed call, so it's dead code.
2017-02-15 14:44:12 +11:00
Nicholas Nethercote 0aedc94238 Bug 1340928 (part 3) - Remove Sampler from ProfileGatherer. r=mstange.
It's only being used in a boolean fashion, so this patch replaces it with a
boolean.
2017-02-15 14:44:12 +11:00
Nicholas Nethercote f528fe2d85 Bug 1339695 (part 11) - Remove the profiler's OS class. r=mstange.
We don't need OS now that the platform-*.cpp files are in the same compilation
unit as platform.cpp.

The patch removes the sleep functions because they are unnecessary indirection.

OS::Startup() is necessary, but the patch renames it PlatformInit() to match
Platform{Start,Stop}() and profiler_init(), from which it is called.
2017-02-20 09:07:37 +11:00
Nicholas Nethercote c7ab9c86dc Bug 1339695 (part 10) - Rename SPS_* macros as GP_*. r=jseward.
This removes the final mentions of the old "SPS" name.
2017-02-18 00:57:03 +11:00
Nicholas Nethercote f2a7677b91 Bug 1339695 (part 8) - Clean up platform detection throughout the profiler. r=mstange.
Currently we use the SPS_* macros in some places, but also use other ones like
__arm__ and ANDROID and XP_{WIN,MAC,LINUX}. This patch makes the profiler
consistently use the SPS_* macros and removes the V8_HOST_ARCH_* macros.

The patch also does the following.

- Cleans up some header inclusions, e.g. including pthread.h directly in the
  files that use it, and removing some unneeded android/log.h inclusions.

- Removes an unused branch in SetSampleContext() -- we don't support ARM on
  anything other than Android, and glibc 2.3 is ancient.

- Doesn't use SPS_* in PseudoStack.h because that would require exporting
  PlatformMacros.h, which doesn't seem worthwhile.

Some things that aid the understanding of this patch.

- XP_LINUX and LINUX are both defined for Linux *and* Android.

- x86/Android is the only supported platform that doesn't define
  HAVE_NATIVE_UNWIND.

- Every platform that defines USE_LUL_STACKWALK also defines
  HAVE_NATIVE_UNWIND.
2017-02-18 00:56:21 +11:00
Nicholas Nethercote 45db545bf4 Bug 1339695 (part 7) - Remove ENABLE_LEAF_DATA. r=mstange.
It's defined if any of XP_{WIN,MAC,LINUX} are defined and the latter includes
Android as well. So it's defined on all the OSes the profiler supports.
2017-02-18 00:55:10 +11:00
Marco Castelluccio 2f3e68079b Bug 1330833 - Add the new "modules" (DLLs) ping type. r=Dexter,mstange,jorendorff, data-review=bsmedberg 2017-02-18 14:17:30 +00:00
Nicholas Nethercote 450b97cd7e Bug 1340327 - Set bools earlier in profiler_start(). r=mstange.
They must be set before the call to MaybeSetProfiler(), which checks
gProfileThreads, and before the gTaskTracer check.

This patch fixes the failure of some threads (e.g. Compositor) to be profiled,
as well as allowing TaskTracer to start up again!
2017-02-18 10:16:47 +11:00
Wes Kocher 3f83b41f7e Backed out 2 changesets (bug 1330833) for windows 64 xpcshell failures a=backout
Backed out changeset 466565fa382a (bug 1330833)
Backed out changeset 927194e7769d (bug 1330833)

MozReview-Commit-ID: GB4KsH29xYC
2017-02-16 17:20:54 -08:00
Marco Castelluccio a7e3f95164 Bug 1330833 - Add the new "modules" (DLLs) ping type. r=Dexter,mstange,jorendorff, data-review=bsmedberg 2017-02-16 17:09:32 +00:00
Nicholas Nethercote c7d20db347 Bug 1339695 (part 6) - Remove some B2G-only code in profiler_register_thread(). r=mstange. 2017-02-15 16:26:23 +11:00
Nicholas Nethercote bfa9cc757b Bug 1339695 (part 5) - Introduce PROFILE_JAVA. r=mstange.
This factors out some common preprocessor conditions.
2017-02-15 16:25:22 +11:00
Nicholas Nethercote 9d7aa7eebd Bug 1339435 - Fix bogus assertion in both profiler_time() variants. r=jseward. 2017-02-15 14:36:10 +11:00
Nicholas Nethercote c5d44ba18d Bug 1339327 (part 7) - Rename some things in platform-linux.cc. r=mstange.
The new names are more consistent, and I find them clearer.

The patch also inlines and removes the horribly-named ProfilerSignalThread()
function.
2017-02-15 14:26:23 +11:00
Nicholas Nethercote 401f105d67 Bug 1339327 (part 5) - Rename some profiler functions related to sleeping. r=mstange.
The new names make it clearer that these actions apply to just one thread.

- profiler_sleep_start() --> profiler_thread_sleep()
- profiler_sleep_end()   --> profiler_thread_wake()
- profiler_is_sleeping() --> profiler_thread_is_sleeping()
- GeckoProfilerSleepRAII --> GeckoProfilerThreadSleepRAII
- GeckoProfilerWakeRAII  --> GeckoProfilerThreadWakeRAII
2017-02-15 14:26:23 +11:00
Nicholas Nethercote dda3271ef1 Bug 1339327 (part 4) - Rename some globals in the profiler. r=mstange.
The 'g' prefix is for global variables. The 's' prefix is for static class
members.
2017-02-15 14:26:23 +11:00
Nicholas Nethercote 993dd3b023 Bug 1339327 (part 3) - Remove ToStreamAsJSON(). r=mstange.
This is possible because profiler_shutdown() can call
profiler_save_profile_to_file() to do the saving.
2017-02-15 14:26:23 +11:00
Nicholas Nethercote 98fb0a7ed6 Bug 1339327 (part 1) - Fix profiler_get_features(). r=mstange.
"unwinder" and "jank" are never checked for via hasFeature(), and are not
mentioned anywhere else in the profiler. This patch removes them from
profiler_get_features().

"restyle" *does* have a hasFeature() call and is handled by
profiler_feature_active(). This patch adds it to profiler_get_features().
2017-02-15 14:26:22 +11:00
Nicholas Nethercote 0d9b6f9c8e Bug 1338957 (part 3) - Simplify sleep handling in PseudoStack. r=mstange.
Sleep handling is currently done with two counters (mSleepId, mSleepIdObserved)
and a boolean (mSleeping). This patch replaces it with a single tri-state
variable (mSleep), which is enough to replicate the functionality.

The patch also clearly documents how this variable is accessed from multiple
threads and the potential inaccuracies that can result from races.
2017-02-13 17:22:44 +11:00
Nicholas Nethercote 2b2e185068 Bug 1337189 (follow-up) - Fix MOZ_TASK_TRACER bustage. r=schien. 2017-02-13 16:34:58 +11:00
Nicholas Nethercote 93f15c534f Bug 1337189 (part 26) - Remove Sampler.cpp. r=mstange.
Sampler's constructor and destructor are inlined into profiler_{start,stop}(),
respectively. A trivial Sampler class is left behind (now in platform.cpp)
because there are still numerous gSampler null checks, which I will remove in a
follow-up bug.

PseudoStack::flushSamplerOnShutdown() moves into platform.cpp. MAXPATHLEN is
unused and is deleted.
2017-02-09 17:09:39 +11:00
Nicholas Nethercote 25efc9ba1b Bug 1337189 (part 25) - Move streaming/saving code out of Sampler. r=mstange. 2017-02-09 17:04:51 +11:00
Nicholas Nethercote d42a102fc2 Bug 1337189 (part 24) - Move RegisterThread() out of Sampler and rename it. r=mstange.
The new name is MaybeSetProfile(), which better reflects what it does.
2017-02-09 15:40:12 +11:00
Nicholas Nethercote 47689e0c40 Bug 1337189 (part 22) - Move CanNotifyObservers() out of Sampler. r=mstange. 2017-02-09 15:01:27 +11:00
Nicholas Nethercote cda6ae3c7e Bug 1337189 (part 21) - Remove Sampler::SizeOfIncludingThis(). r=mstange. 2017-02-09 15:00:29 +11:00
Nicholas Nethercote 54c050875a Bug 1337189 (part 20) - Move Start() and Stop() out of Sampler. r=mstange.
The patch also renames them as PlatformStart() and PlatformStop() to make it
clearer they are platform-specific.
2017-02-09 09:02:41 +11:00
Nicholas Nethercote d9988b98bd Bug 1337189 (part 19) - Move Tick() and GetThreadHandle() out of sampler. r=mstange.
The patch also removes InplaceTick(), which wasn't serving any useful purpose.
2017-02-09 09:02:41 +11:00
Nicholas Nethercote 7b76408a41 Bug 1337189 (part 18) - Remove Sampler::GetBacktrace(). r=mstange.
The patch also removes NewSyncProfile() by inlining it at its single call site.
2017-02-09 09:02:41 +11:00
Nicholas Nethercote 588435e15f Bug 1337189 (part 16) - Move all the bools out of Sampler. r=mstange.
Two of them (mAddMainThreadIO and mPrivacyMode) are now local variables within
profiler_start(), which is nice.

This change also lets us get rid of four sIs* variables.
2017-02-08 12:01:41 +11:00
Nicholas Nethercote 93a2d8e356 Bug 1337189 (part 15) - Move mBuffer out of Sampler. r=mstange. 2017-02-08 11:36:05 +11:00
Nicholas Nethercote d4b207196e Bug 1337189 (part 14) - Move active_ and paused_ out of Sampler. r=mstange. 2017-02-08 11:12:26 +11:00
Nicholas Nethercote 0354b56f1f Bug 1337189 (part 13) - Move interval_ out of Sampler. r=mstange. 2017-02-08 09:06:16 +11:00
Nicholas Nethercote 7d55463ad1 Bug 1337189 (part 12) - Move s{,Last}FrameNumber from Sampler.cpp to platform.cpp. r=mstange. 2017-02-07 15:56:48 +11:00
Nicholas Nethercote 51fe35f0d9 Bug 1337189 (part 10) - Move entrySize_ out of Sampler. r=mstange. 2017-02-07 15:22:52 +11:00
Nicholas Nethercote c8fdf1c412 Bug 1337189 (part 9) - Move mThreadNameFilters and mFeatures out of Sampler. r=mstange.
Doing so made it clearer that gThreadNameFilters was being accessed from
multiple threads without synchronization, so I added a Mutex for it.
2017-02-07 15:22:27 +11:00
Nicholas Nethercote 165c3f017d Bug 1337189 (part 8) - Move mGatherer out of Sampler. r=mstange. 2017-02-07 14:24:39 +11:00