Commit Graph

1326 Commits

Author SHA1 Message Date
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
4b285f78a5 Bug 1576554 - Test baseprofiler::profiler_get_backtrace - r=gregtatum
Add basic testing of `profiler_get_backtrace` before working on serializing it.

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

--HG--
extra : moz-landing-system : lando
2019-09-17 01:50:49 +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
Aaron Klotz
deaaaa9bbb Bug 1580293: Ensure that parameter packs in mozglue/misc are expanded as rvalue references; r=mhowell
Differential Revision: https://phabricator.services.mozilla.com/D45429

--HG--
extra : moz-landing-system : lando
2019-09-10 19:55:44 +00:00
Mike Shal
f8f5fce637 Bug 1496746 - Remove VPATH; r=glandium
Having a full VPATH for the srcdir sometimes causes make to grab the
wrong prerequisite for a rule, in particular if we have a file in the
srcdir and also generate a file of the same name in the objdir. We don't
really need VPATH anymore though, since most of the information comes
from mozbuild, where we can explicitly list the path to the srcdir or
objdir as necessary.

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

--HG--
extra : moz-landing-system : lando
2019-09-09 17:44:47 +00:00
Toshihito Kikuchi
18aab300b5 Bug 1576697 - Use LauncherResult in WinHeaderOnlyUtils.h instead of WindowsErrorResult. r=aklotz
`WindowsErrorResult` is a class to hold either a value or a Windows error
code based on the `Result` template.  We also have `LauncherResult` for the
same purpose, which was introduced as a part of the launcher process feature
afterward.  The difference is `LauncherResult` holds a filename and line
number along with an error code.

This patch integrates LauncherResult.h into WinHeaderOnlyUtils.h so that we
can use `LauncherResult` more broadly.

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

--HG--
extra : moz-landing-system : lando
2019-09-07 18:17:45 +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
Sylvestre Ledru
36129ce948 Bug 1577236 - clang-10: Fix -Wimplicit-int-float-conversion warnings in various dirs r=glandium
Depends on D43784

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

--HG--
extra : moz-landing-system : lando
2019-08-30 09:11:19 +00:00
Cameron McCormack
a1e18da1b1 Bug 1573090 - Part 2: Look up ELF symbol tables directly when pre-symbolicating Gecko profiles on Linux. r=gerald
Whereas previously MozDescribeCodeAddress would have handled demangling,
we need to explicitly do that from our new GetFunction method.  The string we
generate is now more useful for the profiler to merge -- having dropped the
address in the previous patch, and the file & line number and library in this
patch.

While we're at it, try to demangle Rust symbols too.

Ideally we'd add Rust symbol handling to DemangleSymbol in
StackWalk.cpp, but that lives in mozglue, which currently cannot have
any Rust crate dependencies.

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

--HG--
extra : moz-landing-system : lando
2019-08-23 05:45:16 +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
Cameron Kaiser
efe5f0901c Bug 1571613 - basic support for Power ISA SIMD detection (v2). r=glandium
Differential Revision: https://phabricator.services.mozilla.com/D42592

--HG--
extra : moz-landing-system : lando
2019-08-21 03:36:55 +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
46f5e181ee Bug 1574821 - TestBaseProfiler generates more labels and markers - r=gregtatum
The main goal of these bugs is to move markers to a new storage, so I'm adding
lots of markers to TestBaseProfiler.
Also adding labels, easier to read unsymbolicated profiles, and gives a bit more
coverage too.
And adding a separate "fibonacci canceller" thread, which is needed on some
slower platforms (e.g., Linux 64 ASAN times out otherwise); as a bonus, this
tests AUTO_BASE_PROFILER_REGISTER_THREAD.

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

--HG--
extra : moz-landing-system : lando
2019-08-20 03:29:53 +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
Aaron Klotz
a69086ea54 Bug 1573273: Add ProfilerLabelBegin and ProfilerLabelEnd to mozglue; r=gerald
While mozglue continues to be the correct location for calling the affected
code in this patch, the calls requiring profiler labels will soon be
originating from firefox.exe via the launcher process.

mozglue will be supplying the launcher process with an interface that consists
of what are effectively "OnBeginDllLoad" and "OnEndDllLoad" callback
notifications; obviously an RAII class is not going to be useful for that case.

We still want to keep the RAII stuff around, however, since we still need it
for cases where we need to fall back to using the legacy DLL blocklist.

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

--HG--
extra : moz-landing-system : lando
2019-08-14 03:46:41 +00:00
Aaron Klotz
6e2191877a Bug 1573274: Add mozglue-only SuppressStackWalking and DesuppressStackWalking functions to StackWalk on Windows; r=glandium
While mozglue continues to be the correct location for calling the affected
code in this patch, the calls requiring stackwalk suppression will soon be
originating from firefox.exe via the launcher process.

mozglue will be supplying the launcher process with an interface that consists
of what are effectively "OnBeginDllLoad" and "OnEndDllLoad" callback
notifications; obviously an RAII class is not going to be useful for that case.

We still want to keep the RAII stuff around, however, since we still need it
for cases where we need to fall back to using the legacy DLL blocklist.

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

--HG--
extra : moz-landing-system : lando
2019-08-14 03:34:52 +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