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

250 Коммитов

Автор SHA1 Сообщение Дата
Gerald Squelart f2401ecda3 Bug 1464506 - Record FileIO markers on all threads - r=canaltinova
In addition to the existing "mainthreadio" feature, we now have:
- "fileio" to also capture file I/O from other profiled threads.
- "fileioall" to also capture file I/O from all threads (even unregistered threads).
- "noiostacks" to prevent capturing stack traces for "io" markers.
These are all off by default, except for `MOZ_PROFILER_STARTUP=1`.

Differential Revision: https://phabricator.services.mozilla.com/D75764
2020-05-25 08:58:47 +00:00
Gerald Squelart 271f2b32ae Bug 1464506 - Statically check profiler feature numbers - r=canaltinova
This is a simple compile-time check that the feature numbers go from 0 to N-1, to prevent some mistakes when updating feature lists.

Differential Revision: https://phabricator.services.mozilla.com/D75763
2020-05-25 08:57:44 +00:00
Gerald Squelart 3147b9d1d6 Bug 1464506 - profiler_add_marker_for_mainthread records markers from any thread into the main thread track - r=canaltinova
Some markers may be more useful when gathered into a single track, and the main thread is ideal because it's almost always present.

Differential Revision: https://phabricator.services.mozilla.com/D75760
2020-05-25 08:57:31 +00:00
Gerald Squelart 2502f01aa8 Bug 1464506 - CorePS records the main thread id - r=canaltinova
Differential Revision: https://phabricator.services.mozilla.com/D75759
2020-05-25 08:57:29 +00:00
Gerald Squelart 7f21bc7ade Bug 1464506 - Improved StaticBaseProfilerStats, added max duration - r=canaltinova
Made StaticBaseProfilerStats a proper class, with more explicit types for measurements and printfs.
Also added the maximum duration in a set, which can be useful to see what the worst case of some code may be.

(Reminder: This code is not built by default, uncomment `#  define PROFILER_RUNTIME_STATS` above to enable it.)

Differential Revision: https://phabricator.services.mozilla.com/D75758
2020-05-25 08:55:55 +00:00
Gerald Squelart a88e6ae204 Bug 1594268 - profiler_add_marker_for_thread takes payload by const& - r=canaltinova
Instead of accepting a `UniquePtr<ProfilerMarkerPayload>`, `profiler_add_marker_for_thread` now takes it by `const ProfilerMarkerPayload&`.
All callers can now create the payload on the stack, or as a temporary object. This saves a memory alloc+free for each call.

Differential Revision: https://phabricator.services.mozilla.com/D75912
2020-05-19 23:07:54 +00:00
alwu fd606724bc Bug 1612557 - part4 : use `Media` category for markers r=bryce,gerald,canaltinova
This patch will do :
- add `Media` markers in related codes
- implement `MediaSampleMarkerPayload` to record the media sample

The advantage of doing so :
- using markers can help us know what happens on the media by a glance without expanding the call stack
- adding sample markers allows us compare the speed of decoding sample in `MediaDecoderStataMachine` and rendering sample in `VideoSink`

Differential Revision: https://phabricator.services.mozilla.com/D74174
2020-05-16 19:58:25 +00:00
alwu 0bccc7a4cf Bug 1612557 - part2 : create a sub-category 'Cubeb'. r=padenot
This patch will do :
- create a sub-category `Cubeb`
- add  `Cubeb` profiling labels in related codes

The advantage of doing so :
- allow us to know the percentage of time respectively we spend on cubeb and non-cubeb codes

More details :
The profiling code would include `<atomic>` which is C++ only, so I can't use the label in `cubeb.c` directly. Instead, I add labels on the `AudioStream` and `AudioCallbackDriver` where we would call cubeb related methods.

Differential Revision: https://phabricator.services.mozilla.com/D74172
2020-05-11 14:08:10 +00:00
alwu 8dda6be6ef Bug 1612557 - part1 : create a profiling category `Media`. r=bryce,gerald
This patch will do :
- create a profiling category `Media`
- add  `Media` profiling labels in related codes

The advantage of doing so :
- allow us to easily see what operations are related to media playback from the profiled report

More details :
According to the description in the `ProfilingCategory.h`, `topmost profiler label frame in the label stack determines the category pair of that stack`. Therefore, most labels I added are the first task would run on the thread, in order to ensure all its following tasks can be marked as the media playback label as well.

Differential Revision: https://phabricator.services.mozilla.com/D74171
2020-05-12 17:35:19 +00:00
Gerald Squelart e1d51db19a Bug 1635570 - Cut too-long label dynamic strings and add ellipsis - r=canaltinova
If a label contains a dynamic string that's too long (512 characters or more), instead of just replacing it with "(too long)", we now cut it down to the maximum size, with an ellipsis at the end.

Added test for that in gtest. Also added nearby test for empty strings.

Differential Revision: https://phabricator.services.mozilla.com/D74378
2020-05-12 01:13:17 +00:00
Chris Fronk af8a02cc9d Bug 1512991 - Add JsonWriteFunc::Write to take string length. r=botond
Differential Revision: https://phabricator.services.mozilla.com/D72560
2020-05-08 16:24:31 +00:00
Gerald Squelart 668492b4ef Bug 1632750 - Recycle chunks that are destroyed through DestroyChunksAtOrBefore or the local limit - r=canaltinova
Whenever chunks are about to be destroyed, we try to keep one or two alive, to hopefully fulfill the next request, thereby avoiding a deallocation+allocation pair.

Differential Revision: https://phabricator.services.mozilla.com/D72370
2020-05-08 03:35:57 +00:00
Gerald Squelart 3292ac76d9 Bug 1632750 - Make ProfileBufferChunkManagerWithLocalLimit a ProfileBufferControlledChunkManager - r=canaltinova
Differential Revision: https://phabricator.services.mozilla.com/D72363
2020-05-08 03:34:28 +00:00
Gerald Squelart 2cf1bef331 Bug 1632750 - ProfileBufferChunkManagerWithLocalLimit doesn't need to track chunk metadata sizes - r=canaltinova
The chunk metadata size is tiny (less than 100 bytes) compared to the buffer size (1MB by default), so it's fine to ignore it while dealing with cross-Firefox limits.

Differential Revision: https://phabricator.services.mozilla.com/D72558
2020-05-08 03:33:29 +00:00
Gerald Squelart a09a699a12 Bug 1632750 - ProfileBufferControlledChunkManager - r=canaltinova
Interface class for a chunk manager that can be controlled: It will provide updates about chunks, and release chunks on command.

Differential Revision: https://phabricator.services.mozilla.com/D72362
2020-05-08 03:44:34 +00:00
Markus Stange fcfda28406 Bug 1635803 - Make sure <cstdlib> is included before mozalloc.h, to work around bug 1635968. r=gerald
Differential Revision: https://phabricator.services.mozilla.com/D74154
2020-05-06 22:57:05 +00:00
Gerald Squelart 9eb780f5ef Bug 1635338 - profiler_is_locked_on_current_thread() now also checks for the buffer lock - r=gregtatum,canaltinova
profiler_is_locked_on_current_thread() is used to help users avoid calling `profiler_...` functions when the profiler may already have a lock in place, which would prevent a 2nd recursive lock (resulting in a crash or a never-ending wait).
So we must return `true` for any of:
- The main profiler mutex, used by most functions, and/or
- The buffer mutex, used directly in some functions without locking the main mutex, e.g., marker-related functions.

Differential Revision: https://phabricator.services.mozilla.com/D73789
2020-05-06 12:45:40 +00:00
Gerald Squelart a58e3ee5a8 Bug 1635338 - ProfileChunkedBuffer::IsThreadSafeAndLockedOnCurrentThread - r=gregtatum,canaltinova
Expose `ProfileChunkedBuffer`'s mutex (if present), so that potential callers can avoid recursive calls that would lock or crash.

Differential Revision: https://phabricator.services.mozilla.com/D73788
2020-05-06 12:44:44 +00:00
Gerald Squelart f504b757de Bug 1635338 - baseprofiler::profiler_is_locked_on_current_thread - r=gregtatum,canaltinova
Mimic Gecko Profiler's `profiler_is_locked_on_current_thread()` in Base Profiler.

Differential Revision: https://phabricator.services.mozilla.com/D73787
2020-05-06 12:44:22 +00:00
Gerald Squelart 368c811625 Bug 1635338 - BaseProfilerMutex::IsLockedOnCurrentThread - r=gregtatum,canaltinova
Make `BaseProfilerMutex::mOwningThreadId` non-optional, and use it in `IsLockedOnCurrentThread()`, which is similar to the one in Gecko Profiler.
Add related `BaseProfilerMaybeMutex::IsActivatedAndLockedOnCurrentThread()`.

Differential Revision: https://phabricator.services.mozilla.com/D73786
2020-05-06 12:42:37 +00:00
Greg V e65e9412b0 Bug 1634205 - Support Gecko Profiler and Base Profiler on FreeBSD r=mstange
- supports amd64 and arm64 (aarch64)
- uses LUL for stack walking

Differential Revision: https://phabricator.services.mozilla.com/D73162
2020-05-06 17:44:19 +00:00
Markus Stange 16fc9519a1 Bug 1578726 - Stop looking for non-existent EnterJIT frames. r=gerald
At the time this code was written, JavaScript JIT entry trampolines were
emitting EnterJIT label frames that carried a stack address. From this stack
address, register values could be recovered that would allow native stack
unwinding to resume after getting lost in JIT code.

The EnterJIT label frame was removed in bug 1057082.

Differential Revision: https://phabricator.services.mozilla.com/D73939
2020-05-05 22:53:45 +00:00
Markus Stange 7c4a6b32f3 Bug 1634784 - Remove #ifdef MOZ_GECKO_PROFILER wrappers in mozglue/baseprofiler cpp files, and reorder includes. r=gerald
I apologize for mixing multiple types of changes in this patch. The mix is probably harder to review than necessary.

Because of the way these .cpp files are listed in mozglue/baseprofiler/moz.build,
they are only built when MOZ_GECKO_PROFILER is set. So the #ifdef MOZ_GECKO_PROFILER
wrapper is now unnecessary.
Removing this wrapper has many knock-on effects on other lines in these files
due to preprocessor line indentation.

As I was removing the #ifdefs, I was reordering includes as well, to follow the
include order laid out on https://google.github.io/styleguide/cppguide.html#Names_and_Order_of_Includes ;
namely, system headers should go before "your project's" .h files.

I also removed the BaseProfiler.h include from some files but not from all.
In the past, the BaseProfiler.h include served the purpose of picking up the
MOZ_BASE_PROFILER #define, and it's no longer needed for that reason.
There are probably lots of now-unnecessary BaseProfiler.h includes left.

Differential Revision: https://phabricator.services.mozilla.com/D73527
2020-05-05 22:00:49 +00:00
Markus Stange 6725e6df9a Bug 1634784 - Remove MOZ_BASE_PROFILER and replace it with MOZ_GECKO_PROFILER everywhere. r=gerald
Differential Revision: https://phabricator.services.mozilla.com/D73526
2020-05-05 21:44:11 +00:00
Gerald Squelart bccea8601e Bug 1571171 - Clamp profiler capacity to allowed values - r=canaltinova
The profiler can be given any power of two, but there were no safety checks to ensure that the buffer had a minimum workable capacity (to hold at least 4 chunks, each capable of holding at least one stack sample), and also to prevent large buffers that could break the currently-supported 2GiB limit.

This fixes the issue with test_merged_stacks.js, which was requesting a too-small buffer. (This started when we switched to the chunk-based buffer, because the profiler was blindly using the provided number as maximum, and dividing that size by 4 for each chunk, which was not enough to hold a full sample in some builds.)

Differential Revision: https://phabricator.services.mozilla.com/D73212
2020-05-04 12:49:30 +00:00
Markus Stange 19bb155e7d Bug 1634782 - Enable MOZ_BASE_PROFILER on MingW. r=gerald
Now the base profiler is enabled on all platforms that also have MOZ_GECKO_PROFILER.

Differential Revision: https://phabricator.services.mozilla.com/D73513
2020-05-01 23:11:27 +00:00
Emilio Cobos Álvarez 5420284414 Bug 1632972 - Fix logic to detect the main executable. r=mstange
This is how my mapfile looks like:

  5587df936000-5587df96b000 r--p 00000000 fd:02 21584889                   /home/emilio/src/moz/gecko/obj-debug/dist/bin/firefox
  5587df96b000-5587df9ec000 r-xp 00035000 fd:02 21584889                   /home/emilio/src/moz/gecko/obj-debug/dist/bin/firefox
  5587df9ec000-5587df9ed000 r--p 000b6000 fd:02 21584889                   /home/emilio/src/moz/gecko/obj-debug/dist/bin/firefox
  5587df9ed000-5587df9ee000 rw-p 000b7000 fd:02 21584889                   /home/emilio/src/moz/gecko/obj-debug/dist/bin/firefox

Note how the executable bit, which is the only one we look at, and which
is where we get exeExeAddr from (0x5587df96b000 in this case) is in the
middle of the executable, but the library will span all four ranges.

Check for whether the library _contains_ the start address of the
executable region instead of whether it starts with it.

Differential Revision: https://phabricator.services.mozilla.com/D72504
2020-04-25 10:11:28 +00:00
Gerald Squelart d6c1b933f1 Bug 1630872 - Quick-moving InChunkPointer with `ProfileBufferBlockIndex` - r=canaltinova
As opposed to `ProfileBufferIndex` (no "Block"), `ProfileBufferBlockIndex` is only supposed to point at a valid block start.
If we trust this assumption, it allows for quick access to the given block index inside the buffer, as we don't need to read blocks one by one until we reach the given position.

There are still safety checks (MOZ_ASSERTs in DEBUG builds) to verify that block indices are correctly used.

Differential Revision: https://phabricator.services.mozilla.com/D71502
2020-04-24 06:21:46 +00:00
Gerald Squelart a11580da0f Bug 1630872 - Replace uses of BlocksRingBuffer with ProfileChunkedBuffer in Base Profiler - r=canaltinova
Differential Revision: https://phabricator.services.mozilla.com/D71883
2020-04-24 06:24:44 +00:00
Gerald Squelart c00a525a32 Bug 1630872 - Removed 'BlocksRingBuffer' from some Base Profiler platform variables - r=canaltinova
Renamed some variables to be more generic. Their type is going to change in the next patch, and that type doesn't need to be in the names; also it will make the next patch easier to review.

Differential Revision: https://phabricator.services.mozilla.com/D71882
2020-04-24 06:21:10 +00:00
Gerald Squelart 3a06f23a20 Bug 1630872 - Replace InChunkBuffer::operator bool() and operator!() with IsNull() - r=canaltinova
`explicit operator bool()` and `operator!()` were cute ways to make `InChunkBuffer` quack like a pointer when testing if it's effectively null.
But after some experience, and since `InChunkPointer` will not be used in generic code where pointers would be accepted, I now think that it's better to be clearer about it and use an explicit `IsNull()`.

Differential Revision: https://phabricator.services.mozilla.com/D71499
2020-04-24 06:19:39 +00:00
Gerald Squelart 6814c95c04 Bug 1630872 - ProfileChunkedBuffer Put* functions provide a Maybe<ProfileBufferEntryWriter> - r=canaltinova
Same as with `BlocksRingBuffer`: Instead of a potentially-null pointer to a
`ProfileBufferEntryWriter`, we are now providing a
`Maybe<ProfileBufferEntryWriter>`, which is safer.

Differential Revision: https://phabricator.services.mozilla.com/D71287
2020-04-24 06:19:27 +00:00
Gerald Squelart 525010089c Bug 1630872 - BlockRingBuffer Put* functions provide a Maybe<ProfileBufferEntryWriter> - r=canaltinova
Instead of a potentially-null pointer to a `ProfileBufferEntryWriter`, we are now providing a `Maybe<ProfileBufferEntryWriter>`, which is safer.

Differential Revision: https://phabricator.services.mozilla.com/D71286
2020-04-24 06:19:09 +00:00
Nazım Can Altınova e8ef58fd4d Bug 1623770 - Return early if failed to allocate a memory in CopyDataIntoLazilyAllocatedBuffer. r=gerald
Differential Revision: https://phabricator.services.mozilla.com/D72131
2020-04-23 11:42:45 +00:00
Markus Stange ddece4ba4f Bug 1630895 - Infer categories for Java frames. r=gerald
Differential Revision: https://phabricator.services.mozilla.com/D71383
2020-04-17 23:30:10 +00:00
Gerald Squelart 97cb0a90bd Bug 1626837 - ProfileChunkedBuffer (de)serialization - r=canaltinova
This is needed to embed a small buffer (e.g., containing one backtrace attached
to a marker) into a bigger buffer (e.g., the main profiler buffer).

Differential Revision: https://phabricator.services.mozilla.com/D69499

--HG--
extra : moz-landing-system : lando
2020-04-15 03:26:06 +00:00
Gerald Squelart 1feb663e29 Bug 1626837 - ProfileChunkedBuffer read functions - r=canaltinova
Differential Revision: https://phabricator.services.mozilla.com/D69498

--HG--
extra : moz-landing-system : lando
2020-04-15 03:25:48 +00:00
Gerald Squelart 8e1dfc3db0 Bug 1626837 - ProfileChunkedBuffer detail::InChunkPointer - r=canaltinova
`InChunkPointer` is an internal accessor pointing at a position inside a chunk.
It can handle up to two groups of chunks (typically the extant chunks stored in
the chunk manager, and the current chunk.

Differential Revision: https://phabricator.services.mozilla.com/D69497

--HG--
extra : moz-landing-system : lando
2020-04-15 03:25:40 +00:00
Gerald Squelart 23b9adb050 Bug 1626837 - ProfileChunkedBuffer write functions - r=canaltinova
Differential Revision: https://phabricator.services.mozilla.com/D69496

--HG--
extra : moz-landing-system : lando
2020-04-15 03:25:33 +00:00
Gerald Squelart b001bcf853 Bug 1626837 - ProfileChunkedBuffer chunk request mechanism - r=canaltinova
To ensure that a spare chunk is ready to handle data that will eventually
overflow the current chunk, `ProfileChunkedBuffer` uses
`ProfileBufferChunk::RequestChunk()` to queue a request for a new chunk.

This request should be handled off-thread by the buffer user -- but a response
is not guaranteed, so the buffer does not rely on it and can get a new chunk
on the spot if really needed.

Because the request is asynchronous, and because either the buffer or the user
could be destroyed while a request is in flight, a shared
`RequestedChunkRefCountedHolder` object is used:
- When the request is handled, the new chunk (or nullptr) is given to the
  holder.
- When the buffer needs a new chunk, it can retrieve the new chunk if the
  request was successfully fulfilled.
If the requestee is destroyed first, the request won't be fulfilled and the
buffer will carry on without relying on requests.
If the requester is destroyed first, the holder (with a potential requested
chunk) will just get destroyed after the request is fulfilled or the requestee
is destroyed as well.

Differential Revision: https://phabricator.services.mozilla.com/D69495

--HG--
extra : moz-landing-system : lando
2020-04-15 03:21:45 +00:00
Gerald Squelart 61054fffee Bug 1626837 - ProfileChunkedBuffer ChunkManager handling - r=canaltinova
`ProfileChunkedBuffer` can handle zero or one `ProfileBufferChunkManager` at a
time, and can optionally take ownership of the manager.

Differential Revision: https://phabricator.services.mozilla.com/D69494

--HG--
extra : moz-landing-system : lando
2020-04-15 03:21:27 +00:00
Gerald Squelart dcbdec35d9 Bug 1626837 - ProfileChunkedBuffer basic data and functions - r=canaltinova
ProfileChunkedBuffer simulates a near-infinite buffer over ProfileBufferChunks.
It uses a ProfileBufferChunkManager to get chunks and later release them.
Its use is similar to BlocksRingBuffer:
- It reserves blocks in chunks, adds some structure (just the size of the entry
  that follows), and lets a user-provided writer write the entry.
- It allows reading past entries.
- It can be in an "out-of-session" state where APIs are still available but do
  nothing.

It is intended to eventually replace BlocksRingBuffer.

This patch starts with the basic structure, following patches will add all
planned features.

Differential Revision: https://phabricator.services.mozilla.com/D69493

--HG--
extra : moz-landing-system : lando
2020-04-15 03:21:09 +00:00
Gerald Squelart 989ad20d1d Bug 1626837 - Add BlocksRingBuffer::IsInSession() - r=canaltinova
`ProfileBuffer` used to check if a `BlocksRingBuffer` was in session by looking
at its buffer size.
Now `IsInSession()` should be used, it is clearer in intent, and will make the
transition to `ProfileChunkedBuffer` slightly easier.

Differential Revision: https://phabricator.services.mozilla.com/D69492

--HG--
extra : moz-landing-system : lando
2020-04-15 03:20:51 +00:00
Gerald Squelart ca9fa3fe8f Bug 1627563 - Replace MOZ_MUST_USE with [[nodiscard]] in mozglue/baseprofiler. r=canaltinova
Also move MOZ_MUST_USE before function declarations' specifiers and return type. While clang and gcc's attribute((warn_unused_result)) can appear before, between, or after function specifiers and return types, the [[nodiscard]] attribute must precede the function specifiers.

And removed a few unneded `#include "mozilla/Attributes.h"`.

Differential Revision: https://phabricator.services.mozilla.com/D69755

--HG--
extra : moz-landing-system : lando
2020-04-06 10:04:38 +00:00
Gerald Squelart d4709d16f3 Bug 1625856 - ProfileBufferChunkManagerWithLocalLimit - r=canaltinova
`ProfileBufferChunkManagerWithLocalLimit` is a chunk manager that enforces a
memory limit in each process.

It is meant to mimic the main way `BlocksRingBuffer` works, so that we can more
easily switch to the new buffer storage without introducing the extra complexity
of inter-process memory coordination yet.

`ProfileBufferChunkManagerWithLocalLimit` will still offer a benefit over
`BlocksRingBuffer`, in that it won't allocate the maximum buffer size
immediately -- speeding the initialization, and hopefully even reducing the
total Firefox memory consumption in short-lived processes.

Differential Revision: https://phabricator.services.mozilla.com/D68770

--HG--
extra : moz-landing-system : lando
2020-04-02 03:09:36 +00:00
Gerald Squelart de1f096fd6 Bug 1624257 - ProfileBufferChunkManagerSingle - r=canaltinova
Chunk manager dealing with only one chunk at a time.

Differential Revision: https://phabricator.services.mozilla.com/D68014

--HG--
extra : moz-landing-system : lando
2020-03-29 23:49:32 +00:00
Gerald Squelart 2e503c9a92 Bug 1624257 - ProfileBufferChunkManager - r=canaltinova
Base class for chunk managers.

Differential Revision: https://phabricator.services.mozilla.com/D68013

--HG--
extra : moz-landing-system : lando
2020-03-29 23:25:35 +00:00
André Bargull 13bfe75b97 Bug 1625138 - Part 40: Replace remaining mozilla::IsSame with std::is_same. r=froydnj
Differential Revision: https://phabricator.services.mozilla.com/D68560

--HG--
extra : moz-landing-system : lando
2020-03-28 13:57:21 +00:00
James Willcox 2ef4e466f8 Bug 1291377 - Don't use custom linker on Android 6.0+ r=glandium
We still need it for Android < 6.0 (API 23) because otherwise we don't
have a way to hook up mozalloc.

Differential Revision: https://phabricator.services.mozilla.com/D66993

--HG--
extra : moz-landing-system : lando
2020-03-20 15:35:48 +00:00
Gerald Squelart c80fa7258c Bug 1623228 - ProfileBufferChunk - r=canaltinova
A `ProfileBufferChunk` represents a single chunk of memory, with an optional
link to the next chunk.

In the new Fission-compatible profiler storage, chunks will be allocated by a
chunk manager, filled with data by the profiler, and then released back to the
chunk manager.
The chunk manager may decide to destroy or recycle old chunks based on memory
limits (per process, or for the entire Firefox app).

Differential Revision: https://phabricator.services.mozilla.com/D67272

--HG--
extra : moz-landing-system : lando
2020-03-24 01:04:33 +00:00