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

534 Коммитов

Автор SHA1 Сообщение Дата
Toshihito Kikuchi 07dfbc6b36 Bug 1723868 - Skip msvp9dec_store.dll in GetInfoForSelf(). r=gerald
When mfplat.dll loads msvp9dec_store.dll, it posts a task
to unload the module to the work queue even if msvp9dec_store.dll
is already loaded and mfplat.dll skips LoadLibrary.  Therefore,
we cannot safely lock msvp9dec_store.dll by loading it as data.

The proposed fix is to skip processing the module.

Differential Revision: https://phabricator.services.mozilla.com/D121777
2021-08-05 02:36:27 +00:00
Nazım Can Altınova 4302cd6058 Bug 1652560 - Autogenerate profiling_categories.rs with profiling_categories.yaml r=gerald,emilio
Generate the user friendly Rust enums and their impls for profiling categories.

Differential Revision: https://phabricator.services.mozilla.com/D120792
2021-07-30 21:49:21 +00:00
Nazım Can Altınova 0b9f9eb6a9 Bug 1652560 - Autogenerate ProfilingCategoryList.h with profiling_categories.yaml r=emilio,gerald
Previously ProfilingCategoryList.h was a central place for profiling
categories. But with this patch, profiling_categories.yaml becomes the
canonical place for it and the macro header file is being generated
automatically. This is needed to make the profiling categories in sync with
Rust and C++.

Differential Revision: https://phabricator.services.mozilla.com/D120791
2021-07-30 21:49:21 +00:00
Gerald Squelart e7e9ae90ae Bug 1721110 - profiler_current_thread_id() now returns ProfilerThreadId - r=florian
Differential Revision: https://phabricator.services.mozilla.com/D120225
2021-07-21 04:16:59 +00:00
Gerald Squelart 7bc3116790 Bug 1721110 - baseprofiler::profiler_current_thread_id() now returns BaseProfilerThreadId - r=florian
Differential Revision: https://phabricator.services.mozilla.com/D120224
2021-07-21 04:16:59 +00:00
Gerald Squelart 723be2ec1e Bug 1721110 - baseprofiler::profiler_current_process_id() now returns BaseProfilerProcessId - r=florian
Differential Revision: https://phabricator.services.mozilla.com/D120222
2021-07-21 04:16:58 +00:00
Gerald Squelart 72f0855bfa Bug 1721110 - Introduce BaseProfilerProcessId and BaseProfilerThreadId - r=florian
These classes should replace the `int` type that is currently used to store process and thread ids. The next patches will start using them. Advantages:
- Prevent type mismatches, e.g., giving a process id (or other number) to a function expecting a thread id.
- Prevent nonsensical arithmetic operations.
- Make the unspecified id more abstract, so it's more obvious and portable.
- Make conversions to/from numbers (for display or storage) more visible.
- Allow future changes of APIs using them less risky.
- Allow future changes of the ids themselves (e.g., to be able to use bigger underlying types on some platforms, or even the opaque std:🧵:id type.)

Differential Revision: https://phabricator.services.mozilla.com/D120221
2021-07-21 04:16:57 +00:00
Gerald Squelart a966352bcd Bug 1721110 - {,Base}ProfilerUtils.h with process&thread functions taken from {,Base}ProfilerState.h - r=florian
This new header isolates the process and thread functions that should be available in all builds, and in most other profiler headers.
Non-MOZ_GECKO_PROFILER implementations return ids 0 (unspecified process/thread). `profiler_is_main_thread()` returns false, it's arbitrary but consistent with `0` (it makes little sense to use it there anyway.)

Differential Revision: https://phabricator.services.mozilla.com/D120220
2021-07-21 04:16:57 +00:00
Gerald Squelart 171c2eed5f Bug 1721110 - {,Base}ProfilerState.h improvements: Sprinkle nodiscard's and more - r=florian
The next patch will extract parts of these headers into a separate file, so it's best to do this clean-up now, to best preserve history.
- Add [[nodiscard]] to all functions that return something. (There are no cases where that returned value could really be ignored.)
- Hide scProfilerMainThreadId in a "detail" namespace, to emphasize that it's an implementation detail that the user shouldn't access directly.
- Combine tightly-nested namespaces start/end into single lines, it's more readable.

Differential Revision: https://phabricator.services.mozilla.com/D120219
2021-07-21 04:16:56 +00:00
Gerald Squelart 02a156fe92 Bug 1720846 - Fix non-unified build by adding missing #includes - r=florian
Differential Revision: https://phabricator.services.mozilla.com/D120301
2021-07-20 09:31:17 +00:00
Florian Quèze 292c1a1f60 Bug 1720368 - Remove MOZ_GECKO_PROFILER ifdefs around profiler_init and profiler_shutdown calls, r=gerald.
Differential Revision: https://phabricator.services.mozilla.com/D119809
2021-07-15 22:04:23 +00:00
Tom Ritter 1b9b6b72db Bug 1666222: Cut over a ton of NowUnfuzzed calls -> Now 4/5 r=smaug,extension-reviewers,zombie
With Fuzzyfox removed, Now() does what NowUnfuzzed() did.

Differential Revision: https://phabricator.services.mozilla.com/D119639
2021-07-14 18:18:17 +00:00
Gerald Squelart 9b0d666eda Bug 1719240 - Rework PSMutex into PSAutoLock - r=canaltinova
This prevents unwanted direct access to the mutex, and removes duplicated code.

And make the Base Profiler mutex&lock consistent.

Differential Revision: https://phabricator.services.mozilla.com/D119147
2021-07-13 12:20:49 +00:00
Florian Quèze c87b4eb7b7 Bug 1717991 - Profiler headers should declare all the marker related functions even when MOZ_GECKO_PROFILER is not defined, r=gerald.
Differential Revision: https://phabricator.services.mozilla.com/D118679
2021-06-25 13:28:01 +00:00
Gerald Squelart c83e6a0508 Bug 1715922 - Windows timer resolution is enhanced by default, except if notimerresolutionchange feature is set - r=canaltinova
This reverses bug 1703410: By default the profiler now changes the timer resolution (normally 64Hz) when the requested sampling interval is lower than 10ms, to allow fast-enough sampling for most uses.

But since this can influence other timers in Firefox, it makes debugging some types of issues more difficult. To help with this, there is now a "No Timer Resolution change" on Windows, which prevents the profiler from changing the timer resolution, at a risk of slowing down sampling in some processes.

Differential Revision: https://phabricator.services.mozilla.com/D117626
2021-06-21 11:48:23 +00:00
Florian Quèze dfeb53e219 Bug 1715257 - Remove Task Tracer code from the profiler, r=gerald,necko-reviewers.
Differential Revision: https://phabricator.services.mozilla.com/D117996
2021-06-17 09:33:00 +00:00
Iulian Moraru b02492de66 Backed out changeset 617a466d0cce (bug 1715257) for causing build bustages. CLOSED TREE 2021-06-17 10:58:16 +03:00
Florian Quèze 7b4906a6bd Bug 1715257 - Remove Task Tracer code from the profiler, r=gerald,necko-reviewers.
Differential Revision: https://phabricator.services.mozilla.com/D117996
2021-06-17 06:12:10 +00:00
Gerald Squelart 098790a8eb Bug 1703410 - Only change Windows timer resolution if PROFILER_ADJUST_TIMER_RESOLUTION is set - r=florian
On Windows, the profiler changes the timer resolution when the sampling interval is less than 10ms.
However this change affects all of Firefox, which can change other behaviors, sometimes causing confusion when refresh-rate issues magically disappear when the profiler is running.

So now by default the profiler will not change the timer resolution. This should rarely affect the profiler's effective sampling rate, unless all threads in a process are in a waiting state, in which case there is nothing new to sample anyway! The front-end is investigating ways to make sampling gaps more obvious, see https://github.com/firefox-devtools/profiler/issues/2962

If some power users really need the added sampling precision in some profiling sessions, the timer resolution change may be requested before running Firefox, by setting the environment variable "PROFILER_ADJUST_TIMER_RESOLUTION" to any value.

Differential Revision: https://phabricator.services.mozilla.com/D115451
2021-05-19 22:29:17 +00:00
Toshihito Kikuchi d8fe2ac176 Bug 1702086 - Part4: Use PEHeaders::GetBounds instead of GetModuleInformation. r=gerald
`SharedLibraryInfo::GetInfoForSelf()` can use `PEHeaders::GetBounds` instead of
`GetModuleInformation` to get the start/end address of a module's mapped region
in the local process.  It's roughly 100x faster because `GetModuleInformation`
invokes two system calls `NtQueryInformationProcess` and `NtReadVirtualMemory`
while `nt::PEHeaders` does not.

Depends on D115254

Differential Revision: https://phabricator.services.mozilla.com/D115255
2021-05-19 18:01:49 +00:00
Toshihito Kikuchi 2755a48956 Bug 1702086 - Part3: Use PEHeaders::GetVersionInfo. r=gerald
This patch replaces two versions of `GetVersion` in Gecko profiler and
baseprofiler with `PEHeaders::GetVersionInfo`.

Depends on D115253

Differential Revision: https://phabricator.services.mozilla.com/D115254
2021-05-19 18:01:48 +00:00
Toshihito Kikuchi 4e1b4037be Bug 1702086 - Part2: Get PDB information from the new handle. r=gerald
This patch is the actual fix for Bug 1702086.  The problem of Bug 1702086 is that
`LoadLibraryExW` loaded the module onto an address different from the original
mapped addresss because it was unloaded after we started enumeration.  Calling
`GetPdbInfo` with the original address `module.lpBaseOfDll` caused a crash.

The proposed fix consists of three parts.

The first part is to get PDB information from `handleLock`, which is always valid
even if the original address was unloaded.  With this, we don't need a check
of `VirtualQuery`.

The second part is to add `LOAD_LIBRARY_AS_IMAGE_RESOURCE` along with
`LOAD_LIBRARY_AS_DATAFILE` to the call to `LoadLibraryEx`.  This is needed
to read information from the sections outside the PE headers because
RVA (= relative virtual address) is an address after relocation.
Without `LOAD_LIBRARY_AS_IMAGE_RESOURCE`, a module is mapped without relocation,
so `GetPdbInfo()` accesses wrong memory resulting in a crash.

The third part is to introduce `PEHeaders::GetPdbInfo`, replacing two versions
of `GetPdbInfo` in Gecko profiler and baseprofiler.

Depends on D115252

Differential Revision: https://phabricator.services.mozilla.com/D115253
2021-05-19 18:01:48 +00:00
Toshihito Kikuchi d64610fed5 Bug 1702086 - Part1: Introduce EnumerateProcessModules. r=gerald
This patch introduces `EnumerateProcessModules` to enumerate all loaded modules
in the local process so that Gecko profiler and baseprofiler can use it.

Differential Revision: https://phabricator.services.mozilla.com/D115252
2021-05-19 18:01:47 +00:00
Gerald Squelart 8b96edfb80 Bug 1710757 - Fix baseprofiler native-frame output - r=florian
SprintfLiteral doesn't support "%#llx" anymore.
So this patch switches to an explicit "0x%llx" to output addresses as the symbolicator expects.

Differential Revision: https://phabricator.services.mozilla.com/D114914
2021-05-12 10:22:55 +00:00
Andi-Bogdan Postelnicu eab549fd19 Bug 1519636 - Initial reformat of C/C++ code with clang-format version 12.0.0. r=sylvestre
clang-format version 12.0.0 (taskcluster-KEgO7qdgQ8uaewA6NkRnRA)

Differential Revision: https://phabricator.services.mozilla.com/D114211
2021-05-10 07:15:07 +00:00
Florian Quèze 7a8983cc88 Bug 1705318 - substract the memory used by the profiler buffer when sampling the memory counter, r=gerald.
Differential Revision: https://phabricator.services.mozilla.com/D114397
2021-05-07 09:32:11 +00:00
Gerald Squelart e2d8ae5a08 Bug 1708350 - profiler_suspend_and_sample_thread can now sample the current thread - r=canaltinova
Differential Revision: https://phabricator.services.mozilla.com/D114115
2021-05-06 23:23:40 +00:00
Florian Quèze 3e63d9143b Bug 1635442 - Only initialize LUL when the StackWalk feature is requested on Linux, r=gerald.
Differential Revision: https://phabricator.services.mozilla.com/D113693
2021-04-29 15:27:26 +00:00
Alexandru Michis 335b6f5f96 Backed out changeset 6bd7baadb78c (bug 1702086) for causing Bug 1607574.
CLOSED TREE
2021-04-28 23:23:01 +03:00
Toshihito Kikuchi 0d9e48e427 Bug 1702086 - Make sure LoadLibraryEx really locks the mapped address. r=mstange
Before `SharedLibraryInfo::GetInfoForSelf` calls `GetPdbInfo` to parse a module's
PE header, it calls `LoadLibraryEx` to prevent the module from being unloaded
during `GetPdbInfo`.  If the module was already unloaded before `LoadLibraryEx`,
however, `LoadLibraryEx` maps the module onto an address different from the original
mapped address, so that `module.lpBaseOfDll` becomes invalid.

This patch is to call `LoadLibraryEx` before `GetModuleInformation` to make sure
`LoadLibraryEx` increments the module's refcount and does not map the module onto
a new address.  With this, `module.lpBaseOfDll` is always valid, thus we don't have
to call `VirtualQuery`.

Differential Revision: https://phabricator.services.mozilla.com/D110421
2021-04-01 00:35:01 +00:00
Nazım Can Altınova 7039884fe6 Bug 1698129 - Rename the profiler browsingContextID outputs to tabID and bump the profile version r=gerald
Lastly, we are changing the parts that requires a version bump and bumping the
profiler version in the end. This will require a PR in the front-end for a
version upgrader and changes related to the renaming.

Differential Revision: https://phabricator.services.mozilla.com/D109282
2021-03-25 12:52:11 +00:00
Nazım Can Altınova f8b414e1c2 Bug 1698129 - Rename browsingContextID to tabID inside the profiler codebase r=julienw,gerald,devtools-backward-compat-reviewers
This patch is only  about renaming the internals of the profiler codebase and
it doesn't touch any parts that requires a backwards compatibility or version
bump.

Differential Revision: https://phabricator.services.mozilla.com/D109280
2021-03-25 12:52:10 +00:00
Jeff Muizelaar 9290181962 Bug 1700113 - Use the builtin gettid() on Android. r=glandium
Syscalls can be pretty slow on Android and this lets us use the
gettid() cache that bionic has:
d7c52625f2/libc/bionic/gettid.cpp

Differential Revision: https://phabricator.services.mozilla.com/D109353
2021-03-23 00:41:12 +00:00
Mike Hommey 86270cdf01 Bug 1699375 - Move MozStackWalkThread to a separate header. r=gerald
It requires including <windows.h>, preventing the inclusion of StackWalk.h
from some places (and upcoming changes will make StackWalk.h included in
more places).

Differential Revision: https://phabricator.services.mozilla.com/D108910
2021-03-22 21:25:29 +00:00
Mike Hommey ec7f538e0c Bug 1698719 - Remove aSkipFrames argument to both FramePointerStackWalk and MozStackWalkThread. r=gsvelto,gerald
In the case of FramePointerStackwalk, the caller gives a pointer to the
top-most frame to walk from. There isn't really a reason to give a
number of frames to skip, as the right frame pointer could be given in
the first place if that was really necessary. And in practice, it's
hasn't been used so far.

In the case of MozStackWalkThread, the caller presumably doesn't know
what the thread the stack is being walked for is doing, and it would be
a guesswork to pass a valid number of frames to skip. In practice, it's
also not used.

The aSkipFrames is already a footgun on MozStackWalk (and we're going to
change that in bug 1515229), we don't need to keep a footgun on these
other stack walking methods.

Differential Revision: https://phabricator.services.mozilla.com/D108563
2021-03-17 00:21:39 +00:00
Gerald Squelart f193604f7c Bug 1687631 - Enable CPU Utilization by default in the profilers - r=florian
Differential Revision: https://phabricator.services.mozilla.com/D107598
2021-03-15 11:54:43 +00:00
Gerald Squelart 96f3fabfcb Bug 1693037 - Fix non-MOZ_GECKO_PROFILER builds - r=florian
No code changes.

Build issues were found by renaming `MOZ_GECKO_PROFILER` to something else in toolkit/moz.configure, in both unified and non-unified builds, on all supported platforms.

Also updated some profiler-related comments.

Differential Revision: https://phabricator.services.mozilla.com/D105375
2021-02-17 22:36:28 +00:00
Florian Quèze 2df72b6edb Bug 1691092 - When capturing a marker stack, stop when the PROFILER category is encountered, r=gerald.
Differential Revision: https://phabricator.services.mozilla.com/D104248
2021-02-16 19:04:03 +00:00
Florian Quèze 7f356c706e Bug 1691092 - add PROFILER category to make profiler overhead very visible, r=gerald.
Differential Revision: https://phabricator.services.mozilla.com/D104242
2021-02-16 19:04:02 +00:00
Gerald Squelart 811250c823 Bug 1691589 - Extract profiler label APIs into separate headers - r=florian
New headers BaseProfilerLabels.h and ProfilerLabels.h now contain all label-related APIs.

These files were hg-copied from the main headers, to preserve history, and then non-label content was removed from the main headers.
The "RAII" macros were moved to these *ProfilerLabels.h headers, because that's the most-common header in which they're needed. Meta-bug 1681416 will probably move these again as needed.

Differential Revision: https://phabricator.services.mozilla.com/D104587
2021-02-16 04:44:19 +00:00
Gerald Squelart 9cc158ebf3 Bug 1691589 - Don't include main profiler headers from markers headers - r=florian
{Base,}ProfilerMarkers.h can now rely on {Base,}ProfilerState.h (and just one function forward declaration), so they don't need to include {Base,Gecko}Profiler.h anymore.
Thanks to that, {Base,Gecko}Profiler.h can now include {Base,}ProfilerMarkers.h at the top.

Also, BaseProfilingStack.h should not include BaseProfiler.h (include loop, can cause failures) not algorithm (not used).

***
roll up into 2nd patch

Differential Revision: https://phabricator.services.mozilla.com/D104969
2021-02-16 04:44:18 +00:00
Gerald Squelart 1e76096bd5 Bug 1691589 - Extract profiler state APIs into separate headers - r=florian
New headers BaseProfilerState.h and ProfilerState.h now contain most state-reading APIs.

These files were hg-copied from the main headers, to preserve history, and then chosen declarations were kept only in the relevant header.
This is needed in a following patch, where new headers *ProfilerLabels.h use `profiler_is_active()`.

Differential Revision: https://phabricator.services.mozilla.com/D104968
2021-02-16 04:44:17 +00:00
Markus Stange 8bee4d97d7 Bug 1691121 - Use a more modern way to obtain the thread ID on macOS. r=gerald
Differential Revision: https://phabricator.services.mozilla.com/D104261
2021-02-09 22:39:19 +00:00
Gerald Squelart f3afaa1ce8 Bug 1691504 - ProfileBufferCollector now provides the main profiler buffer's range start - r=canaltinova
ProfileBufferCollector::SamplePositionInBuffer() and BufferRangeStart() need to provide indices in the same main buffer, because they will be used to discard old data (at some previous `SamplePositionInBuffer`) once the `BufferRangeStart` indicates that it is not referenced by the profiler anymore.

Because the periodic sampler uses a local buffer (to avoid allocations and locks), we need to record the special location from the main profiler buffer in ProfileBufferCollector.

Differential Revision: https://phabricator.services.mozilla.com/D104497
2021-02-09 12:21:32 +00:00
Florian Quèze d520574f5c Bug 1690375 - Record markers with partial stacks for flushing pending notifications and marking a style flush as needed, r=gerald.
Differential Revision: https://phabricator.services.mozilla.com/D103844
2021-02-04 15:13:21 +00:00
Florian Quèze a350b3e6d3 Bug 1687709 - enable the CPU utilization feature by default for startup profiling, r=gerald.
Differential Revision: https://phabricator.services.mozilla.com/D102451
2021-01-21 11:05:25 +00:00
Greg Tatum 15991a04d2 Bug 1680517 - Tweak the TextMarker display schema; r=gerald
Differential Revision: https://phabricator.services.mozilla.com/D98610
2020-12-03 21:44:28 +00:00
Gerald Squelart 46d0db1b2c Bug 1677130 - Allow out-of-order ReleaseChunk - r=canaltinova
Differential Revision: https://phabricator.services.mozilla.com/D100860
2021-01-12 23:30:27 +00:00
Gerald Squelart 4ad68eb4c1 Bug 1651863 - ProfileBufferChunkManager::ReleaseChunk (no 's' anymore) only accepts zero or one chunk - r=canaltinova
Differential Revision: https://phabricator.services.mozilla.com/D100859
2021-01-08 12:11:18 +00:00
Gerald Squelart ecaf794c38 Bug 1329600 - Scaffolding to output CPU measurements in samples - r=canaltinova
The `RunningTimes` class stores CPU measurements. It may seem overkill for only one value, but in the future more measurements will be added.

During sampling, CPU measurements are collected by platform-specific code. This patch doesn't produce anything yet, see later patches.
These are stored with the samples.
Note that for duplicated samples (when a thread is known to be "asleep"), we still need to collect new measurements, because there could potentially be some activity happening, e.g. in system calls.
Finally the measurements are output as extra "samples" values.

Units for these values may platform-specific, so they are stored in the top-level JSON "meta" object.

We don't collect running times in the Base Profiler (yet), but we still need to add the appropriate field names in the samples' "schema", as expected by profiler.firefox.com.

Differential Revision: https://phabricator.services.mozilla.com/D99413
2021-01-04 07:19:16 +00:00