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

578 Коммитов

Автор SHA1 Сообщение Дата
Cristian Tuns 1aeac93d23 Backed out 5 changesets (bug 1738627) for causing xpcshell failures on test_ext_geckoProfiler_schema.js CLOSED TREE
Backed out changeset 42d385d7da97 (bug 1738627)
Backed out changeset edeb3a338954 (bug 1738627)
Backed out changeset 98f02e35134d (bug 1738627)
Backed out changeset 711daa6dd24b (bug 1738627)
Backed out changeset 49e12753a40c (bug 1738627)
2021-11-05 05:12:28 -04:00
Gerald Squelart ea92e5ea81 Bug 1738627 - MOZ_PROFILER_STARTUP_FEATURES {cpu,stacks,markers}allthreads - r=canaltinova
New features cpuallthreads, stacksallthreads, and markersallthreads now allow the user to selectively profile non-selected threads for more information.

The gtest GeckoProfiler.FeatureCombinations is modified to test combinations of up to 3 of a set of features, to lower its cost, which allows adding the new features.

Differential Revision: https://phabricator.services.mozilla.com/D130011
2021-11-05 05:52:29 +00:00
Gerald Squelart 8ff93952a4 Bug 1737058 - Empty MOZ_PROFILER_SHUTDOWN in child processes, so they don't needlessly and dangerously write their profile to the same file - r=canaltinova
The user shouldn't set MOZ_PROFILER_SHUTDOWN to an empty string, it wouldn't work anyway.
So now there is an extra check for that, to avoid even attempting to write a profile when there is no actual filename.

Thanks to this, the parent process can now just re-set MOZ_PROFILER_SHUTDOWN to "" in its children, so that they won't try to output their own profile into the same file. (This used to mostly work, because the parent process was the last to write its profile; but anecdotal data shows this may not alwaybe be true.)

As a bonus optimization, this means that child processes don't waste time needlessly saving their profile to disk.

Differential Revision: https://phabricator.services.mozilla.com/D129237
2021-10-22 08:41:27 +00:00
Gerald Squelart 302a5711fa Bug 1577658 - DeserializeAfterKindAndStream takes a lambda: (tid) -> writer - r=canaltinova
Previously, DeserializeAfterKindAndStream would take a JSON writer and a thread id, using the thread id (if specified) to only output markers from that thread to the given writer.

Now, DeserializeAfterKindAndStream takes a lambda, which will be called with the thread id found in the marker, that lambda can either return null (nothing to output) or a pointer to a writer, in which case the marker is read and output to the given writer.
This makes DeserializeAfterKindAndStream more flexible, and will allow handling markers from different threads, each possibly being output to different writers.

Also, for simplicity the entry is now always fully read, so there is no need for the caller to do anything. The return bool is therefore unnecessary, and has been removed.

Differential Revision: https://phabricator.services.mozilla.com/D128433
2021-10-21 05:47:21 +00:00
Gerald Squelart df50ece611 Bug 1735697 - Remove profiler_can_accept_markers(), use profiler_thread_is_being_profiled() instead - r=florian
Differential Revision: https://phabricator.services.mozilla.com/D128577
2021-10-18 23:11:30 +00:00
Gerald Squelart 424aac2b72 Bug 1735697 - Only record markers from actually-profiled threads - r=florian
`profiler_add_marker()` now checks if the marker's target thread is actively being profiled. This is to prevent adding markers that would be discarded anyway, from taking CPU time to process, and from using space in the profile buffer.

This means that `profiler_thread_is_being_profiled(ProfilerThreadId)` must be used when a marker is intended for another thread, i.e., when it uses the MarkerThreadId option.

(Note: since baseprofiler::profiler_thread_is_being_profiled(ProfilerThreadId) is not available, baseprofiler::AddMarker cannot prevent markers targetted at non-profiled thread; There are none yet anyway.)

Differential Revision: https://phabricator.services.mozilla.com/D128576
2021-10-18 23:11:30 +00:00
Gerald Squelart 8bf5fd4b34 Bug 1735697 - profiler_is_being_profiled checks for pauses, and can check another thread - r=florian
If the profiler is paused, then really, threads are not *being* profiled.

profiler_is_active_and_unpaused() was added, to help with non-MOZ_GECKO_PROFILER builds.

(Note: baseprofiler::profiler_thread_is_being_profiled(ProfilerThreadId) is not possible to implement, but it's not needed anyway.)

Differential Revision: https://phabricator.services.mozilla.com/D128707
2021-10-18 23:11:29 +00:00
Nazım Can Altınova 146befbbdb Bug 1733335 - Add tracing marker type for the Rust side r=gerald
Differential Revision: https://phabricator.services.mozilla.com/D127112
2021-10-11 07:59:09 +00:00
Sandor Molnar ac87f8501e Backed out 4 changesets (bug 1733335) for causing multiple dt failures. CLOSED TREE
Backed out changeset 8c14ac28d042 (bug 1733335)
Backed out changeset 066819ce0e86 (bug 1733335)
Backed out changeset c44e1bb6d9ff (bug 1733335)
Backed out changeset 4cd1efb42295 (bug 1733335)
2021-10-06 17:49:47 +03:00
Nazım Can Altınova 9651c20007 Bug 1733335 - Add tracing marker type for the Rust side r=gerald
Differential Revision: https://phabricator.services.mozilla.com/D127112
2021-10-06 11:35:15 +00:00
Marian-Vasile Laza 6c22452994 Backed out 4 changesets (bug 1733335) for causing build bustages. CLOSED TREE
Backed out changeset 45a3ae02f837 (bug 1733335)
Backed out changeset 41c62acfb5a6 (bug 1733335)
Backed out changeset cf3b6b6cc6c6 (bug 1733335)
Backed out changeset b919d9cfb8e5 (bug 1733335)
2021-10-05 15:07:44 +03:00
Nazım Can Altınova aae1952697 Bug 1733335 - Add tracing marker type for the Rust side r=gerald
Differential Revision: https://phabricator.services.mozilla.com/D127112
2021-10-05 11:34:27 +00:00
Mike Hommey 49ee506e32 Bug 1732208 - Silence the unused-but-set-variable warning in platform-linux-android.cpp. r=gerald
platform-linux-android.cpp:199:9: error: variable 'r' set but not used [-Werror,-Wunused-but-set-variable]
    int r = sem_init(&mMessage2, /* pshared */ 0, 0);
        ^
platform-linux-android.cpp:206:9: error: variable 'r' set but not used [-Werror,-Wunused-but-set-variable]
 not used [-Werror,-Wunused-but-set-variable]
    int r = sem_destroy(&mMessage2);
        ^

Differential Revision: https://phabricator.services.mozilla.com/D126459
2021-09-28 00:02:47 +00:00
Nazım Can Altınova a15be90d61 Bug 1654413 - Deserialize and stream the markers and marker schemas r=emilio,gerald
Now we can deserialize and stream everything to the JSON.

Differential Revision: https://phabricator.services.mozilla.com/D124027
2021-09-21 11:08:12 +00:00
Nazım Can Altınova ca180f8629 Bug 1654413 - Add add_marker Rust profiler API and serialize the marker to the buffer r=emilio,gerald
This only adds the API and then adds the profiler payload to the buffer. The
deserialization and streaming will happen in the next patch.

Differential Revision: https://phabricator.services.mozilla.com/D124026
2021-09-21 11:08:11 +00:00
Nazım Can Altınova a5b9cfdadb Bug 1654413 - Add MarkerSchema struct and its enums for marker API r=emilio,gerald
You can see the `mozilla::MarkerSchema` for the C++ counterpart. This Rust
struct simply wraps the C++ object and keeps the reference of it as RAII. This
heap allocates the inner C++ object but it's fine to do it here, because it's
we only create a MarkerSchema object at the end of a profiling session and it
happens once per marker type. It should be very rare.

Differential Revision: https://phabricator.services.mozilla.com/D124025
2021-09-21 11:08:11 +00:00
Nazım Can Altınova 02f9877e83 Bug 1654413 - Add add_untyped_marker Rust API r=emilio,gerald
This is the first and simplest API for the markers. There will be two more
APIs in the following patches (add_text_marker and add_marker). You can see the
PROFILER_MARKER_UNTYPED macro for the C++ counterpart.

Differential Revision: https://phabricator.services.mozilla.com/D124022
2021-09-21 11:08:10 +00:00
Nazım Can Altınova 7ec023dfe3 Bug 1654413 - Add a MarkerTiming and MarkerOptions Rust structs for the marker API r=emilio,gerald
These structs are needed for the marker APIs. We also have the same structs as
the C++ classes. See `mozilla::MarkerTiming` and `mozilla::MarkerOptions`.

Differential Revision: https://phabricator.services.mozilla.com/D124020
2021-09-21 11:08:09 +00:00
Gerald Squelart b3c424f6d7 Bug 1663382 - Optimize Deserializer<ProfilerStringView> to reference in-buffer data when possible - r=canaltinova
Because string contents could be split in two separate chunks, the default ProfilerStringView deserializer needed to concatenate it together in an off-chunk buffer.
But now thanks to ProfileBufferEntryReader::ReadSpans, it is possible to know if the contents are in a single memory area inside one chunk (which should be the vast majority of cases), in which case the ProfilerStringView can just reference it using its internal std::string_view, which saves managing a separate buffer and copying data into it.
However this can only be done safely when the span is correctly aligned for the character type, which may not be the case for char16_t strings that must be even-aligned.

Differential Revision: https://phabricator.services.mozilla.com/D124430
2021-09-10 11:43:48 +00:00
Gerald Squelart 997a0ba46c Bug 1663382 - ProfileBufferEntryReader::{Peek,Read}Spans return pointers to entry bytes - r=canaltinova
Instead of always having to use `ReadBytes` to copy bytes out of the profile buffer into an external buffer, these functions provide one or two spans (pointer+size) pointing at the area, which can be used to look at the data without copying it, especially in the majority of cases where areas are fully inside one chunk and only need one span to address.

Differential Revision: https://phabricator.services.mozilla.com/D124429
2021-09-10 11:43:48 +00:00
Gerald Squelart c4a6f1bac7 Bug 1663382 - Remove dangerous ProfilerStringView::Data() - r=florian
`ProfilerStringView::Data()` would return a pointer to the start of the string, but there may not be a null terminator at the end!
To reduce the likelihood of misuses, that function has now been removed.
Instead, callers must now access the data through `AsSpan` or the `Span` conversion operator (which makes it easy to use with `NS_ConvertUTF16toUTF8` for example).

It was not an issue until now, because deserialized string would always be terminated when copied out of the profile buffer, but a following patch will add optimized code where the non-terminated string inside the buffer will be directly pointed at.

Differential Revision: https://phabricator.services.mozilla.com/D125027
2021-09-10 11:43:47 +00:00
Mike Hommey 9c0f04e547 Bug 1730030 - Replace some assembly with corresponding compiler builtins. r=gerald
This has the side-effect of adding the missing arm64 mac support for PHC.

Differential Revision: https://phabricator.services.mozilla.com/D125139
2021-09-10 00:58:34 +00:00
Narcis Beleuzu d1008ea8e7 Backed out 2 changesets (bug 1663382) for bc failures on browser_test_marker_network_serviceworker_synthetized_response.js . CLOSED TREE
Backed out changeset f3a453eb5700 (bug 1663382)
Backed out changeset 2fd6d02ad407 (bug 1663382)
2021-09-07 03:28:41 +03:00
Gerald Squelart dceb658042 Bug 1663382 - Optimize Deserializer<ProfilerStringView> to reference in-buffer data when possible - r=canaltinova
Because string contents could be split in two separate chunks, the default ProfilerStringView deserializer needed to concatenate it together in an off-chunk buffer.
But now thanks to ProfileBufferEntryReader::ReadSpans, it is possible to know if the contents are in a single memory area inside one chunk (which should be the vast majority of cases), in which case the ProfilerStringView can just reference it using its internal std::string_view, which saves managing a separate buffer and copying data into it.
However this can only be done safely when the span is correctly aligned for the character type, which may not be the case for char16_t strings that must be even-aligned.

Differential Revision: https://phabricator.services.mozilla.com/D124430
2021-09-06 22:18:03 +00:00
Gerald Squelart 6076a5b8de Bug 1663382 - ProfileBufferEntryReader::{Peek,Read}Spans return pointers to entry bytes - r=canaltinova
Instead of always having to use `ReadBytes` to copy bytes out of the profile buffer into an external buffer, these functions provide one or two spans (pointer+size) pointing at the area, which can be used to look at the data without copying it, especially in the majority of cases where areas are fully inside one chunk and only need one span to address.

Differential Revision: https://phabricator.services.mozilla.com/D124429
2021-09-06 22:18:02 +00:00
Iulian Moraru c701e5f6e9 Backed out 2 changesets (bug 1663382) for causing multiple mochitest crashes. CLOSED TREE
Backed out changeset bac8ae20a8af (bug 1663382)
Backed out changeset 0b3495e23e77 (bug 1663382)
2021-09-06 06:50:02 +03:00
Gerald Squelart 108a906e53 Bug 1663382 - Optimize Deserializer<ProfilerStringView> to reference in-buffer data when possible - r=canaltinova
Because string contents could be split in two separate chunks, the default ProfilerStringView deserializer needed to concatenate it together in an off-chunk buffer.
But now thanks to ProfileBufferEntryReader::ReadSpans, it is possible to know if the contents are in a single memory area inside one chunk (which should be the vast majority of cases), in which case the ProfilerStringView can just reference it using its internal std::string_view, which saves managing a separate buffer and copying data into it.

Differential Revision: https://phabricator.services.mozilla.com/D124430
2021-09-06 02:40:08 +00:00
Gerald Squelart af8c9a770f Bug 1663382 - ProfileBufferEntryReader::{Peek,Read}Spans return pointers to entry bytes - r=canaltinova
Instead of always having to use `ReadBytes` to copy bytes out of the profile buffer into an external buffer, these functions provide one or two spans (pointer+size) pointing at the area, which can be used to look at the data without copying it, especially in the majority of cases where areas are fully inside one chunk and only need one span to address.

Differential Revision: https://phabricator.services.mozilla.com/D124429
2021-09-06 02:40:08 +00:00
Nazım Can Altınova 0f657df07f Bug 1728544 - Make the MarkerSchema::Searchable enum class values CamelCased r=gerald
Differential Revision: https://phabricator.services.mozilla.com/D124242
2021-09-03 14:30:10 +00:00
Nazım Can Altınova a38b25b295 Bug 1728544 - Make the MarkerSchema::Format enum class values CamelCased r=gerald
Differential Revision: https://phabricator.services.mozilla.com/D124241
2021-09-03 14:30:10 +00:00
Nazım Can Altınova ddae0f7cd6 Bug 1728544 - Make the MarkerSchema::Location enum class values CamelCased r=gerald
Differential Revision: https://phabricator.services.mozilla.com/D124240
2021-09-03 14:30:09 +00:00
Christopher Winter 7acf6d224b Bug 1604914 - Make ShouldProfileThread more efficient r=gerald
When starting the profiler, also make a copy of the filter strings
converted to lower-case. This allows caseless comparisons to be made
against thread names without repeatedly converting the filters to
lower-case for each thread.

Differential Revision: https://phabricator.services.mozilla.com/D123302
2021-08-26 01:31:25 +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
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
Gerald Squelart 9c1ed025c1 Bug 1633572 - New small buffer entry to indicate an indentical sample instead of a copy - r=canaltinova
Instead of copying the full stack from the previous sample when identical, the new ProfileBufferEntryKind::TimeBeforeSameSample + SameSample entry pair indicates that this is an identical sample. Later when producing the final JSON profile, we can just re-use the same sample identifier as before.

This effectively lowers the size of this kind of entry from hundreds of bytes, down to 20-30 bytes, which should help with capturing more samples in the same buffer size. And it also uses less CPU resources, since we don't need to find the previous stack and copy it.

We still need to perform a full copy at the start of a buffer chunk, to make sure there is always a full stack available in case older previous chunks have been destroyed.

Differential Revision: https://phabricator.services.mozilla.com/D122679
2021-08-18 01:47:41 +00:00
Gerald Squelart aaee7d55b0 Bug 1633572 - ProfileChunkedBuffer::IsIndexInCurrentChunk - r=canaltinova
Differential Revision: https://phabricator.services.mozilla.com/D122678
2021-08-18 01:47:41 +00:00
Gerald Squelart 2be7cfed4b Bug 1633572 - Fix PROFILER_RUNTIME_STATS - r=canaltinova
PROFILER_RUNTIME_STATS was broken recently. It's only used during development (mostly to benchmark new code), so it's not critical and no tests are needed.

Differential Revision: https://phabricator.services.mozilla.com/D122677
2021-08-18 01:47:40 +00:00
Gerald Squelart adfaf6a929 Bug 1725089 - Add support for WASI in ProfilerUtils - r=jandem
Differential Revision: https://phabricator.services.mozilla.com/D122313
2021-08-12 12:27:25 +00:00
Gerald Squelart 056d185383 Bug 1721569 - Use std::this_thread::get_id() on other platforms - r=florian
Now `profiler_current_thread_id()` is available on all platforms, at all tier levels.

Differential Revision: https://phabricator.services.mozilla.com/D121053
2021-08-11 03:27:52 +00:00
Gerald Squelart 032f23b189 Bug 1721569 - Change id native types to reflect what each platform really provides - r=florian
Differential Revision: https://phabricator.services.mozilla.com/D121052
2021-08-11 03:27:51 +00:00
Gerald Squelart 1f76b47543 Bug 1721569 - Move main-thread id functions to cpp files - r=florian
This hides the scProfilerMainThreadId detail, and makes for a safer API.
Also, ::profiler_init_main_thread_id() calls ::mozilla::baseprofiler::profiler_init_main_thread_id().
And in non-MOZ_GECKO_PROFILER builds, AUTO_PROFILER_INIT calls profiler_init_main_thread_id(), which makes other main-thread functions usable there (assuming profiler_current_thread_id works).

Differential Revision: https://phabricator.services.mozilla.com/D121695
2021-08-11 03:27:51 +00:00
Gerald Squelart 84d1ba4229 Bug 1721569 - Moved implementations of {,Base}ProfilerUtils.h declarations to ProfilerUtils.cpp - r=florian
This patch only shuffles source code around, so that all declarations in {,Base}ProfilerUtils.h are now implemented only in ProfilerUtils.cpp (instead of the different platform-*.cpp), the final generated code should be the same in MOZ_GECKO_PROFILER builds (the default on all our supported platforms).
This simplifies the headers and makes further changes easier.

In non-MOZ_GECKO_PROFILER builds: On supported platforms these functions are now fully defined; Unsupported platforms should all had `getpid()`, but thread ids are null.
So now `profiler_current_process_id()` is available on all platforms, at all tier levels.

Differential Revision: https://phabricator.services.mozilla.com/D121051
2021-08-11 03:27:50 +00:00
Gerald Squelart 5d1937d55a Bug 1721569 - Handle different sizes of Profiler{Process,Thread}Id - r=florian
Since ProfilerProcessId and ProfilerThreadId (and their NumberTypes) will potentially grow to 64 bits on some platforms (in a later patch), all code that uses them must be able to handle bigger types.

Differential Revision: https://phabricator.services.mozilla.com/D121049
2021-08-11 03:27:50 +00:00
Toshihito Kikuchi 07dfbc6b36 Bug 1723868 - Skip msvp9dec_store.dll in GetInfoForSelf(). r=gerald
When mfplat.dll loads msvp9dec_store.dll, it posts a task
to unload the module to the work queue even if msvp9dec_store.dll
is already loaded and mfplat.dll skips LoadLibrary.  Therefore,
we cannot safely lock msvp9dec_store.dll by loading it as data.

The proposed fix is to skip processing the module.

Differential Revision: https://phabricator.services.mozilla.com/D121777
2021-08-05 02:36:27 +00:00
Nazım Can Altınova 4302cd6058 Bug 1652560 - Autogenerate profiling_categories.rs with profiling_categories.yaml r=gerald,emilio
Generate the user friendly Rust enums and their impls for profiling categories.

Differential Revision: https://phabricator.services.mozilla.com/D120792
2021-07-30 21:49:21 +00:00
Nazım Can Altınova 0b9f9eb6a9 Bug 1652560 - Autogenerate ProfilingCategoryList.h with profiling_categories.yaml r=emilio,gerald
Previously ProfilingCategoryList.h was a central place for profiling
categories. But with this patch, profiling_categories.yaml becomes the
canonical place for it and the macro header file is being generated
automatically. This is needed to make the profiling categories in sync with
Rust and C++.

Differential Revision: https://phabricator.services.mozilla.com/D120791
2021-07-30 21:49:21 +00:00
Gerald Squelart e7e9ae90ae Bug 1721110 - profiler_current_thread_id() now returns ProfilerThreadId - r=florian
Differential Revision: https://phabricator.services.mozilla.com/D120225
2021-07-21 04:16:59 +00:00
Gerald Squelart 7bc3116790 Bug 1721110 - baseprofiler::profiler_current_thread_id() now returns BaseProfilerThreadId - r=florian
Differential Revision: https://phabricator.services.mozilla.com/D120224
2021-07-21 04:16:59 +00:00
Gerald Squelart 723be2ec1e Bug 1721110 - baseprofiler::profiler_current_process_id() now returns BaseProfilerProcessId - r=florian
Differential Revision: https://phabricator.services.mozilla.com/D120222
2021-07-21 04:16:58 +00:00