Commit Graph

7026 Commits

Author SHA1 Message Date
Anmol Agarwal
d6766388f1 Bug 1554657 - Add a verbose mode to |mach lint| to display log output r=ahal
Differential Revision: https://phabricator.services.mozilla.com/D43507

--HG--
extra : moz-landing-system : lando
2019-09-23 13:19:25 +00:00
Jesse Schwartzentruber
146562d993 Bug 1581158 - Add fuzzing target for rkv r=froydnj
Differential Revision: https://phabricator.services.mozilla.com/D45891

--HG--
rename : tools/fuzzing/moz.build => tools/fuzzing/rust/moz.build
extra : moz-landing-system : lando
2019-09-20 21:27:35 +00:00
Ted Campbell
62565b25fc Bug 1578730 - Add js::GetCodeCovergeSummaryAll API. r=nbp,marco
Split the GetCodeCoverageSummary API into a variant for a specific realm
vs checking all realms. This restores the original behaviour of the
getLcovInfo testing function to only return info on current realm. This
makes testing OOM behaviour much more predictable.

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

--HG--
extra : moz-landing-system : lando
2019-09-19 00:08:39 +00:00
Andrew Halberstadt
885bdd32e7 Bug 1580280 - [lint] Support Python 3 in other lint integrations r=sylvestre
Differential Revision: https://phabricator.services.mozilla.com/D45440

--HG--
extra : moz-landing-system : lando
2019-09-18 21:11:02 +00:00
Andrew Halberstadt
795035dba3 Bug 1580280 - [lint] Support Python 3 in the wpt integration r=jgraham
Differential Revision: https://phabricator.services.mozilla.com/D45439

--HG--
extra : moz-landing-system : lando
2019-09-19 00:34:48 +00:00
Andi-Bogdan Postelnicu
f26c05d126 Bug 1581846 - mark some Coverity checkers as disabled since their results yiled to be false-positive. r=bastien
Differential Revision: https://phabricator.services.mozilla.com/D46151

--HG--
extra : moz-landing-system : lando
2019-09-19 03:57:34 +00:00
Greg Tatum
1700229ac1 Bug 1564475 - Add a native allocation profiling test; r=canaltinova
Differential Revision: https://phabricator.services.mozilla.com/D42198

--HG--
extra : moz-landing-system : lando
2019-09-18 18:47:03 +00:00
Greg Tatum
b534604d61 Bug 1564475 - Only turn on the native allocation tracking with a profiler feature; r=njn
The code changes to use a profiler feature for the native allocations were deferred
until this commit.

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

--HG--
extra : moz-landing-system : lando
2019-09-18 18:46:39 +00:00
Greg Tatum
1738125fb6 Bug 1564475 - Add a mechanism to collect profiler backtraces; r=njn,gerald
The profiler backtraces inside a memory hook are re-entrant for the
profile lock. This patch adds additional guards to protect against this
in order to allow for a profiler backtrace during native allocations.

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

--HG--
extra : moz-landing-system : lando
2019-09-18 18:46:19 +00:00
Greg Tatum
7da1f1429c Bug 1564475 - Disable native allocations when the bloat log is turned on; r=njn
There is a bad interaction between the bloat log and the native allocation
tracking. There is a detailed message explaining the problem in the code.

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

--HG--
extra : moz-landing-system : lando
2019-09-18 18:46:06 +00:00
Greg Tatum
4aa10db6ce Bug 1564475 - Add the ability to collect markers with a Bernoulli trial; r=njn
This commit adds both the native allocation marker, and the Bernoulli
trial to attempt to sample the native allocations.

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

--HG--
extra : moz-landing-system : lando
2019-09-18 18:45:57 +00:00
Greg Tatum
5b4a05cfdf Bug 1564475 - Add a mechanism to block re-entry on profiler memory hooks; r=njn
This commit adds a ThreadIntercept mechanism to block re-entry when
attempting to collect the stacks of native allocations.
A following commit will actually hook them up to collect allocations.

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

--HG--
extra : moz-landing-system : lando
2019-09-18 18:45:48 +00:00
Greg Tatum
8340186c94 Bug 1564475 - Remove lock failure when removing the profiler counters; r=jesup
The ProfilerCounters had a static lifetime controlled by a UniquePtr. This
is an issue if the profiler mutex, which is also static, gets destroyed
first. The counters will then try to access the profiler mutex, and find
it already destroyed, leading to a crash. This commit changes the life
cycle to explicitly leak the counters for the lifteime of the process.

In addition, this patch adds explicit install and removal functions for
the memory hooks.

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

--HG--
extra : moz-landing-system : lando
2019-09-18 18:45:44 +00:00
Mark Hammond
140dc3f765 Bug 1578217 - remove the sync 'yellow state' telemetry. r=tcsc
Differential Revision: https://phabricator.services.mozilla.com/D45765

--HG--
extra : moz-landing-system : lando
2019-09-19 00:34:04 +00:00
Bas Schouten
53993c8cdf Bug 1581427: Define UniqueProfilerBacktrace and profiler_get_backtrace() to be no-ops on a build without profiling. r=njn
Differential Revision: https://phabricator.services.mozilla.com/D46090

--HG--
extra : moz-landing-system : lando
2019-09-18 12:38:52 +00:00
Gerald Squelart
2402857f3f Bug 1581049 - Use AutoCStrings in StreamSamplesToJSON to avoid mallocs - r=gregtatum
Profiling the profiler showed a lot of time spent allocating memory for the
frame-address strings, almost half the time of `StreamSamplesToJSON`!
Using an "Auto" string will prevent these allocations in most cases.

Also removed the `printf("0x%llx")`, instead just appending "0x" and an hex-
formatted number with `AppendInt()` (which handles 32- and 64-bit numbers
separately, so there is no more needs to do a double-cast to avoid sign
extensions -- There is still a double cast, but a no-op one to fix the type to
either `uint32_t` or `uint64_t`).

Using an Auto string for nearby frame labels as well.

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

--HG--
extra : moz-landing-system : lando
2019-09-18 01:23:12 +00:00
Gerald Squelart
b5d3f932a0 Bug 1581049 - Gather stack sample data into fewer entries - r=gregtatum
Stack samples may contain up to hundreds or thousands of entries, which need to
be copied (during sampling and duplicating), and also mostly skipped when
creating the JSON output for other threads or other types of profile data.

This patch gathers all sample legacy entries (apart from the thread id and the
timestamp) into a single non-legacy entry, which is much faster to copy or
skip. The preceding timestamp now has a distinct Kind (`TimeBeforeCompactStack`)
to know whether to handle legacy entries of the new `CompactStack` entry kind.

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

--HG--
extra : moz-landing-system : lando
2019-09-18 01:23:00 +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
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
Andrew Halberstadt
93128f0dc2 Bug 1576812 - [tryselect] Re-order header shortcuts in an order that makes more sense (given they don't all fit), r=iain
Differential Revision: https://phabricator.services.mozilla.com/D46181

--HG--
extra : moz-landing-system : lando
2019-09-17 18:56:25 +00:00
Andrew Halberstadt
dcbb6094c1 Bug 1576812 - [tryselect] Increase width of fzf preview pane in |mach try fuzzy| r=gbrown
Depends on D44911

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

--HG--
extra : moz-landing-system : lando
2019-09-06 14:59:54 +00:00
Andrew Halberstadt
1719cc129d Bug 1576812 - [tryselect] Improve mach try fuzzy documentation r=iain
Differential Revision: https://phabricator.services.mozilla.com/D44911

--HG--
extra : moz-landing-system : lando
2019-09-17 16:32:40 +00:00
Julian Descottes
c56df517ed Bug 1578468 - Skip fission mochitests and sw-e10s xpcshell tests for DevTools try presets r=ochameau
Depends on D45843

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

--HG--
extra : moz-landing-system : lando
2019-09-17 09:08:59 +00:00
Julian Descottes
0521d90c71 Bug 1578468 - Add devtools-linux preset r=ochameau
Differential Revision: https://phabricator.services.mozilla.com/D45843

--HG--
extra : moz-landing-system : lando
2019-09-16 07:08:35 +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
060b8c8c50 Bug 1581049 - Use AutoCStrings in StreamSamplesToJSON to avoid mallocs - r=gregtatum
Profiling the profiler showed a lot of time spent allocating memory for the
frame-address strings, almost half the time of `StreamSamplesToJSON`!
Using an "Auto" string will prevent these allocations in most cases.

Also removed the `printf("0x%llx")`, instead just appending "0x" and an hex-
formatted number with `AppendInt()` (which handles 32- and 64-bit numbers
separately, so there is no more needs to do a double-cast to avoid sign
extensions -- There is still a double cast, but a no-op one to fix the type to
either `uint32_t` or `uint64_t`).

Using an Auto string for nearby frame labels as well.

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

--HG--
extra : moz-landing-system : lando
2019-09-17 01:54:50 +00:00
Gerald Squelart
5172b40969 Bug 1581049 - Gather stack sample data into fewer entries - r=gregtatum
Stack samples may contain up to hundreds or thousands of entries, which need to
be copied (during sampling and duplicating), and also mostly skipped when
creating the JSON output for other threads or other types of profile data.

This patch gathers all sample legacy entries (apart from the thread id and the
timestamp) into a single non-legacy entry, which is much faster to copy or
skip. The preceding timestamp now has a distinct Kind (`TimeBeforeCompactStack`)
to know whether to handle legacy entries of the new `CompactStack` entry kind.

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

--HG--
extra : moz-landing-system : lando
2019-09-17 01:54:37 +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
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