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

393 Коммитов

Автор SHA1 Сообщение Дата
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
Razvan Maries f86965f8af Backed out changeset 1a28a2477439 (bug 1623228) for build bustages on ProfileBufferChunk.h. CLOSED TREE 2020-03-23 23:29:12 +02:00
Gerald Squelart df0599ee6d 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-23 18:16:08 +00:00
Bogdan Tara 05377fcd08 Backed out changeset fe0c22951e7c (bug 1291377) for mozglue related Android bustages CLOSED TREE 2020-03-20 16:39:42 +02:00
James Willcox e2c25ee165 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 14:20:48 +00:00
Gerald Squelart 7dd306dcd9 Bug 1623195 - Optimize ProfileBufferEntryWriter::Serializer<Variant> - r=canaltinova
The old code was using `std::index_sequence_for` to call templated functions for
*every* possible Variant alternative.
Instead, using `Variant::match()` with a generic lambda (that also takes the
current Variant index, thanks to bug 1621865) means we're only calling the
function corresponding to the current alternative.

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

--HG--
extra : moz-landing-system : lando
2020-03-18 10:23:10 +00:00
Chris Fronk d5b004443b Bug 1143478 - Rename mozilla::Pair to CompactPair. r=froydnj
Differential Revision: https://phabricator.services.mozilla.com/D64511

--HG--
rename : mfbt/Pair.h => mfbt/CompactPair.h
extra : moz-landing-system : lando
2020-03-17 12:42:12 +00:00
Markus Stange 3349423265 Bug 1557570 - Build the base profiler on Android. r=gerald
Differential Revision: https://phabricator.services.mozilla.com/D64998

--HG--
extra : moz-landing-system : lando
2020-03-17 03:27:35 +00:00
Markus Stange de0a0463d6 Bug 1557570 - Make baseprofiler/core/shared-libraries-linux.cc compile on Android. r=glandium
Stop including "Linker.h" and always include <link.h> instead, which also comes with ElfW() and other things that this code needs.
Also fix up "!/" path detection code.

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

--HG--
extra : moz-landing-system : lando
2020-03-17 03:26:57 +00:00
Markus Stange 6d980e05bb Bug 1618979 - Use PrintToConsole for things that should always be printed. r=gerald
Differential Revision: https://phabricator.services.mozilla.com/D64996

--HG--
extra : moz-landing-system : lando
2020-03-17 03:26:19 +00:00
Markus Stange e3cd7fc71c Bug 1618979 - Tweak base profiler logging. r=gerald
This fixes the declaration of (BaseProfiler)LogTest. It also makes it so that the logs show up on Android.
In xpcom we have printf_stderr which does something similar and also handles Windows.

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

--HG--
extra : moz-landing-system : lando
2020-03-17 03:25:40 +00:00
Markus Stange e54247708a Bug 1619362 - Sync up the two profiler feature lists again. r=gerald
Differential Revision: https://phabricator.services.mozilla.com/D65012

--HG--
extra : moz-landing-system : lando
2020-03-17 03:25:02 +00:00
Markus Stange f38f79b818 Bug 1619362 - Remove two unused variables. r=gerald
Differential Revision: https://phabricator.services.mozilla.com/D64990

--HG--
extra : moz-landing-system : lando
2020-03-17 03:24:23 +00:00
Markus Stange 345b2ee888 Bug 1619362 - Parse MOZ_BASE_PROFILER_STARTUP_DURATION and _INTERVAL. r=froydnj
Differential Revision: https://phabricator.services.mozilla.com/D64988

--HG--
extra : moz-landing-system : lando
2020-03-17 04:11:20 +00:00
Gerald Squelart bc32add109 Bug 1622179 - Replace direct dependencies on BlocksRingBuffer with ProfileBufferEntryWriter's where possible - r=canaltinova
This removes most dependencies on BlocksRingBuffer, to ease the transition to
the upcoming Fission-friendly profile buffer, including:
- Length type,
- SumBytes(),
- Gecko extensions of serialization.

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

--HG--
rename : tools/profiler/public/BlocksRingBufferGeckoExtensions.h => tools/profiler/public/ProfileBufferEntrySerializationGeckoExtensions.h
extra : moz-landing-system : lando
2020-03-16 20:32:35 +00:00
Gerald Squelart 3aec963bb6 Bug 1621866 - Use C++17 fold expressions in ProfileBufferEntrySerialization.h - r=canaltinova
Fold expressions are more expressive and probably produce better code than the
older template-recursion and initializer_list patterns.

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

--HG--
extra : moz-landing-system : lando
2020-03-12 21:05:31 +00:00
Bob Owen 22f20a8d00 Bug 1557282 Part 2: Fix profiler issues when using SetLockdownDefaultDacl. r=dmajor
When we are running from a network drive the new feature in part 1 doesn't work.
So this uses DuplicateHandle instead of OpenThread to get the thread handle used
by the profiler.
It also removes a DuplicateHandle THREAD_ALL_ACCESS call that also fails and a
DuplicateHandle to get a real process handle, which only seems to have been to
fix something on Windows XP.
The handle passed in is always the profiler one, so already has the necessary
permissions. If no thread handle is passed then the pseudo handle is used.

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

--HG--
extra : moz-landing-system : lando
2020-03-12 20:40:50 +00:00
Narcis Beleuzu feebca4edf Backed out 4 changesets (bug 1557282) as requested by tjr . CLOSED TREE
Backed out changeset deabd1e1018b (bug 1557282)
Backed out changeset 25e5b5ba8ac3 (bug 1557282)
Backed out changeset 30afcaf2782a (bug 1557282)
Backed out changeset f83095f739e0 (bug 1557282)

--HG--
extra : rebase_source : 1730b805fbd8d0b786f7dcec71aa9c02a8f7a93a
2020-03-12 19:39:27 +02:00
Bob Owen f25e4ba8c6 Bug 1557282 Part 2: Fix profiler issues when using SetLockdownDefaultDacl.
When we are running from a network drive the new feature in part 1 doesn't work.
So this uses DuplicateHandle instead of OpenThread to get the thread handle used
by the profiler.
It also removes a DuplicateHandle THREAD_ALL_ACCESS call that also fails and a
DuplicateHandle to get a real process handle, which only seems to have been to
fix something on Windows XP.
The handle passed in is always the profiler one, so already has the necessary
permissions. If no thread handle is passed then the pseudo handle is used.

Depends on D66610

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

--HG--
extra : moz-landing-system : lando
2020-03-12 16:57:45 +00:00
Gerald Squelart 9e0576b94c Bug 1620515 - Replace BlocksRingBuffer::EntryReader/Writer with ProfileBufferEntryReader/Writer - r=canaltinova
The new ProfileBufferEntryReader/Writer are now used everywhere, including in
the profilers and tests.
The old EntryReader/Writer have been removed.

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

--HG--
extra : moz-landing-system : lando
2020-03-11 21:59:19 +00:00
Gerald Squelart 7803bc357b Bug 1620515 - ProfileBufferEntryReader and ProfileBufferEntryWriter - r=canaltinova
Actual implementation of the entry reader and writer.
They expose a very similar API as the original BlocksRingBuffer entry reader&
writer.

(No tests here; In the next patch they will get used instead of the old reader&
writer, and will hence inherit all relevant tests.)

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

--HG--
extra : moz-landing-system : lando
2020-03-11 21:57:31 +00:00
Gerald Squelart 119ca02f31 Bug 1620515 - ProfileBufferEntrySerialization.h with (de)serializers - r=canaltinova
ProfileBufferEntrySerialization.h will contain the entry reader and writer.

This patch creates the file with renamed copies of the (de)serializers from
BlocksRingBuffer; there shouldn't be significant code changes, this `hg cp` will
help keep their history. See next patch for how they will actually be used.

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

--HG--
rename : mozglue/baseprofiler/public/BlocksRingBuffer.h => mozglue/baseprofiler/public/ProfileBufferEntrySerialization.h
extra : moz-landing-system : lando
2020-03-11 21:56:50 +00:00
Gerald Squelart d156810f51 Bug 1620515 - Revert order of BlocksRingBuffer (de)serializer declarations - r=canaltinova
Only reordering declarations, to make the next patch easier to read.

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

--HG--
extra : moz-landing-system : lando
2020-03-11 21:56:17 +00:00
shindli b02b3a6e1a Backed out changeset a08637fb30c8 (bug 1143478) for causing bustages in /builds/worker/checkouts/gecko/ipc/mscom/Registration.cpp CLOSED TREE
--HG--
rename : mfbt/CompactPair.h => mfbt/Pair.h
2020-03-11 14:30:54 +02:00
Chris Fronk a27e438c2d Bug 1143478 - Rename mozilla::Pair to CompactPair. r=froydnj
Differential Revision: https://phabricator.services.mozilla.com/D64511

--HG--
rename : mfbt/Pair.h => mfbt/CompactPair.h
extra : moz-landing-system : lando
2020-03-11 12:18:13 +00:00
Simon Giesecke a763c5c535 Bug 1613985 - Use default for equivalent-to-default constructors/destructors in mozglue. r=glandium
Differential Revision: https://phabricator.services.mozilla.com/D65495

--HG--
extra : moz-landing-system : lando
2020-03-10 08:47:24 +00:00
Mike Hommey 1a58a0ff4f Bug 1619865 - Support pdb paths with forward slashes. r=gerald
Differential Revision: https://phabricator.services.mozilla.com/D65286

--HG--
extra : moz-landing-system : lando
2020-03-04 08:02:42 +00:00
Cameron Kaiser ca26f712dd Bug 1619495 - fix compilation error with ModuloBuffer.h. r=gerald
Differential Revision: https://phabricator.services.mozilla.com/D65225

--HG--
extra : moz-landing-system : lando
2020-03-04 01:49:18 +00:00
Gerald Squelart 6a8de0643e Bug 1618406 - Replace BlocksRingBuffer::BlockIndex with ProfileBufferBlockIndex - r=gregtatum,canaltinova
To facilitate the upcoming transition to a new Fission-friendly storage, all
uses of `BlocksRingBuffer::{,Block}Index` are replaced with
`ProfileBuffer{,Block}Index`.

`BlocksRingBuffer::{,Block}Index` are not needed anymore.

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

--HG--
extra : moz-landing-system : lando
2020-03-02 05:34:26 +00:00
Gerald Squelart 6ee54a61e0 Bug 1618406 - Add ProfileBuffer{,Block}Index - r=canaltinova
ProfileBufferIndex.h contains:
- `ProfileBufferIndex`, a generic index into a Profiler buffer.
- `ProfileBufferBlockIndex`, an almost-opaque index that should only point at
  valid (or expired) blocks.

These will soon be used instead of `BlocksRingBuffer::{,Block}Index`, to make
the transition away from `BlocksRingBuffer` easier.

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

--HG--
extra : moz-landing-system : lando
2020-03-02 05:33:25 +00:00
Andrew McCreight 4babb2b5ab Bug 1609815 - Remove Web Replay C++ implementation. r=jgilbert,jandem,gbrown
Patch by bhackett and jlaster. Also reviewed by mccr8.

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

--HG--
extra : moz-landing-system : lando
2020-02-27 17:39:15 +00:00
Ciure Andrei 00dd87f6f4 Backed out changeset d407a28318e6 (bug 1609815) for causing windows ming bustages CLOSED TREE
--HG--
extra : histedit_source : b2c748e31e0f6ba8fcf9960a336e0bbd361b07e6
2020-02-27 07:05:19 +02:00
Andrew McCreight b197e1f783 Bug 1609815 - Remove Web Replay C++ implementation. r=jgilbert,jandem,gbrown
Patch by bhackett and jlaster. Also reviewed by mccr8.

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

--HG--
extra : moz-landing-system : lando
2020-02-27 04:43:48 +00:00
Gerald Squelart 2e862dd93e Bug 1616298 - ULEB128Reader - r=canaltinova
Unsigned LEB128 parser class that can be fed bytes one by one.

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

--HG--
extra : moz-landing-system : lando
2020-02-26 01:40:33 +00:00
Gerald Squelart 29ff6c0fbd Bug 1616298 - Run BaseProfiler-independent tests even when BaseProfiler is not built - r=gregtatum,canaltinova
Some of the BaseProfile headers are always available, even when BaseProfiler
itself is not built, so we should test these in all cases.

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

--HG--
extra : moz-landing-system : lando
2020-02-26 01:39:58 +00:00
Arthur Iakab a973454927 Backed out 2 changesets (bug 1616298)for causing build bustages on TestBaseProfiler.cpp
CLOSED TREE

Backed out changeset 781be7f64b1a (bug 1616298)
Backed out changeset a3920eccb1ac (bug 1616298)
2020-02-25 20:55:44 +02:00
Gerald Squelart bd615e6031 Bug 1616298 - ULEB128Reader - r=canaltinova
Unsigned LEB128 parser class that can be fed bytes one by one.

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

--HG--
extra : moz-landing-system : lando
2020-02-25 06:05:29 +00:00
Gerald Squelart 8f7a1f5c14 Bug 1616298 - Run BaseProfiler-independent tests even when BaseProfiler is disabled - r=gregtatum,canaltinova
Some of the BaseProfile headers are always available, even when BaseProfiler
itself is disabled, so we should test these in all cases.

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

--HG--
extra : moz-landing-system : lando
2020-02-25 17:01:37 +00:00
Emilio Cobos Álvarez 4f0e8086f2 Bug 1609996 - Fix some things that the automated replacement didn't catch. r=froydnj
This makes Gecko build again. I'll squash this into the previous commit anyhow.

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

--HG--
extra : moz-landing-system : lando
2020-01-20 16:18:28 +00:00
Nazım Can Altınova d8afe0647a Bug 1609708 - Rename PROFILER_TRACING to PROFILER_TRACING_MARKER. r=gerald
Depends on D60229

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

--HG--
extra : moz-landing-system : lando
2020-01-17 21:29:15 +00:00
shindli c52d5f8025 Backed out 2 changesets (bug 1586939) for causing perma bc failures in automation.py CLOSED TREE
Backed out changeset 922243345807 (bug 1586939)
Backed out changeset b5aac83f7f4f (bug 1586939)
2020-01-16 09:51:49 +02:00
Gerald Squelart 50efb05c6b Bug 1586939 - Remove "_BASE" from most Base Profiler env-vars - r=gregtatum
Now both profilers are controlled by the same environment variables, e.g.
"MOZ_PROFILER_STARTUP" to run both profilers at startup.

The only remaining Base Profiler-specific commands are:
- MOZ_BASE_PROFILER_HELP, because the Base Profiler doesn't have the same
  capabilities as Gecko, so it may display different available features.
- MOZ_BASE_PROFILER_LOGGING, because the Base Profiler doesn't have access to
  MOZ_LOG (both the env-var and the C++ macros).

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

--HG--
extra : moz-landing-system : lando
2020-01-15 01:57:35 +00:00
Gerald Squelart 407454a9e0 Bug 1586939 - Re-enable MOZ_BASE_PROFILER_STARTUP_DURATION and _INTERVAL - r=gregtatum
This env-vars were not processed because of some needed special processing, and
they were not critical.
But now we want them to be correctly read, to match the Gecko Profiler features.

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

--HG--
extra : moz-landing-system : lando
2020-01-15 01:57:13 +00:00
Gerald Squelart 1484f8824a Bug 1600644 - Don't count ActivePS::mProfileBuffer's own size twice - r=canaltinova
In bug 1587332, ActivePS::mProfileBuffer was changed from
`const UniquePtr<ProfileBuffer>` to just `ProfileBuffer`, so its own object size
is now counted as part of `sizeof(ActivePS)`, and we should only count its
dependencies with `SizeOfExcludingThis`.

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

--HG--
extra : moz-landing-system : lando
2020-01-02 12:21:58 +00:00
Gerald Squelart 7a41d8998c Bug 1604661 - Gecko Profiler filter "*" selects all registered threads - r=gregtatum
The only way to select all registered threads was to have an empty entry in the
filter list, usually by just having "," (a single comma).
The popup removes spurious empty items, making this impossible for most users.

It is now possible to just have "*" (as the whole filter string, or at least one
item in the list) to select all registered threads.

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

--HG--
extra : moz-landing-system : lando
2019-12-18 20:38:59 +00:00
Jeff Walden e57173377f Bug 1439659 - Make |MOZ_{LITTLE,BIG}_ENDIAN| into function macros so that invoking them inside |#if| conditions when they haven't been defined yet is a compile error. r=froydnj
Differential Revision: https://phabricator.services.mozilla.com/D57038

--HG--
extra : moz-landing-system : lando
2019-12-13 20:51:04 +00:00
Gerald Squelart fb5cbabc75 Bug 1598531 - Output Base Profiler logging to stderr, so it is correctly sync'd with MOZ_LOG - r=gregtatum
This is especially useful when debugging both Base Profiler and Gecko Profiler,
so that their messages are correctly sequenced.

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

--HG--
extra : moz-landing-system : lando
2019-11-26 23:01:25 +00:00
Gerald Squelart 9da1d33d1e Bug 1598992 - Use same thread names in Base Profiler filter as in Gecko, and suffix with "(pre-xul)" in JSON - r=gregtatum
The Base Profiler originally named the main thread "Main Thread", which is
friendlier than "GeckoMain". However this makes it more difficult to combine the
controls for both profilers if they use different names.

So now both profilers use "GeckoMain", so filters can be exactly the same.
Base Profiler adds "(pre-xul)" to the name to distinguish tracks in the
frontend -- This distinction is actually necessary so the frontend doesn't get
confused by threads with the exact same name, but eventually tracks will get
combined in the frontend as well.

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

--HG--
extra : moz-landing-system : lando
2019-11-26 23:01:10 +00:00
Narcis Beleuzu 822a54d9fb Backed out 6 changesets (bug 1598992, bug 1598531, bug 1598529) for causing MinGW bustages on GeckoProfiler.cpp. CLOSED TREE
Backed out changeset 407ccb5f316b (bug 1598531)
Backed out changeset 40903d7428fb (bug 1598992)
Backed out changeset 53bc356053b0 (bug 1598992)
Backed out changeset a7931318ce6c (bug 1598992)
Backed out changeset b3880cc8dc23 (bug 1598992)
Backed out changeset 1e969b7c2352 (bug 1598529)
2019-11-26 23:36:11 +02:00
Gerald Squelart 8bd3b43665 Bug 1598531 - Output Base Profiler logging to stderr, so it is correctly sync'd with MOZ_LOG - r=gregtatum
This is especially useful when debugging both Base Profiler and Gecko Profiler,
so that their messages are correctly sequenced.

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

--HG--
extra : moz-landing-system : lando
2019-11-26 11:28:33 +00:00
Gerald Squelart 65a045f543 Bug 1598992 - Use same thread names in Base Profiler filter as in Gecko, and suffix with "(pre-xul)" in JSON - r=gregtatum
The Base Profiler originally named the main thread "Main Thread", which is
friendlier than "GeckoMain". However this makes it more difficult to combine the
controls for both profilers if they use different names.

So now both profilers use "GeckoMain", so filters can be exactly the same.
Base Profiler adds "(pre-xul)" to the name to distinguish tracks in the
frontend -- This distinction is actually necessary so the frontend doesn't get
confused by threads with the exact same name, but eventually tracks will get
combined in the frontend as well.

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

--HG--
extra : moz-landing-system : lando
2019-11-26 11:27:45 +00:00
Mike Hommey b1d0510804 Bug 1598196 - Support disabling the linker on Android in the code. r=froydnj
For now, there is no flag to actually allow it, but this is the
code-side changes to allow the linker being disabled.

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

--HG--
extra : moz-landing-system : lando
2019-11-21 14:57:24 +00:00
Mike Hommey 6b83eba3c7 Bug 1598194 - Make FaultyLib-specific code FaultyLib-specific rather than Android-specific. r=gerald
The custom linker used on Android (FaultyLib), can be enabled on
non-Android, and in the near future, may not always be enabled on
Android, so the FaultyLib-specific parts of the profile need to not be
specific to Android, but to the linker being enabled instead.

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

--HG--
extra : moz-landing-system : lando
2019-11-25 23:04:24 +00:00
Andrew McCreight d25c3b20ae Bug 1598787 - Rename XRE_ChildProcessTypeToString to XRE_GeckoProcessTypeToString. r=froydnj
This function works on all GeckoProcessTypes, not just those for child
processes.

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

--HG--
extra : moz-landing-system : lando
2019-11-25 22:45:31 +00:00
Randell Jesup b3b313e654 Bug 1595482: change "responsiveness" field to "eventDelay" in profiler r=canaltinova
We want the profiler UI to be able to know if the data can be used for
reconstructing the event delays, since it measures something different
from the old 16ms event injection.

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

--HG--
extra : moz-landing-system : lando
2019-11-18 14:26:14 +00:00
Nazım Can Altınova b7c55f9282 Bug 1468789 - Part 3: Serialize innerWindowID for js/jit frames. r=gerald
Differential Revision: https://phabricator.services.mozilla.com/D51861

--HG--
extra : moz-landing-system : lando
2019-11-14 14:15:03 +00:00
Nazım Can Altınova 8f6754f6fc Bug 1468789 - Part 2: Collect inner window id information for js interpreter frames and add a mechanism to get that for jit frames r=gerald,jandem,mstange
Differential Revision: https://phabricator.services.mozilla.com/D51860

--HG--
extra : moz-landing-system : lando
2019-11-15 08:01:30 +00:00
Narcis Beleuzu f0fe67f321 Backed out changeset 70738ac7ba9b (bug 1595482) for xpcshell failures on test_responsiveness.js . CLOSED TREE 2019-11-13 18:28:31 +02:00
Randell Jesup f542396ff9 Bug 1595482: change "responsiveness" field to "eventDelay" in profiler r=canaltinova
We want the profiler UI to be able to know if the data can be used for
reconstructing the event delays, since it measures something different
from the old 16ms event injection.

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

--HG--
extra : moz-landing-system : lando
2019-11-13 14:21:52 +00:00
Randell Jesup 3d6c5b76dd Bug 1572337: Don't call TimeStamp::Now() within SuspendAndSample r=froydnj
Avoids deadlocks on Windows due to Now() taking a lock; if done while we've
paused a thread that holds the lock we will deadlock.

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

--HG--
extra : moz-landing-system : lando
2019-11-08 21:18:06 +00:00
Randell Jesup 05d65a0464 Bug 1572337: Remove old responsiveness profiler measurement r=gerald
Differential Revision: https://phabricator.services.mozilla.com/D44060

--HG--
extra : moz-landing-system : lando
2019-11-08 21:08:07 +00:00
Ciure Andrei b7c3599997 Backed out 3 changesets (bug 1572337, bug 1594015) for causing linting failures and build bustages CLOSED TREE
Backed out changeset 25f074eb5074 (bug 1594015)
Backed out changeset fc8a37c2c22c (bug 1572337)
Backed out changeset 913d6bd82284 (bug 1572337)
2019-11-07 16:37:00 +02:00
Randell Jesup 95be6cffe0 Bug 1572337: Remove old responsiveness profiler measurement r=gerald
Differential Revision: https://phabricator.services.mozilla.com/D44060

--HG--
extra : moz-landing-system : lando
2019-11-07 12:53:35 +00:00
Gerald Squelart 1824e6f651 Bug 1584190 - In JSON profile, counters' sample_groups should be an array of objects - r=canaltinova
profile.counters[n].sample_groups was mistakenly streamed as an object, which
prevents having more than one, and goes against the published format
documentation.

The front-end was implemented to process the incorrect format, so it will need
to be updated as well; hence the version change to 18.

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

--HG--
extra : moz-landing-system : lando
2019-10-30 22:20:06 +00:00
Gerald Squelart d24177fe2a Bug 1587332 - Encapsulate ActivePS::mProfileBuffer as a ProfileBuffer value - r=canaltinova
Having `mProfileBuffer` be a pointer is not really helpful:
- The pointer is never null (It's allocated on ActivePS construction, and
  implicitly deleted on ActivePS destruction); it's never moved-from.
- It requires an extra `new` and an extra `delete`.

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

--HG--
extra : moz-landing-system : lando
2019-10-10 10:52:09 +00:00
Gerald Squelart dff1750481 Bug 1587329 - MOZ_ASSERT(sInstance) in all functions that dereference sInstance - r=canaltinova
Add assertions that all `sInstance` pointers (from both `CorePS` and `ActivePS`)
are not null before being dereferenced.

This is probably more than needed, but it's only `MOZ_ASSERT`s limited to
Nightly, and it should give better feedback in case something goes wrong.

Eventually, I think it would be better to make most methods non-static, and have
a checked reference-to-instance getter.

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

--HG--
extra : moz-landing-system : lando
2019-10-10 10:51:50 +00:00
Nazım Can Altınova 2e832289ac Bug 1512500 - Record parent page information in profiler r=gerald,nika
Differential Revision: https://phabricator.services.mozilla.com/D47426

--HG--
extra : moz-landing-system : lando
2019-10-09 21:25:19 +00:00
Nazım Can Altınova 6379b166c1 Bug 1583271 - Part 3: Remove the disabled assertion and add a mechanism to capture the first non-auto:blank frame r=nika
We are not simply excluding all about:blanks because there might be some
about:blank that user really visits. But for others we don't want to include
the first about:blank because when a BrowsingContext is loaded, and if the
principal matches, the first document loaded in it will share the inner window.

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

--HG--
extra : moz-landing-system : lando
2019-10-09 20:58:06 +00:00
Nazım Can Altınova 20fc64e558 Bug 1583271 - Part 1: Change profiler page information IDs to BrowsingContextID and InnerWindowID r=gerald,nika
We were keeping nsDocShell::mHistoryId and nsDocShell::mOSHE as keys. They
weren't quite good because:
1. While loading an iframe, they were being registered twice with the same
ids(for about:blank and the real URL) sometimes.
2. It wasn't possible to access to the parent mHistoryId and mOSHE from a child
processes if the parent is in a different process. That may not be the case for
now, but it will be after fission.
So we had to find other IDs to:
1. Determine the Tab of the frames.
2. Determine the URLs of the frames.
For the first use case, we were using nsDocShell::mHistoryId for that purpose
but that was wrong. The closest thing that we can get to a tab ID is
BrowsingContext ID because they don't change after a navigation. But iframes
have different BrowsingContext's, so we still need to create a tree to
construct a tab content. That can be either in the front-end or capture time.
For the second use case, we were using a key pair of mHistoryId and mOSHE. We
now chose to keep inner window IDs for that purpose. Inner window IDs are
unique for each navigation loads because inner window correspond to each JS
window global objects. That's why we can use that without any problem. But one
problem is that we cannot handle `history.pushState` and `history.replaceState`
changes with that change since window global objects won't change during those.
But that was the best thing we can do after fission. So this will be a small
sacrifice for us to keep that functionality working after fission.
In that patch we also remove the registration/unregistration calls. We are
going to add those calls in the next patch.

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

--HG--
extra : moz-landing-system : lando
2019-10-09 21:25:11 +00:00
Gerald Squelart 499b5db10f Bug 1583868 - New profiler feature "nostacksampling" - r=gregtatum
Previously, the absence of "stackwalk", "leaf", and "javascript" implied that
the test/user didn't want any sampling, but this caused issues in some tests
that enabled "stackwalk" on platforms that didn't support stack-walking, which
ended up suppressing label-only stacks that the test expected.

we now have an explicit feature "nostacksampling" that disables backtraces from
the samplers in both profilers. This effectively cancels "stackwalk", "leaf",
and "javascript" if present.

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

--HG--
extra : moz-landing-system : lando
2019-10-01 22:49:13 +00:00
Brindusan Cristian 79e9f1a034 Backed out changeset 8989d1a83de8 (bug 1583868) for xpcshell failures at test_ext_geckoProfiler_schema.js. CLOSED TREE 2019-10-01 22:27:11 +03:00
Gerald Squelart fa7dc1a809 Bug 1583868 - New profiler feature "nostacksampling" - r=gregtatum
Previously, the absence of "stackwalk", "leaf", and "javascript" implied that
the test/user didn't want any sampling, but this caused issues in some tests
that enabled "stackwalk" on platforms that didn't support stack-walking, which
ended up suppressing label-only stacks that the test expected.

we now have an explicit feature "nostacksampling" that disables backtraces from
the samplers in both profilers. This effectively cancels "stackwalk", "leaf",
and "javascript" if present.

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

--HG--
extra : moz-landing-system : lando
2019-10-01 14:00:21 +00:00
Gerald Squelart 16dbd4f365 Bug 1582992 - Removed unneded BlocksRingBuffer's entry destructor, and ProfilerBuffer's JS::AutoSuppressGCAnalysis - r=gregtatum
`BlocksRingBuffer` had an "entry destructor" to make it a more generic
container, and it was useful during early prototyping of the new profiler
storage (so that we could store owning pointers).
But this entry destructor is stored in an `std::function`, which gets marked as
a potential GC caller by the js rooting hazard analyzer; and as this bug found,
it's not obvious where to place `JS::AutoSuppressGCAnalysis`, because profiler
entries (including stacks) could be added on one thread while GC happens
elsewhere, which triggers the embedded `AutoAssertNoGC` check.

Since we don't actually use the entry destructor facility in the profiler, it's
easier to just get rid of it. As a bonus, it's a small optimization.
Tests that were using an entry destructor now use the `State` instead, to verify
that entries are pushed and cleared as expected.

If needed in the future outside of the profiler, `BlocksRingBuffer` could again
include an entry destructor, but it would have to be through templating, so that
the class used in the profiler wouldn't contain an `std::function`.

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

--HG--
extra : moz-landing-system : lando
2019-09-23 20:50:20 +00:00
Gerald Squelart 1549c7e36e Bug 1582357 - Allow profiler entries up to the size of the buffer - r=gregtatum
In some situations, entries may in fact take more than half the buffer size
(e.g., when duplicating a stack into a small temporary buffer).
So we now allow blocks to take the full buffer size -- but not more, as they
would start overwriting themselves!

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

--HG--
extra : moz-landing-system : lando
2019-09-19 13:40:01 +00:00
Gerald Squelart 64ec6b96a0 Bug 1581049 - BlocksRingBuffer (de)serializer uses optimized inter-ModuloBuffer copier - r=gregtatum
Instead of copying `BlocksRingBuffer` data byte-by-byte (using iterators byte
dereferencers), we can now use `ModuloBuffer::Iterator::ReadInto(Iterator&)` to
copy them using a small number of `memcpy`s.

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

--HG--
extra : moz-landing-system : lando
2019-09-18 01:22:42 +00:00
Gerald Squelart 229768ce0a Bug 1581049 - ModuloBuffer::Iterator::ReadInto(ModuloBuffer::Iterator&) - r=gregtatum
Some objects are copied byte-by-byte to/from `ModuloBuffer`s.
E.g., serialized `BlocksRingBuffer`s, or duplicate stacks. (And more to come.)

`Iterator::ReadInto(Iterator&)` optimizes these copies by using the minimum
number of `memcpy`s possible.

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

--HG--
extra : moz-landing-system : lando
2019-09-18 01:22:30 +00:00
Gerald Squelart 738f482766 Bug 1578329 - profiler_can_accept_markers(), don't store markers when paused - r=gregtatum
profiler_can_accept_markers() is a fast and racy check that markers would
currently be stored, it should be used around potentially-expensive calls to
add markers.

And now markers are no longer stored when the profiler is paused. (Note that the
profiler is paused when a profile is being stored, this will help make this
operation faster.)

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

--HG--
extra : moz-landing-system : lando
2019-09-18 01:21:50 +00:00
Gerald Squelart a8b053c3b1 Bug 1578327 - Discard old data just before streaming - r=gregtatum
Since all profiler data is now stored inside ProfileBuffer, there is no real
need to continuously discard old data during sampling (this was particularly
useful to reclaim memory taken by old markers&payloads).

Instead, we can now just discard the old data once, just before starting to
stream it to JSON.

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

--HG--
extra : moz-landing-system : lando
2019-09-18 01:21:32 +00:00
Gerald Squelart 58ac06a047 Bug 1576555 - Remove unneeded ProfilerMarker - r=gregtatum
Now that what was in ProfilerMarker is stored directly in `BlocksRingBuffer`,
there is no need for this class anymore!
This also removes all the pointer management around it (when added to a TLS
list, moved during sampling, deleted when expired).

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

--HG--
extra : moz-landing-system : lando
2019-09-18 01:21:20 +00:00
Gerald Squelart 02d2886883 Bug 1576555 - Don't store temporary ProfilerMarkerPayloads in UniquePtrs - r=gregtatum
Since payloads are not kept alive long after they have been serialized, we can
just create them on the stack and pass a reference to their base (or pointer,
`nullptr` representing "no payloads") to `profiler_add_marker()`.

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

--HG--
extra : moz-landing-system : lando
2019-09-18 01:21:02 +00:00
Gerald Squelart 666a5caa9d Bug 1576555 - Store markers directly into BlocksRingBuffer - r=gregtatum
Markers and their payloads can now be serialized straight into the profiler's
`BlocksRingBuffer`, which is now thread-safe to allow such concurrent accesses
(even when gPSMutex is not locked).
This already saves us from having to allocate a `PayloadMarker` on the heap, and
from having to manage it in different lists.

The now-thread-safe `BlocksRingBuffer` in `CorePS` cannot be used inside the
critical section of `SamplerThread::Run`, because any mutex function could hang
because of the suspended thread (even though they functionally don't appear to
interact). So the sampler now uses a local `BlocksRingBuffer` without mutex.
As a bonus, the separate buffer helps reduce the number of concurrent locking
operations needed when capturing the stack.

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

--HG--
extra : moz-landing-system : lando
2019-09-18 01:20:45 +00:00
Gerald Squelart 06043a38e3 Bug 1576555 - BlocksRingBuffer::AppendContents(const BlocksRingBuffer&) - r=gregtatum
Copy the full contents of BlocksRingBuffer into another one.
This is mainly useful to use a temporary buffer to store some data without
contentions, and then integrate the temporary buffer into the main one.

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

--HG--
extra : moz-landing-system : lando
2019-09-18 01:20:28 +00:00
Gerald Squelart fc93e3d9da Bug 1575448 - De/serialize ProfilerMarkerPayload derived objects - r=gregtatum
Payloads will serialize themselves into a `BlocksRingBuffer` entry when first
captured.
Later they will be deserialized, to stream JSON for the output profile.

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

--HG--
extra : moz-landing-system : lando
2019-09-18 01:20:10 +00:00
Gerald Squelart 0ffe75f626 Bug 1575448 - ProfilerMarkerPayload::CommonProps - r=gregtatum
The common data members stored in the ProfilerMarkerPayload base class can be
gathered into a struct, which will make it easier to pass around, especially
when a derived object is constructed with these common properties.

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

--HG--
extra : moz-landing-system : lando
2019-09-18 01:19:53 +00:00
Gerald Squelart ac26c5d9f5 Bug 1576554 - {S,Des}erializer<ProfilerBacktrace> - r=gregtatum
Markers may contain backtraces, so we need to be able to de/serialize them.
This involves de/serializing the underyling `BlocksRingBuffer`.

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

--HG--
extra : moz-landing-system : lando
2019-09-18 01:19:40 +00:00
Gerald Squelart 9f7c402a79 Bug 1576551 - Store BlocksRingBuffer outside of ProfileBuffer - r=gregtatum
The main `BlocksRingBuffer`s will be stored in `CorePS` (outside of
`ProfileBuffer`s), as we need to be able to safely access the underlying buffers
when profilers are not enabled.

Also `ProfilerBacktrace` will own the `BlocksRingBuffer` that its captured
`ProfileBuffer` uses.

Taking this opportunity to rename the different `mBuffer`s to more useful names.

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

--HG--
extra : moz-landing-system : lando
2019-09-18 01:19:21 +00:00
Gerald Squelart 74301e6c5c Bug 1576551 - Assume capacity is in 8-byte entries - r=gregtatum
Now that we are using a byte-oriented `BlocksRingBuffer` instead of an array of
9-byte `ProfileBufferEntry`'s, internally the profiler sets the buffer size in
bytes. However all external users (popup, tests, etc.) still assume that the
requested capacity is in entries!

To limit the amount of changes, we will keep assuming externally-visible
capacities are in entries, and convert them to bytes.
Even though entries used to be 9 bytes each, and `BlocksRingBuffer` adds 1 byte
for the entry size, some entries actually need less space (e.g., 32-bit numbers
now take 6 bytes instead of 9), so converting to less than 9 bytes per entry is
acceptable.
We are settling on 8 bytes per entry: It's close to 9, and it's a power of two;
since the effective number of entries was a power of two, and `BlocksRingBuffer`
also uses a power of two size in bytes, this convertion keeps sizes in powers of
two.

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

--HG--
extra : moz-landing-system : lando
2019-09-18 01:19:14 +00:00
Gerald Squelart 6666138a83 Bug 1576551 - Use BlocksRingBuffer in ProfileBuffer - r=gregtatum
This just replaces `ProfileBuffer`'s self-managed circular buffer with a
`BlocksRingBuffer`.

That `BlocksRingBuffer` does not need its own mutex (yet), because all uses go
through gPSMutex-guarded code.

`ProfileBuffer` now also pre-allocates a small buffer for use in
`DuplicateLastSample()`, this avoids multiple mallocs at each sleeping thread
stack duplication.

Note: Internal "magic" sizes have been multiplied by 8 (and tweaked upwards, to
handle bigger stacks), because they originally were the number of 9-byte
entries, but now it's the buffer size in bytes. (And entries can now be smaller
than 9 bytes, so overall the capacity in entries should be similar or better.)
However, external calls still think they are giving a number of "entries", this
will be handled in the next patch.

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

--HG--
extra : moz-landing-system : lando
2019-09-18 01:19:12 +00:00
Gerald Squelart 82b9f4f30f Bug 1576551 - AUTO_PROFILER_STATS(locked_profiler_stream_json_for_this_process) - r=gregtatum
Add some stats (off by default) around streaming JSON, as the following patches
may affect it.

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

--HG--
extra : moz-landing-system : lando
2019-09-18 01:19:10 +00:00
Gerald Squelart c90cc7f5b7 Bug 1580091 - Use BaseProfilerMaybeMutex in BlocksRingBuffer - r=gregtatum
In some situations we will *need* to use a `BlocksRingBuffer` that absolutely
does not use a mutex -- In particular in the critical section of
`SamplerThread::Run()`, when a thread is suspended, because any action on any
mutex (even a private one that no-one else interacts with) can result in a hang.

As a bonus, `BlocksRingBuffer`s that are known not to be used in multi-thread
situations (e.g., backtraces, extracted stacks for duplication, etc.) will waste
less resources trying to lock/unlock their mutex.

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

--HG--
extra : moz-landing-system : lando
2019-09-18 01:19:08 +00:00
Gerald Squelart cac9b1645b Bug 1580091 - BaseProfilerMaybeMutex and BaseProfilerMaybeAutoLock - r=gregtatum
`BaseProfilerMaybeMutex` wraps a `BaseProfilerMutex` inside a `Maybe`.
The decision to use a mutex or not is set at construction time.
If there is no mutex, all operations do nothing (at the small cost of checking
if the mutex is present.)

`BaseProfilerMaybeAutoLock` is the recommented RAII object to lock and
automatically unlock a `BaseProfilerMaybeMutex` until the end of a block scope.

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

--HG--
extra : moz-landing-system : lando
2019-09-18 01:19:06 +00:00
Bogdan Tara 361c83c1a9 Backed out 21 changesets (bug 1578327, bug 1575448, bug 1580091, bug 1576554, bug 1581049, bug 1576551, bug 1578329, bug 1576555) for platform.cpp related bustage CLOSED TREE
Backed out changeset 27afea20c396 (bug 1581049)
Backed out changeset be1ec4577d37 (bug 1581049)
Backed out changeset b4b6bbb18cc1 (bug 1581049)
Backed out changeset b30942f9db54 (bug 1581049)
Backed out changeset 473c431866f7 (bug 1578329)
Backed out changeset ac492dc3df20 (bug 1578329)
Backed out changeset f51875652f6f (bug 1578327)
Backed out changeset 512b7cbd18f6 (bug 1576555)
Backed out changeset 2d63a9934c00 (bug 1576555)
Backed out changeset ff73f648ab6c (bug 1576555)
Backed out changeset 49f49079bbb5 (bug 1576555)
Backed out changeset e8323157c6f3 (bug 1575448)
Backed out changeset 3b0d726f2dd6 (bug 1575448)
Backed out changeset 5924790abc4b (bug 1576554)
Backed out changeset a14ac9bb5338 (bug 1576554)
Backed out changeset b6d73f5042a7 (bug 1576551)
Backed out changeset 366030bd2d84 (bug 1576551)
Backed out changeset d7ee4148aad9 (bug 1576551)
Backed out changeset ec72dfc7301e (bug 1576551)
Backed out changeset 79b29286f906 (bug 1580091)
Backed out changeset 6f34c2e57ccf (bug 1580091)
2019-09-17 10:16:14 +03:00
Gerald Squelart 541c78764a Bug 1581049 - BlocksRingBuffer (de)serializer uses optimized inter-ModuloBuffer copier - r=gregtatum
Instead of copying `BlocksRingBuffer` data byte-by-byte (using iterators byte
dereferencers), we can now use `ModuloBuffer::Iterator::ReadInto(Iterator&)` to
copy them using a small number of `memcpy`s.

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

--HG--
extra : moz-landing-system : lando
2019-09-17 01:54:21 +00:00
Gerald Squelart 4c2ab062ce Bug 1581049 - ModuloBuffer::Iterator::ReadInto(ModuloBuffer::Iterator&) - r=gregtatum
Some objects are copied byte-by-byte to/from `ModuloBuffer`s.
E.g., serialized `BlocksRingBuffer`s, or duplicate stacks. (And more to come.)

`Iterator::ReadInto(Iterator&)` optimizes these copies by using the minimum
number of `memcpy`s possible.

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

--HG--
extra : moz-landing-system : lando
2019-09-17 01:54:03 +00:00
Gerald Squelart b643004d63 Bug 1578329 - profiler_can_accept_markers(), don't store markers when paused - r=gregtatum
profiler_can_accept_markers() is a fast and racy check that markers would
currently be stored, it should be used around potentially-expensive calls to
add markers.

And now markers are no longer stored when the profiler is paused. (Note that the
profiler is paused when a profile is being stored, this will help make this
operation faster.)

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

--HG--
extra : moz-landing-system : lando
2019-09-17 01:53:54 +00:00
Gerald Squelart 7d435fc17a Bug 1578327 - Discard old data just before streaming - r=gregtatum
Since all profiler data is now stored inside ProfileBuffer, there is no real
need to continuously discard old data during sampling (this was particularly
useful to reclaim memory taken by old markers&payloads).

Instead, we can now just discard the old data once, just before starting to
stream it to JSON.

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

--HG--
extra : moz-landing-system : lando
2019-09-17 01:53:52 +00:00
Gerald Squelart 79e1b2e357 Bug 1576555 - Remove unneeded ProfilerMarker - r=gregtatum
Now that what was in ProfilerMarker is stored directly in `BlocksRingBuffer`,
there is no need for this class anymore!
This also removes all the pointer management around it (when added to a TLS
list, moved during sampling, deleted when expired).

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

--HG--
extra : moz-landing-system : lando
2019-09-17 01:53:50 +00:00
Gerald Squelart 8364b4ebdb Bug 1576555 - Don't store temporary ProfilerMarkerPayloads in UniquePtrs - r=gregtatum
Since payloads are not kept alive long after they have been serialized, we can
just create them on the stack and pass a reference to their base (or pointer,
`nullptr` representing "no payloads") to `profiler_add_marker()`.

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

--HG--
extra : moz-landing-system : lando
2019-09-17 02:32:21 +00:00
Gerald Squelart b48590ff79 Bug 1576555 - Store markers directly into BlocksRingBuffer - r=gregtatum
Markers and their payloads can now be serialized straight into the profiler's
`BlocksRingBuffer`, which is now thread-safe to allow such concurrent accesses
(even when gPSMutex is not locked).
This already saves us from having to allocate a `PayloadMarker` on the heap, and
from having to manage it in different lists.

The now-thread-safe `BlocksRingBuffer` in `CorePS` cannot be used inside the
critical section of `SamplerThread::Run`, because any mutex function could hang
because of the suspended thread (even though they functionally don't appear to
interact). So the sampler now uses a local `BlocksRingBuffer` without mutex.
As a bonus, the separate buffer helps reduce the number of concurrent locking
operations needed when capturing the stack.

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

--HG--
extra : moz-landing-system : lando
2019-09-17 01:52:16 +00:00
Gerald Squelart 6d95d503f5 Bug 1576555 - BlocksRingBuffer::AppendContents(const BlocksRingBuffer&) - r=gregtatum
Copy the full contents of BlocksRingBuffer into another one.
This is mainly useful to use a temporary buffer to store some data without
contentions, and then integrate the temporary buffer into the main one.

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

--HG--
extra : moz-landing-system : lando
2019-09-17 01:51:53 +00:00
Gerald Squelart 5b86107991 Bug 1575448 - De/serialize ProfilerMarkerPayload derived objects - r=gregtatum
Payloads will serialize themselves into a `BlocksRingBuffer` entry when first
captured.
Later they will be deserialized, to stream JSON for the output profile.

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

--HG--
extra : moz-landing-system : lando
2019-09-17 01:51:41 +00:00
Gerald Squelart 64f0dcdf95 Bug 1575448 - ProfilerMarkerPayload::CommonProps - r=gregtatum
The common data members stored in the ProfilerMarkerPayload base class can be
gathered into a struct, which will make it easier to pass around, especially
when a derived object is constructed with these common properties.

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

--HG--
extra : moz-landing-system : lando
2019-09-17 01:51:18 +00:00
Gerald Squelart a14e2c944d Bug 1576554 - {S,Des}erializer<ProfilerBacktrace> - r=gregtatum
Markers may contain backtraces, so we need to be able to de/serialize them.
This involves de/serializing the underyling `BlocksRingBuffer`.

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

--HG--
extra : moz-landing-system : lando
2019-09-17 02:16:04 +00:00
Gerald Squelart 003cded47d Bug 1576551 - Store BlocksRingBuffer outside of ProfileBuffer - r=gregtatum
The main `BlocksRingBuffer`s will be stored in `CorePS` (outside of
`ProfileBuffer`s), as we need to be able to safely access the underlying buffers
when profilers are not enabled.

Also `ProfilerBacktrace` will own the `BlocksRingBuffer` that its captured
`ProfileBuffer` uses.

Taking this opportunity to rename the different `mBuffer`s to more useful names.

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

--HG--
extra : moz-landing-system : lando
2019-09-17 02:12:42 +00:00
Gerald Squelart c538807a81 Bug 1576551 - Assume capacity is in 8-byte entries - r=gregtatum
Now that we are using a byte-oriented `BlocksRingBuffer` instead of an array of
9-byte `ProfileBufferEntry`'s, internally the profiler sets the buffer size in
bytes. However all external users (popup, tests, etc.) still assume that the
requested capacity is in entries!

To limit the amount of changes, we will keep assuming externally-visible
capacities are in entries, and convert them to bytes.
Even though entries used to be 9 bytes each, and `BlocksRingBuffer` adds 1 byte
for the entry size, some entries actually need less space (e.g., 32-bit numbers
now take 6 bytes instead of 9), so converting to less than 9 bytes per entry is
acceptable.
We are settling on 8 bytes per entry: It's close to 9, and it's a power of two;
since the effective number of entries was a power of two, and `BlocksRingBuffer`
also uses a power of two size in bytes, this convertion keeps sizes in powers of
two.

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

--HG--
extra : moz-landing-system : lando
2019-09-17 01:50:19 +00:00
Gerald Squelart 71e4f99d21 Bug 1576551 - Use BlocksRingBuffer in ProfileBuffer - r=gregtatum
This just replaces `ProfileBuffer`'s self-managed circular buffer with a
`BlocksRingBuffer`.

That `BlocksRingBuffer` does not need its own mutex (yet), because all uses go
through gPSMutex-guarded code.

`ProfileBuffer` now also pre-allocates a small buffer for use in
`DuplicateLastSample()`, this avoids multiple mallocs at each sleeping thread
stack duplication.

Note: Internal "magic" sizes have been multiplied by 8 (and tweaked upwards, to
handle bigger stacks), because they originally were the number of 9-byte
entries, but now it's the buffer size in bytes. (And entries can now be smaller
than 9 bytes, so overall the capacity in entries should be similar or better.)
However, external calls still think they are giving a number of "entries", this
will be handled in the next patch.

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

--HG--
extra : moz-landing-system : lando
2019-09-17 01:49:59 +00:00
Gerald Squelart e8ea7f331e Bug 1576551 - AUTO_PROFILER_STATS(locked_profiler_stream_json_for_this_process) - r=gregtatum
Add some stats (off by default) around streaming JSON, as the following patches
may affect it.

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

--HG--
extra : moz-landing-system : lando
2019-09-17 01:49:37 +00:00
Gerald Squelart d20384e398 Bug 1580091 - Use BaseProfilerMaybeMutex in BlocksRingBuffer - r=gregtatum
In some situations we will *need* to use a `BlocksRingBuffer` that absolutely
does not use a mutex -- In particular in the critical section of
`SamplerThread::Run()`, when a thread is suspended, because any action on any
mutex (even a private one that no-one else interacts with) can result in a hang.

As a bonus, `BlocksRingBuffer`s that are known not to be used in multi-thread
situations (e.g., backtraces, extracted stacks for duplication, etc.) will waste
less resources trying to lock/unlock their mutex.

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

--HG--
extra : moz-landing-system : lando
2019-09-17 01:49:24 +00:00
Gerald Squelart 44511f2936 Bug 1580091 - BaseProfilerMaybeMutex and BaseProfilerMaybeAutoLock - r=gregtatum
`BaseProfilerMaybeMutex` wraps a `BaseProfilerMutex` inside a `Maybe`.
The decision to use a mutex or not is set at construction time.
If there is no mutex, all operations do nothing (at the small cost of checking
if the mutex is present.)

`BaseProfilerMaybeAutoLock` is the recommented RAII object to lock and
automatically unlock a `BaseProfilerMaybeMutex` until the end of a block scope.

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

--HG--
extra : moz-landing-system : lando
2019-09-17 01:49:07 +00:00
Gerald Squelart e1481bf4bb Bug 1576550 - AUTO_PROFILER_STATS(add_marker...) - r=gregtatum
Gather stats for most calls to `profiler_add_marker()`, including the time to
allocate payloads if any.

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

--HG--
extra : moz-landing-system : lando
2019-09-04 07:58:21 +00:00
Gerald Squelart 95f77c2409 Bug 1576819 - Use PROFILER_ADD_MARKER{,_WITH_PAYLOAD} everywhere - r=gregtatum
All calls to `profiler_add_marker()` (outside of the profilers code) are
now replaced by either:
- `PROFILER_ADD_MARKER(name, categoryPair)`
- `PROFILER_ADD_MARKER_WITH_PAYLOAD(name, categoryPair, TypeOfMarkerPayload,
                                    (payload, ..., arguments))`

This makes all calls consistent, and they won't need to prefix the category pair
with `JS::ProfilingCategoryPair::`.

Also it will make it easier to add (and later remove) internal-profiling
instrumentation (bug 1576550), and to replace heap-allocated payloads with
stack-allocated ones (bug 1576555).

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

--HG--
extra : moz-landing-system : lando
2019-09-04 07:56:51 +00:00
Toshihito Kikuchi 55ae74e010 Bug 1557564 - Enable Base Profiler in Windows. r=aklotz,gerald
Bug 1556993 fixed the crash in PoisonIOInterposer (due to missing stdout&stderr
fd's), bug 1559379 fixed the mozglue memory issue that the unit test
experienced, and this patch also includes a fix for the test failure in
browser_checkdllblockliststate.js.

So now Base Profiler can be enabled by default on Windows, still using
`MOZ_BASE_PROFILER_...` env-vars for now (upcoming bug will merge these with
non-BASE env-vars soon).

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

--HG--
extra : moz-landing-system : lando
2019-09-03 23:27:46 +00:00
Gerald Squelart 2c3f65a2cf Bug 1577650 - Stop using `using namespace std` in Gecko Profiler - r=canaltinova
Differential Revision: https://phabricator.services.mozilla.com/D44076

--HG--
extra : moz-landing-system : lando
2019-08-30 09:40:30 +00:00
Gerald Squelart ecb1dfd838 Bug 1575453 - Collect stats for sampling, and markers (add, collect, expire) - r=gregtatum
Use AUTO_PROFILER_STATS in both profilers, in:
- SamplerThread::Run() calling DoPeriodicSample()
- racy_profiler_add_marker
- ProfileBuffer::DeleteExpiredStoredMarkers()

This should cover all areas affected by the upcoming changes to the
ProfileBuffer storage, and how markers are stored.

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

--HG--
extra : moz-landing-system : lando
2019-08-22 01:01:25 +00:00
Gerald Squelart 74485a5d46 Bug 1575453 - AUTO_PROFILER_STATS (off by default) - r=gregtatum
AUTO_PROFILER_STATS(name) can be used to time a {block}.
Statistics are gathered in a function-static variable, and printf'd when the
program ends.

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

--HG--
extra : moz-landing-system : lando
2019-08-22 00:33:11 +00:00
Gerald Squelart 608cb489b5 Bug 1575442 - BlocksRingBuffer::LockAndRun - r=gregtatum
Some users will want to lock the buffer but not do any specific operation with
it.

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

--HG--
extra : moz-landing-system : lando
2019-08-22 00:32:51 +00:00
Gerald Squelart f908211695 Bug 1575141 - BlocksRingBuffer::{S,Des}erializer<BlocksRingBuffer> - r=gregtatum
Backtraces (that are kept in some marker payloads) are stored in a small
ProfileBuffer, we will need to store that data, which will happen to be inside
a BlockRingBuffer, so BlockRingBuffer needs to be able to (de)serialize itself!

This is done by storing the contents in the active buffer range, and some extra
data, to later reconstruct a BlocksRingBuffer that looks like the original.

Depends on D42496

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

--HG--
extra : moz-landing-system : lando
2019-08-20 21:33:52 +00:00
Gerald Squelart 87c8e35964 Bug 1574896 - BlocksRingBuffer de/serialization methods and helpers - r=gregtatum
Markers and their payloads contain all kinds of objects that we'll need to
serialize into a BlocksRingBuffer (new ProfileBuffer storage).

This patch will add functions to:
- Compute the size needed to store objects,
- Write multiple objects into a BlockRingBuffer entry,
- Read objects back from an entry.

And it will provide a number of useful de/serialization helpers for:
- Trivially-copyable objects,
- Strings of different types,
- Raw pointers (with some safety guards to avoid surprises),
- Tuples (to store multiple sub-objects),
- Spans,
- Maybe (for optional objects),
- Variant.

This should be enough to store most kinds of data. Further specializations
can&will be written as necessary for more complex or obscure types.

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

--HG--
extra : moz-landing-system : lando
2019-08-20 22:39:12 +00:00
Gerald Squelart a07a9b2250 Bug 1574825 - Make ModuloBuffer::Iterator a proper random-access iterator - r=gregtatum
This allows its use in std algorithms and types that require a real iterator
(like `template <typename InputIt> std::string::string(InputIt, InputIt)`).

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

--HG--
extra : moz-landing-system : lando
2019-08-20 12:51:31 +00:00
Gerald Squelart ed60590cee Bug 1574824 - BlocksRingBuffer:SizeOf{Ex,In}cludingThis - r=gregtatum
Differential Revision: https://phabricator.services.mozilla.com/D42451

--HG--
extra : moz-landing-system : lando
2019-08-20 12:49:50 +00:00
Gerald Squelart 0a514cb1ca Bug 1574824 - ModuloBuffer:SizeOf{Ex,In}cludingThis - r=gregtatum
Differential Revision: https://phabricator.services.mozilla.com/D42450

--HG--
extra : moz-landing-system : lando
2019-08-20 12:49:32 +00:00
Gerald Squelart 50443e7037 Bug 1574822 - BlocksRingBuffer::Reader::At() - r=gregtatum
`Reader::At()` can be used to get a `BlockIterator` at a given `BlockIndex`,
clamped between `begin()` and `end()`.

This will be useful when we want to iterate starting at a given index, e.g.,
when duplicating stacks.

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

--HG--
extra : moz-landing-system : lando
2019-08-20 14:26:07 +00:00
Gerald Squelart 16f6820be1 Bug 1569871 - MOZ_PROFILER_STARTUP set to ''/'0'/'N'/'n' does not start the profiler - r=canaltinova
(Also MOZ_BASE_PROFILER_STARTUP.)

This makes it easier to keep that variable setup in the environment, and change
its value to switch between enabling and disabling the profiler.

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

--HG--
extra : moz-landing-system : lando
2019-08-19 08:36:28 +00:00
Nazım Can Altınova a35427a236 Bug 1574187 - Stabilize profilerOverhead data in profile json. r=gerald
Depends on D42285

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

--HG--
extra : moz-landing-system : lando
2019-08-16 12:18:01 +00:00
Nazım Can Altınova 6eb786c0d4 Bug 1574187 - Add a samples object that contains all the samples in profilerOverhead. r=gerald
Differential Revision: https://phabricator.services.mozilla.com/D42285

--HG--
extra : moz-landing-system : lando
2019-08-16 12:17:29 +00:00
Gerald Squelart e99e0cc6db Bug 1574143 - Make BlocksRingBuffer::Reader RAII - r=gregtatum
In practice the Reader doesn't need to be copied/moved/reassign.
BlocksRingBuffer::Read() can just instantiate one on the stack, and pass it by
reference to callbacks.

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

--HG--
extra : moz-landing-system : lando
2019-08-16 03:55:08 +00:00
Gerald Squelart ac3d39c7f3 Bug 1574143 - Remove BlocksRingBuffer::EntryReserver - r=gregtatum
The point of the EntryReserver was mainly to have an object that represented a
writing lock on BlocksRingBuffer, so potentially perform multiple consecutive
writes.
After some experience implementing bug 1562604, there's actually no need for it.

So instead of having `Put()` create an `EntryReserver`, we now have
`ReserveAndPut()` that does the whole work in one function.

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

--HG--
extra : moz-landing-system : lando
2019-08-16 03:54:49 +00:00
Gerald Squelart 11b3a5f66e Bug 1574143 - Make BlocksRingBuffer::EntryWriter RAII - r=gregtatum
EntryWriter doesn't even need to be moveable, as BlocksRingBuffer can just
create one on the stack, and pass it by reference to callbacks.
This removes risks, and potential data copies.

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

--HG--
extra : moz-landing-system : lando
2019-08-16 04:02:18 +00:00
Makoto Kato c4cb964c8e Bug 1572613 - Use frame pointer based stack walker even if Android/x86 and Android/x86-64. r=jseward
Actually, we use clang for all Linux and Android platform, so it is no reason to use frame pointer based stack walker for LUL on Android/x86 and Android/x86-64 if no DWARF rule.

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

--HG--
extra : moz-landing-system : lando
2019-08-13 07:34:29 +00:00
Gerald Squelart 86c0b62678 Bug 1573111 - BlocksRingBuffer can switch underlying buffer - r=gregtatum
`BlocksRingBuffer` will be used both inside and outside `ProfileBuffer`:
- Inside to serve as `ProfileBuffer`'s main storage for stack traces,
- Outside to allow marker storage even when `ProfileBuffer` is locked during
  stack sampling.

`ProfileBuffer` only exists while `ActivePS` is alive, but because of the
potential outside accesses above (due to small races between ProfileBuffer
shutdown, and thread-local IsBeingProfiled() flags), we cannot just do the same
for BlocksRingBuffer, and it must remain alive to gracefully deny these accesses
around the profiler startup and shutdown times.

To accomplish this, `BlocksRingBuffer` may be in different states:
- "In-session", we have a real buffer to write to and read from,
- "Out-of-session", without buffer so reads&writes do nothing.
This is implemented by enclosing the underlying `ModuloBuffer` and the entry
deleter in a `Maybe`, which may be `Nothing` when the profiler is not running
and the `ProfileBuffer`'s `BlocksRingBuffer` is out-of-session.

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

--HG--
extra : moz-landing-system : lando
2019-08-13 12:06:40 +00:00
Brindusan Cristian a8a9f04996 Backed out changeset 58dd47c5aa51 (bug 1573111) for build bustages at TestBaseProfiler.cpp:875:51. CLOSED TREE 2019-08-13 06:21:16 +03:00
Gerald Squelart b2274966d4 Bug 1573111 - BlocksRingBuffer can switch underlying buffer - r=gregtatum
`BlocksRingBuffer` will be used both inside and outside `ProfileBuffer`:
- Inside to serve as `ProfileBuffer`'s main storage for stack traces,
- Outside to allow marker storage even when `ProfileBuffer` is locked during
  stack sampling.

`ProfileBuffer` only exists while `ActivePS` is alive, but because of the
potential outside accesses above (due to small races between ProfileBuffer
shutdown, and thread-local IsBeingProfiled() flags), we cannot just do the same
for BlocksRingBuffer, and it must remain alive to gracefully deny these accesses
around the profiler startup and shutdown times.

To accomplish this, `BlocksRingBuffer` may be in different states:
- "In-session", we have a real buffer to write to and read from,
- "Out-of-session", without buffer so reads&writes do nothing.
This is implemented by enclosing the underlying `ModuloBuffer` and the entry
deleter in a `Maybe`, which may be `Nothing` when the profiler is not running
and the `ProfileBuffer`'s `BlocksRingBuffer` is out-of-session.

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

--HG--
extra : moz-landing-system : lando
2019-08-13 03:11:53 +00:00
Gerald Squelart 41c580344f Bug 1572027 - Make BlocksRingBuffer::EntryReader move-only - r=gregtatum
After some bad experiences, I think EntryReader should be move-only:
- It needs to be moveable so it can be created from a function, and move-
  constructed into a Maybe<> if needed.
- It can be passed around as a reference.

Previously, it could be passed by value, but it was too easy to create bugs,
e.g.: A function delegates to a sub-function to read something at the beginning,
then the first function wants to read more past that, but if the reader was
passed by value the first function would not see past what the sub-function did
read.

As a bonus, `mRing` can now be a reference instead of a pointer, and other
members can be const.

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

--HG--
extra : moz-landing-system : lando
2019-08-07 21:33:09 +00:00
Gerald Squelart 5d6dbb3289 Bug 1571392 - Make BlocksRingBuffer::EntryWriter move-only - r=gregtatum
It makes little sense to copy a writer (also an output iterator).

We're keeping it move-constructible (so it can be passed around for construction
purposes), but not move-assignable to help make more members `const`.

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

--HG--
extra : moz-landing-system : lando
2019-08-07 01:54:45 +00:00
Gerald Squelart c05de0f147 Bug 1571390 - BlocksRingBuffer::GetState() takes a snapshot of the current state - r=gregtatum
This makes it easier to grab all BlocksRingBuffer state variables:
- Range start and end.
- Number of pushed blocks/entries, number of cleared blocks/entries.

The function is thread-safe, and the returned values are consistent with each
other, but they may become stale straight after the function returns (and the
lock is released).
They are still valuable to statistics, and to know how far the range has at
least reached (but may go further soon).

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

--HG--
extra : moz-landing-system : lando
2019-08-07 01:54:31 +00:00
Gerald Squelart f2af619bd3 Bug 1571355 - Base Profiler mutex tweaks - r=gregtatum
Renamed `BPAutoLock` to `BaseProfilerAutoLock`.
DEBUG-build `~BaseProfilerMutex()` checks that it is unlocked.
Prevent `BaseProfilerMutex` and `BaseProfilerAutoLock` copies&moves.
DEBUG-build check that `Lock()` sees `mOwningThreadId`==0 (because that is the
initial value, and the value after a previous `Unlock()`).
Don't preserve atomic `mOwningThreadId` in JS recording.

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

--HG--
extra : moz-landing-system : lando
2019-08-07 01:54:09 +00:00
Gerald Squelart a2e0f9390e Bug 1571348 - ProfilerMarkerPayload::Set...() can be replaced with constructor arguments - r=gregtatum
`ProfilerMarkerPayload::Set...()` functions are only used by derived classes in
the same files, and these values could just be set during construction.

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

--HG--
extra : moz-landing-system : lando
2019-08-07 01:53:55 +00:00
Greg Tatum cf59c7c0d7 Bug 1521929 - Remove RSS and USS measurements from the profiler; r=gerald,mixedpuppy
Differential Revision: https://phabricator.services.mozilla.com/D40287

--HG--
extra : moz-landing-system : lando
2019-08-05 15:37:18 +00:00
Sylvestre Ledru a34ae8d650 Bug 1571292 - -Wbool-operation: fix a warning (! instead of ~) r=gerald
Differential Revision: https://phabricator.services.mozilla.com/D40574

--HG--
extra : moz-landing-system : lando
2019-08-04 22:00:40 +00:00
Gerald Squelart ce889db273 Bug 1569515 - Collect overhead stats in ProfileBuffer - r=canaltinova
`ProfileBuffer` is now responsible for collecting overhead stats, and adding
them to the struct returned by `profiler_get_buffer_info()`.

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

--HG--
extra : moz-landing-system : lando
2019-07-31 01:28:51 +00:00
Gerald Squelart 68db1b82de Bug 1569506 - SamplerThread can own a Sampler instead of being one - r=canaltinova
`SamplerThread` inheriting from `Sampler` was a bit confusing, and scary with no
virtual destructor&functions.
`SamplerThread` only uses `Sampler`'s `Disable()` and
`SuspendAndSampleAndResumeThread()` functions, and `SamplerThread` is never
accessed through a `Sampler` reference/pointer.
So `SamplerThread` can just own a `Sampler` to make that relationship clearer.

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

--HG--
extra : moz-landing-system : lando
2019-07-31 01:28:49 +00:00
Gerald Squelart 6abdf8f681 Bug 1569458 - Use mMutex.AssertCurrentThreadOwns() in BlocksRingBuffer - r=gregtatum
This of course checks that the mutex is locked as expected in non-public APIs.
It also checks that user callbacks will not keep readers/writers longer than
they should.

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

--HG--
extra : moz-landing-system : lando
2019-07-30 12:19:55 +00:00
Gerald Squelart d5ac2c3154 Bug 1569458 - Unify Base Profiler mutexes into one class - r=gregtatum
`BaeProfilerMutex` is a concrete mutex based on MutexImpl, which was previously
implemented twice in both platform.h and BlocksRingBuffer.h.
This combined mutex has some DEBUG code (when MOZ_BASE_PROFILER is #defined) to
catch recursive locking, and to assert that the mutex is held (for code that
cannot easily use the "proof of lock" pattern; e.g., going through user-provided
callbacks).

This class needs to be public (because it is used in public headers), but is an
implementation detail, so it is located in a new header
"mozilla/BaseProfilerDetail.h" that will collect `mozilla::baseprofiler::detail`
code that may be useful to a few files in Base Profiler.

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

--HG--
extra : moz-landing-system : lando
2019-07-30 12:19:54 +00:00
Gerald Squelart ce8cf3d633 Bug 1567861 - Fix BlocksRingBuffer::ClearBefore() with past-the-end BlockIndex - r=gregtatum
`ClearBefore()` with a past-the-end `BlockIndex` was calling `Clear()`, which
tried to take the lock again! Also we didn't return after that.
Fixed, and added corresponding test.

Also: Removed ambiguous "delete" word, now using more precise "destroy" or
"entry destructor".

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

--HG--
extra : moz-landing-system : lando
2019-07-30 07:24:20 +00:00
Gerald Squelart f5ca1ba02d Bug 1567465 - Default BlockIndex used as empty value index before any valid entry - r=gregtatum
This is a similar concept as `nullptr` is to a pointer.

`BlocksRingBuffer` now skips the first byte in the buffer, so that no entries
start at 0 (the internal default `BlockIndex` value).
All `BlocksRingBuffer` public APIs handle this default value, and do nothing
and/or return Nothing (as if it pointed at an already-deleted entry).

Added tests for this, and for all BlockIndex operations.

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

--HG--
extra : moz-landing-system : lando
2019-07-19 16:10:30 +00:00
Gerald Squelart dd5708c6dc Bug 1567461 - Ensure ModuloBuffer can be properly move-constructed - r=gregtatum
Without declaring them, ModuloBuffer had its copy&move constructor&assignments
defaulted. This means it could have been copied, and then both objects would now
own the same resource and attempt to free it on destruction!

So now:
- Copy construction&assignment are now explicitly disallowed.
- Move assignment is disallowed, to keep some members `const`.
- Move construction is allowed (so a function can return a ModuloBuffer), and
  ensures that the moved-from object won't free the resource anymore.

Bonus: `mBuffer` is now `const`, to ensure that it cannot point at something
else, but note the pointed-at bytes are *not* const.
So ModuloBuffer is like an unchanging resource, but it allows to be moved-from
as an xvalue that should not be used after the move.

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

--HG--
extra : moz-landing-system : lando
2019-07-20 00:13:59 +00:00
Gerald Squelart 6ea0a33e9a Bug 1566706 - ModuloBuffer and BlocksRingBuffer can be given a external underlying buffer - r=gregtatum
By default `ModuloBuffer` allocates its own buffer on the heap.
Now `ModuloBuffer` adds two alternatives:
- Take ownership of a pre-allocated `UniquePtr<uint8_t>` buffer.
- Work over an unowned `uint8_t*` array. The caller is responsible for
  ownership, and ensuring that the array lives at least as long as the
  `ModuloBuffer`/`BlocksRingBuffer`.

`BlocksRingBuffer` can pass along these new options to its underlying
`ModuloBuffer`.

The main use will be for small on-stack `BlocksRingBuffer` that can store a
stack trace, or to more easily collect data (without allocating anything on the
heap) that can then go into the upcoming `ProfileBuffer`'s `BlocksRingBuffer`.

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

--HG--
extra : moz-landing-system : lando
2019-07-19 00:56:18 +00:00
Gerald Squelart 2af2523782 Bug 1565137 - BlocksRingBuffer is a thread-safe variable-sized circular buffer - r=gregtatum
This adds to the byte-oriented ModuloBuffer from bug 1563425:
- Thread-safety: All APIs may be called at any time from any thread.
- Structure: The buffer will be divided in "blocks" of different size, with some
  block meta-data and space for the user "entry".
- Capable of handling user resources: The user may provide a "deleter" that will
  be informed about soon-to-be-destroyed entries; so if some entries reference
  outside resources, these references may be properly released.

Note: This first implementation still only allows the user to manipulate bytes
and trivially-copyable objects (same as with the ModuloBuffer iterators). A
follow-up bug will introduce better serialization capabilities, with the aim to
eventually store everything that current Profiler Markers and their payloads
contain.

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

--HG--
extra : moz-landing-system : lando
2019-07-16 07:57:24 +00:00
Sylvestre Ledru ddf2513ea7 Bug 1519636 - Ride along: Move to the unix CR type r=Ehsan
# ignore-this-changeset

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

--HG--
extra : moz-landing-system : lando
2019-07-16 07:34:18 +00:00
Razvan Maries 76724ce338 Backed out changeset 1ccaad832c1d (bug 1557564) for causing bug 1531789. 2019-07-10 13:19:27 +03:00
Gerald Squelart 20f9546725 Bug 1563425 - ModuloBuffer is a basic circular byte buffer with iterator and LEB128 helpers - r=gregtatum
Basic usage:
- Create buffer: `ModuloBuffer mb(PowerOfTwo);`
- Get iterator: `auto writer = mb.WriterAt(Index);` (or `ReaderAt()`)
- Basic iterator functions on bytes: `*++writer = 'x';`
- Write: `writer.WriteULEB128(sizeof(int)); writer.WriteObject<int>(42);`
- Comparisons, move: `while (writer > reader) { --writer; }`
- Read: `size_t s = reader.ReadULEB128<size_t>(); int i = ReadObject<int>();`

There are no safety checks, it will be up to the caller to ensure thread-safety,
and data safety when wrapping around the buffer.

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

--HG--
extra : moz-landing-system : lando
2019-07-09 04:46:19 +00:00
Gerald Squelart 82b21811d2 Bug 1557564 - Enable Base Profiler in Windows - r=florian
Bug 1556993 fixed the crash in PoisonIOInterposer (due to missing stdout&stderr
fd's), and bug 1559379 fixed the mozglue memory issue that the unit test
experienced.
So now Base Profiler can be enabled by default on Windows, still using
`MOZ_BASE_PROFILER_...` env-vars for now (upcoming bug will merge these with
non-BASE env-vars soon).

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

--HG--
extra : moz-landing-system : lando
2019-07-09 08:09:14 +00:00
Gerald Squelart 58334f8543 Bug 1559000 - Enable/disable mozglue's AutoProfilerLabel when Base Profiler starts/stops - r=mstange
Now that Gecko Profiler only registers its entry&exit functions when running,
and it ensures that Base Profiler is stopped beforehand, Base Profiler can now
register its own entry&exit functions to capture labels before xpcom starts.

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

--HG--
extra : moz-landing-system : lando
2019-07-04 04:39:08 +00:00
Gerald Squelart e610854d8e Bug 1562606 - Implement unsigned LEB128 functions working over iterators - r=gregtatum
The new ProfileBuffer data structure will need to store block sizes (usually
small, LEB128 uses fewer bytes for small numbers), and the circular buffer will
provide iterators that hide the wrapping-around.

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

--HG--
extra : moz-landing-system : lando
2019-07-03 14:49:10 +00:00
Markus Stange 053b6b369b Bug 1557789 - Expose subcategory information in the profile JSON. r=njn
This was reviewed before in bug 1500692.

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

--HG--
extra : moz-landing-system : lando
2019-07-02 17:27:13 +00:00
Greg Tatum bbec67e8f2 Bug 1545582 - Integrate JavaScript memory allocation tracking to the profiler; r=canaltinova
Differential Revision: https://phabricator.services.mozilla.com/D34543

--HG--
extra : moz-landing-system : lando
2019-07-01 21:53:11 +00:00
Julien Wajsberg 319394f539 Bug 1561881 - Always capture the memory counters when profiling r=gerald
Differential Revision: https://phabricator.services.mozilla.com/D36186

--HG--
extra : moz-landing-system : lando
2019-06-27 14:02:30 +00:00
Gerald Squelart b13eeec2e9 Bug 1552063 - Use PowerOfTwo and PowerOfTwoMask in profilers - r=gregtatum
PowerOfTwo makes for a cleaner and more expressive interface, showing that the
profiler will use a power-of-2 storage size.

Using PowerOfTwoMask in ProfilerBuffer also makes it more obvious that we want
cheap modulo operations.
And we don't need to keep the original capacity, as it's only used once and can
easily be recomputed from the mask.

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

--HG--
extra : moz-landing-system : lando
2019-06-28 07:12:57 +00:00