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

9214 Коммитов

Автор SHA1 Сообщение Дата
Gerald Squelart 90bd552555 Bug 1716959 - Don't use lock from profiler_capture_backtrace_into - r=canaltinova
`profiler_capture_backtrace_into` now only uses thread-safe functions: ThreadRegistration::WithOnThreadRefOf, Register::SyncPopulate, DoSyncSample.
So we don't need to lock the main profiler mutex anymore.

This means that on-thread sampling (typically used in markers) can happen at the same time the periodic sampler has locked the profiler mutex and is sampling this and other threads.

Differential Revision: https://phabricator.services.mozilla.com/D122089
2021-08-25 00:56:01 +00:00
Gerald Squelart ca8279e285 Bug 1716959 - Remove compulsory proof-of-lock in DoNativeBacktrace and DoSyncSample - r=canaltinova
Since these functions don't need to access profiler functions requiring a lock, they themselves don't need that lock anymore.

Differential Revision: https://phabricator.services.mozilla.com/D122088
2021-08-25 00:56:00 +00:00
Gerald Squelart e8f70d8971 Bug 1716959 - On-thread sampling uses a per-thread JS frame buffer that's only allocated when there's also a JSContext - r=canaltinova
MergeStack requires a fairly large buffer to store JS frames, too big to be allocated on the stack without risking a stack overflow.
Until now, there was only one buffer, stored in CorePS, and only accessible while holding the Profiler gPSMutex.

Now each thread that has a JSContext, also has its own JS frame buffer, which is accessible on the thread without needing any lock.
The Profiler's Sampler still uses the CorePS buffer for its periodic sampling, but it won't prevent parallel on-thread sampling anymore.

The appropriate buffer is passed to ExtractJsFrames and then MergeStacks.
MergeStacks accepts a null pointer, which happens on threads where there is no JSContext, and therefore no JS to sample.

Differential Revision: https://phabricator.services.mozilla.com/D122087
2021-08-25 00:55:59 +00:00
Gerald Squelart 911112cf23 Bug 1716959 - Pass features to DoSharedSamples to remove lock-dependent feature requests - r=canaltinova
Differential Revision: https://phabricator.services.mozilla.com/D122086
2021-08-25 00:55:59 +00:00
Gerald Squelart e2e7d28006 Bug 1716959 - Lock is not needed anymore in DoNativeBacktrace - r=canaltinova
All implementations of DoNativeBacktrace are now thread-safe, so it's not necessary to make their use dependent on the Profiler's gPSMutex being locked.

Differential Revision: https://phabricator.services.mozilla.com/D122085
2021-08-25 00:55:59 +00:00
Gerald Squelart dae03065c6 Bug 1716959 - Make CorePS::mLul atomic, to avoid using the profiler lock to access it - r=canaltinova
Also added extra nullptr checks to avoid surprises if calling code ever tries to use lul before it's first set.

Differential Revision: https://phabricator.services.mozilla.com/D122084
2021-08-25 00:55:58 +00:00
Gerald Squelart 98cd735985 Bug 1716959 - Make Registers::SyncPopulate() re-entrant on Linux, for safe use in parallel stack unwinding calls - r=canaltinova
`Registers::SyncPopulate()` now uses a ucontext_t that's stored with the `Registers` object, so it can safely be called from parallel threads.

Differential Revision: https://phabricator.services.mozilla.com/D122083
2021-08-25 00:55:58 +00:00
criss ba3d35886e Backed out 7 changesets (bug 1716959) for causing Android build bustages. CLOSED TREE
Backed out changeset e6a849ee0e31 (bug 1716959)
Backed out changeset eb105787f5bd (bug 1716959)
Backed out changeset c39b9c1696aa (bug 1716959)
Backed out changeset ef79ed5f95c1 (bug 1716959)
Backed out changeset 7c84ffb63567 (bug 1716959)
Backed out changeset 2f97ef8a91de (bug 1716959)
Backed out changeset d5607038a5d6 (bug 1716959)
2021-08-25 02:16:26 +03:00
Gerald Squelart a2f14f5c02 Bug 1716959 - Don't use lock from profiler_capture_backtrace_into - r=canaltinova
`profiler_capture_backtrace_into` now only uses thread-safe functions: ThreadRegistration::WithOnThreadRefOf, Register::SyncPopulate, DoSyncSample.
So we don't need to lock the main profiler mutex anymore.

This means that on-thread sampling (typically used in markers) can happen at the same time the periodic sampler has locked the profiler mutex and is sampling this and other threads.

Differential Revision: https://phabricator.services.mozilla.com/D122089
2021-08-24 21:58:44 +00:00
Gerald Squelart a6575f5d1c Bug 1716959 - Remove compulsory proof-of-lock in DoNativeBacktrace and DoSyncSample - r=canaltinova
Since these functions don't need to access profiler functions requiring a lock, they themselves don't need that lock anymore.

Differential Revision: https://phabricator.services.mozilla.com/D122088
2021-08-24 21:58:44 +00:00
Gerald Squelart 2ab9046c97 Bug 1716959 - On-thread sampling uses a per-thread JS frame buffer that's only allocated when there's also a JSContext - r=canaltinova
MergeStack requires a fairly large buffer to store JS frames, too big to be allocated on the stack without risking a stack overflow.
Until now, there was only one buffer, stored in CorePS, and only accessible while holding the Profiler gPSMutex.

Now each thread that has a JSContext, also has its own JS frame buffer, which is accessible on the thread without needing any lock.
The Profiler's Sampler still uses the CorePS buffer for its periodic sampling, but it won't prevent parallel on-thread sampling anymore.

The appropriate buffer is passed to ExtractJsFrames and then MergeStacks.
MergeStacks accepts a null pointer, which happens on threads where there is no JSContext, and therefore no JS to sample.

Differential Revision: https://phabricator.services.mozilla.com/D122087
2021-08-24 21:58:43 +00:00
Gerald Squelart f82b0d2ff3 Bug 1716959 - Pass features to DoSharedSamples to remove lock-dependent feature requests - r=canaltinova
Differential Revision: https://phabricator.services.mozilla.com/D122086
2021-08-24 21:58:43 +00:00
Gerald Squelart b654d8d392 Bug 1716959 - Lock is not needed anymore in DoNativeBacktrace - r=canaltinova
All implementations of DoNativeBacktrace are now thread-safe, so it's not necessary to make their use dependent on the Profiler's gPSMutex being locked.

Differential Revision: https://phabricator.services.mozilla.com/D122085
2021-08-24 21:58:42 +00:00
Gerald Squelart 9964959d01 Bug 1716959 - Make CorePS::mLul atomic, to avoid using the profiler lock to access it - r=canaltinova
Also added extra nullptr checks to avoid surprises if calling code ever tries to use lul before it's first set.

Differential Revision: https://phabricator.services.mozilla.com/D122084
2021-08-24 21:58:42 +00:00
Gerald Squelart 0e09b66701 Bug 1716959 - Make Registers::SyncPopulate() re-entrant on Linux, for safe use in parallel stack unwinding calls - r=canaltinova
`Registers::SyncPopulate()` now uses a ucontext_t that's stored with the `Registers` object, so it can safely be called from parallel threads.

Differential Revision: https://phabricator.services.mozilla.com/D122083
2021-08-24 21:58:42 +00:00
Gerald Squelart 7f3c9eb118 Bug 1727036 - SpliceableJSONWriter::Time... functions output milliseconds with nanosecond precision - r=mstange
Instead of blindly outputting floating-point numbers of milliseconds, which leads to things like 363.03499999999997, times in ms are now converted to integer number of nanoseconds, stringified, and then manually adjusted to milliseconds again, so we get smaller and friendlier outputs like 363.035.

Eventually, bug 1726675 may change all times to integer number of nanoseconds anyway, but this patch is already helpful in reducing the output, and paves the way by separating the time-output functions from other number outputs.

Differential Revision: https://phabricator.services.mozilla.com/D123329
2021-08-24 21:33:05 +00:00
Alex Lopez 4ae24b1f1b Bug 1696251: Refactor docstrings in mach commands. r=mhentges,webdriver-reviewers,geckoview-reviewers,agi
The purpose of this is to remove as many docstrings from CommandProvider
classes to make the step of moving commands out of classes simpler.
Where possible, the docstring has been moved to or merged with the function.

Differential Revision: https://phabricator.services.mozilla.com/D123288
2021-08-24 20:16:05 +00:00
Nazım Can Altınova 1b232babba Bug 1727039 - Add two marker schema structs for Java markers to make them visible in the timeline r=gerald
Differential Revision: https://phabricator.services.mozilla.com/D123435
2021-08-24 13:24:06 +00:00
Gerald Squelart 9dabb52dbd Bug 1722261 - RegisteredThread is now effectively unused, remove all remaining traces - r=canaltinova
Differential Revision: https://phabricator.services.mozilla.com/D121978
2021-08-24 04:47:24 +00:00
Gerald Squelart 973ab36893 Bug 1722261 - Remove RegisteredThread from LiveProfiledThreadData - r=canaltinova
Differential Revision: https://phabricator.services.mozilla.com/D121977
2021-08-24 04:47:23 +00:00
Gerald Squelart cb43159ccf Bug 1722261 - SizeOf{Ex,In}cludingThis for ProfilerRegist* classes, used in CorePS - r=canaltinova
Differential Revision: https://phabricator.services.mozilla.com/D121976
2021-08-24 04:47:23 +00:00
Gerald Squelart ffaa46b8c5 Bug 1722261 - Stop using RegisteredThread::Info() in profiler_unregister_thread - r=canaltinova
And now in locked_unregister_thread, use the aOnThreadRef directly instead of the TLSRegisteredThread.

Differential Revision: https://phabricator.services.mozilla.com/D121975
2021-08-24 04:47:23 +00:00
Gerald Squelart e458356239 Bug 1722261 - Convert locked_profiler_stream_json_for_this_process and ActivePS::ProfiledThreads to stop using RegisteredThread - r=canaltinova
Remove now-unused RegisteredThread::GetJSContext().

Differential Revision: https://phabricator.services.mozilla.com/D121974
2021-08-24 04:47:22 +00:00
Gerald Squelart 7d5bfedffa Bug 1722261 - Convert remaining use of RegisteredThread's ProfilingStack that was in locked_register_thread - r=canaltinova
Differential Revision: https://phabricator.services.mozilla.com/D121973
2021-08-24 04:47:22 +00:00
Gerald Squelart 74c2f32d66 Bug 1722261 - Convert remaining uses of RegisteredThread's GetEventTarget and ResetMainThread - r=canaltinova
Differential Revision: https://phabricator.services.mozilla.com/D121971
2021-08-24 04:47:22 +00:00
Gerald Squelart a46f61bcac Bug 1722261 - In locked_profiler_start, find registered threads from ThreadRegistry and stop using RegisteredThread - r=canaltinova
Differential Revision: https://phabricator.services.mozilla.com/D121970
2021-08-24 04:47:21 +00:00
Gerald Squelart c5c886aafb Bug 1722261 - Remove final uses of {,Racy}RegisteredThread's ReinitializeOnResume, and all ...JSSampling's - r=canaltinova
Differential Revision: https://phabricator.services.mozilla.com/D121969
2021-08-24 04:47:21 +00:00
Gerald Squelart 5ffd2b28fc Bug 1722261 - Rework profiler_set/clear_js_context to use ThreadRegistration - r=canaltinova
Remove some now-unused functions.

Differential Revision: https://phabricator.services.mozilla.com/D121968
2021-08-24 04:47:20 +00:00
Gerald Squelart 9b7f9f3415 Bug 1722261 - In locked_profiler_stop, find live threads from ThreadRegistry and stop using RegisteredThread - r=canaltinova
Differential Revision: https://phabricator.services.mozilla.com/D121967
2021-08-24 04:47:20 +00:00
Gerald Squelart 0599f5dbbe Bug 1722261 - During sampling, go through the ThreadRegistry to find ThreadRegistrations with ProfiledThreadData - r=canaltinova
Differential Revision: https://phabricator.services.mozilla.com/D121966
2021-08-24 04:47:20 +00:00
Gerald Squelart 0a913f148b Bug 1722261 - Remove the old PlatformData, which is now unused - r=canaltinova
Differential Revision: https://phabricator.services.mozilla.com/D121965
2021-08-24 04:47:19 +00:00
Gerald Squelart aaf7249946 Bug 1722261 - Move mPreviousThreadRunningTimes from old PlatformData to ProfiledThreadData - r=canaltinova
It's more appropriate because the running times are only relevant to a profiling session.
And PreviousThreadRunningTimes can now be accessed through the ThreadRegistration (thanks to the ProfiledThreadData pointer added in the previous patch).

Since the threads' RunningTimes don't live in `PlatformData`, and because they are now implicitly cleared between profiling sessions (because `ProfiledThreadData`s get destroyed/recreated when stopping/starting the profiler), there is no need for an explicit `ClearRunningTimes()` anymore.

Differential Revision: https://phabricator.services.mozilla.com/D121964
2021-08-24 04:47:19 +00:00
Gerald Squelart dbec8fac3f Bug 1722261 - Store ProfiledThreadData pointer in ThreadRegistrationData - r=canaltinova
Because ProfiledThreadData is always related to IsBeingProfiled, they are set and cleared together.
In particular, this is used to quickly guess that the thread is being profiled by reading the non-atomic mProfiledThreadData, rather than reading the slightly slower atomic mIsBeingProfiled.

Differential Revision: https://phabricator.services.mozilla.com/D121963
2021-08-24 04:47:18 +00:00
Gerald Squelart 838c078dd5 Bug 1722261 - GetRunningEventDelay through ThreadRegistration - r=canaltinova
Differential Revision: https://phabricator.services.mozilla.com/D121962
2021-08-24 04:47:18 +00:00
Gerald Squelart 664a64ed66 Bug 1722261 - Use IsSleeping and SetSleeping/Awake in ThreadRegistration - r=canaltinova
Also moved profiler_thread_is_sleeping to ProfilerThreadState.h.

Differential Revision: https://phabricator.services.mozilla.com/D121961
2021-08-24 04:47:18 +00:00
Gerald Squelart 18dc921f8e Bug 1722261 - Use ThreadRegistration classes during sampling - r=canaltinova
Differential Revision: https://phabricator.services.mozilla.com/D121960
2021-08-24 04:47:17 +00:00
Gerald Squelart 3114b39b02 Bug 1722261 - ProfilerThreadPlatformData platform-specific implementation - r=canaltinova
This is mostly a copy of the old PlatformData. That old PlatformData will be removed in a later patch, once it's not used anymore.

Differential Revision: https://phabricator.services.mozilla.com/D121959
2021-08-24 04:47:17 +00:00
Gerald Squelart bbe9d3dc72 Bug 1722261 - Remove ThreadInfo.h, use ProfilerRegistrationInfo instead - r=canaltinova
Differential Revision: https://phabricator.services.mozilla.com/D121850
2021-08-24 04:47:16 +00:00
Gerald Squelart 661ef3e99d Bug 1722261 - Store {,Racy}RegisteredThread pointer in ThreadRegistrationData - r=canaltinova
This will help with replacing the old {,Racy}RegisteredThread with the new ThreadRegistration classes, while still being able to access the old classes (until they are not needed anymore).

Differential Revision: https://phabricator.services.mozilla.com/D121849
2021-08-24 04:47:16 +00:00
Gerald Squelart dec6c72992 Bug 1722261 - Move profiler_thread_is_being_profiled to ProfilerThreadState.h and use ThreadRegistration - r=canaltinova
Differential Revision: https://phabricator.services.mozilla.com/D121848
2021-08-24 04:47:16 +00:00
Gerald Squelart 27339446a1 Bug 1722261 - Remove data from RegisteredThread, only keep pass-through methods to the ThreadRegistrationData - r=canaltinova
Now {,Racy}RegisteredThread don't contain any data, but provide the same API that goes through ThreadRegistration.
Until they are removed, {,Racy}RegisteredThread are given private access to ThreadRegistration{,Data} for easier access.

This means that we can now change uses of RegisteredThread to use ThreadRegistration directly instead, and the data will be the same through either APIs.

Also, RacyRegisteredThread::ThreadId() was unused so it can be removed.

Differential Revision: https://phabricator.services.mozilla.com/D121847
2021-08-24 04:47:15 +00:00
Gerald Squelart 17c3deae20 Bug 1722261 - Use ProfilingStack inside ThreadRegistrationData - r=canaltinova
The ProfilingStack object inside ThreadRegistrationData is guaranteed to live while the thread is registered (and alive), and all accesses are guaranteed to be done either:
- On-thread, so during that time ThreadRegistrationData and its ProfilingStack cannot be destroyed.
- From another thread, but with the Profiler lock and/or per-thread lock, which also guarantees that ThreadRegistrationData and its ProfilingStack cannot be destroyed.

RacyRegisteredThread brought some doubts about end-of-thread accesses, that why there's was an intermediate ref-counted ProfilingStackOwner to keep ProfilingStack alive where needed. Now we can remove it.

Also the separate TLS (Thread Local Storage) for ProfilingStackOwner can be removed, since we can reach the ProfilingStack through the ThreadRegistration TLS for the same cost.

Differential Revision: https://phabricator.services.mozilla.com/D121846
2021-08-24 04:47:15 +00:00
Gerald Squelart 46ef60886c Bug 1722261 - Move profiler_is_active_and_thread_is_registered to ProfilerThreadState.h and use ThreadRegistration - r=canaltinova
ThreadRegistration already knows if it's registered, so profiler_is_active_and_thread_is_registered can use that now.

Differential Revision: https://phabricator.services.mozilla.com/D121845
2021-08-24 04:47:14 +00:00
Gerald Squelart 73145d4991 Bug 1722261 - Remove handling of nested RegisteredThreads - r=canaltinova
Since ThreadRegistration already handles nested registrations, the legacy profiler_{,un}register_thread() functions don't need to care about that anymore (and the RegisteredThread TLS will be removed in a later patch anyway).
The informational markers have been moved to ProfilerThreadRegistration.cpp.

Differential Revision: https://phabricator.services.mozilla.com/D122315
2021-08-24 04:47:13 +00:00
Gerald Squelart d4467b9f08 Bug 1722261 - Insert new ThreadRegistration (un)registering functions in the middle of profiler_{,un}register_thread - r=canaltinova
ProfilerThreadRegistry (un)register functions have been moved to platform.cpp because they need to interact closely with functions and classes in that file.

profiler_{,un}register_thread are now simple calls to ThreadRegistration::{R,Unr}egisterThread, which call ThreadRegistry::{R,Unr}egister, which now integrate that old bodies of profiler_{,un}register_thread.
So from this point, threads may use either profiler_{,un}register_thread or ThreadRegistration equivalents, and this will (un)register with both the new ThreadRegistration classes and the legacy RegisteredThread class into CorePS. (Later patches will remove RegisteredThread completely.)

Bonus: Since the stack top is now adjusted when constructing ThreadRegistrationInfo (before giving it to the legacy ThreadInfo), there is no more need for `GetStackTop()`.

Differential Revision: https://phabricator.services.mozilla.com/D121844
2021-08-24 04:47:13 +00:00
Gerald Squelart 72795c1eff Bug 1722261 - New header ProfilerThreadState.h will contain thread-related profiler APIs - r=canaltinova
Thread-related APIs that are currently in ProfilerState.h will move here, and will use the new ThreadRegistration classes introduced in bug 1721939.

In this patch the header is empty apart from a few #includes, and users of "ProfilerState.h"'s thread functions now #include "ProfilerThreadState.h" instead. So there are no actual code changes yet.

Differential Revision: https://phabricator.services.mozilla.com/D121843
2021-08-24 04:47:13 +00:00
Gerald Squelart 40c35fd0e2 Bug 1722261 - Keep track of whether a ThreadRegistration is on the heap - r=canaltinova
When a `ThreadRegistration` object is created through `ThreadRegistration::RegisterThread` (instead of directly on the stack), this is recorded in `mIsOnHeap`.
This helps better handle incorrectly-nested registration/unregistration pairs, or excess unregistrations.

Also, markers are now generated to highlight extra (un)registrations, with added backtrace for those surprising cases of excess unregistrations that should probably be reworked.

And `ThreadRegistration::GetTLS()` was simplified, so it auto-initializes when first used, instead of relying on the main thread registration.

Differential Revision: https://phabricator.services.mozilla.com/D123229
2021-08-24 04:47:12 +00:00
Gerald Squelart 1cf3bc392a Bug 1726657 - Only record sampling overheads if MOZ_PROFILER_RECORD_OVERHEADS is set - r=florian
Sampling overheads are very rarely useful, but they occupy some space during profiling, but also a lot of space in the final JSON profile.
So now they will only be recorded if the environment variable "MOZ_PROFILER_RECORD_OVERHEADS" is set to any non-empty value.

Differential Revision: https://phabricator.services.mozilla.com/D123303
2021-08-23 22:23:34 +00:00
Julien Wajsberg 2a42e8a50e Bug 1697901 - [network markers] Bump the profile version to 24 r=gerald
This ensures our users will use the latest version of the frontend when
capturing 'cancel' network markers.

Depends on D123254

Differential Revision: https://phabricator.services.mozilla.com/D123255
2021-08-23 08:56:53 +00:00
Julien Wajsberg 4bc6caa649 Bug 1697901 - [network markers] Support channel cancelation r=valentin,gerald,necko-reviewers
This patch supports channel cancelations with network markers.

Because of all the possible ways to stop a channel and hence all
possible end markers, it also introduces a new boolean to reduce the
complexity. Indeed it happens that 2 "end functions" are called, but we
need to insert only 1 end marker to have a well-formed result in the
Profiler frontend.

Differential Revision: https://phabricator.services.mozilla.com/D122111
2021-08-23 08:56:52 +00:00