These classes should replace the `int` type that is currently used to store process and thread ids. The next patches will start using them. Advantages:
- Prevent type mismatches, e.g., giving a process id (or other number) to a function expecting a thread id.
- Prevent nonsensical arithmetic operations.
- Make the unspecified id more abstract, so it's more obvious and portable.
- Make conversions to/from numbers (for display or storage) more visible.
- Allow future changes of APIs using them less risky.
- Allow future changes of the ids themselves (e.g., to be able to use bigger underlying types on some platforms, or even the opaque std:🧵:id type.)
Differential Revision: https://phabricator.services.mozilla.com/D120221
This new header isolates the process and thread functions that should be available in all builds, and in most other profiler headers.
Non-MOZ_GECKO_PROFILER implementations return ids 0 (unspecified process/thread). `profiler_is_main_thread()` returns false, it's arbitrary but consistent with `0` (it makes little sense to use it there anyway.)
Differential Revision: https://phabricator.services.mozilla.com/D120220
The next patch will extract parts of these headers into a separate file, so it's best to do this clean-up now, to best preserve history.
- Add [[nodiscard]] to all functions that return something. (There are no cases where that returned value could really be ignored.)
- Hide scProfilerMainThreadId in a "detail" namespace, to emphasize that it's an implementation detail that the user shouldn't access directly.
- Combine tightly-nested namespaces start/end into single lines, it's more readable.
Differential Revision: https://phabricator.services.mozilla.com/D120219
This step removes all the dependencies of mach commands to
having a MachCommandBase as the `self` by using the `command_context`
argument instead. This also removes any remaining statefulness from those
classes that implement mach commands, ultimately making it easier to move
existing commands out of classes in a follow-up.
Differential Revision: https://phabricator.services.mozilla.com/D118058
This step removes all the dependencies of mach commands to
having a MachCommandBase as the `self` by using the `command_context`
argument instead. This also removes any remaining statefulness from those
classes that implement mach commands, ultimately making it easier to move
existing commands out of classes in a follow-up.
Differential Revision: https://phabricator.services.mozilla.com/D118058
This prevents unwanted direct access to the mutex, and removes duplicated code.
And make the Base Profiler mutex&lock consistent.
Differential Revision: https://phabricator.services.mozilla.com/D119147
Bug 1714577 meant to exclude tools/profiler/public/GeckoTraceEvent.h from
clang-format, but the trailing comment in .clang-format-ignored broke that.
Bug 1519636 then formatted the file.
This fixes the exclusion in .clang-format-ignore and backs out the
clang-format on tools/profiler/public/GeckoTraceEvent.h.
Differential Revision: https://phabricator.services.mozilla.com/D119297
This moves the adding of the end marker for redirects in nsHttpChannel
to SetupReplacementChannel, so that all redirects are properly caught.
Without that, some requests will show as unfinished in the profiler
frontend.
Some of the redirects are internal and we may be able to flag and ignore
them in the frontend, but that's work for the future.
Because all redirections get a "REDIRECT" end marker, including the
internal redirection to the service worker's intercepted channel, we now
need an additional "START" marker there as well.
All existing profiler tests related to service workers needed to be
updated because there's an extra redirect marker in all these requests,
as well as several pairs of markers that all have the same id.
This also adds a new profiler test for handling the http->https case
that we wouldn't catch before this patch.
Differential Revision: https://phabricator.services.mozilla.com/D118836
This patch adds a new linter that will error when new code mentions any one of
the following strings:
* `CoInitialize`;
* `CoInitializeEx`;
* `OleInitialize`;
* `RoInitialize`;
* `CoUninitialize`;
* `OleUninitialize`; and
* `RoUninitialize`.
Since I don't care about context, and just want to flag code containing these
names, I opted for a `regex` linter.
Yes, the regex does match a few strings beyond the above list (in particular, it
also matches additional strings that end with an `Ex` suffix), but since
functions with those names don't exist anyway (and would be errors in their own
right), I am not concerned about it.
All existing occurrences have been added to the exclusion list, with the
intent of removing most of them over time.
Differential Revision: https://phabricator.services.mozilla.com/D119129
This is similar to what DoMozStackWalkBacktrace does, by looking where the stack walker stopped, and if it can be restarted at a calling C++-to-JIT entry frame.
Note: The code is pretty much a modified copy, but factoring out the common parts would be difficult because of the specific local variables, the different stack-walking functions, and the different register storages.
Also, instead of mentioning the OS (was only Windows), the choice of platform support is now based on the actual Profiler stack walkers that are used.
Differential Revision: https://phabricator.services.mozilla.com/D118109
Callbacks can be registered to be called at specific profiler state changes.
This may be useful to make sure some markers are recorded at the end of the profile time range, if some information would be useful to always have available (and it doesn't fit in meta-information or elsewhere).
Differential Revision: https://phabricator.services.mozilla.com/D118128
Then this will make it possible in the UI to relate the redirected
request with its redirection.
With this patch a debug build of Firefox will crash when a redirection
happens, but the next patch will fix this.
Differential Revision: https://phabricator.services.mozilla.com/D118467
These requests had except blocks to catch all requests exceptions. But because
we weren't calling 'raise_for_status', exceptions were never raised, resulting
in bizarre error tracebacks later on.
Depends on D118356
Differential Revision: https://phabricator.services.mozilla.com/D118357
A failure displaying estimates should never cause the try push to fail, as it
is entirely optional. This adds a blanket except to catch any exception that
was mishandled inside the estimates submodule.
It still displays a traceback as any failures displayed here should still
legitimately be fixed or have smoother error handling.
Differential Revision: https://phabricator.services.mozilla.com/D118356
When a user runs 'mach try --full', we continue computing the target task set
and cache it anyway (since we were already almost there and starting over in
the event they re-run without '--full' is very expensive.
However, when implementing the 'cache_key' function in bug 1714178, I forgot to
recompute the key in this case, causing the contents of 'target_task_set' to
overwrite the 'full_task_set' cache.
This also includes a minor improvement to re-use the 'full_task_set' cache
regardless of 'disable_target_task_filter', as that flag has zero bearing on
the full task graph. This should result in fewer cache misses when using
--full.
Differential Revision: https://phabricator.services.mozilla.com/D118531
This reverses bug 1703410: By default the profiler now changes the timer resolution (normally 64Hz) when the requested sampling interval is lower than 10ms, to allow fast-enough sampling for most uses.
But since this can influence other timers in Firefox, it makes debugging some types of issues more difficult. To help with this, there is now a "No Timer Resolution change" on Windows, which prevents the profiler from changing the timer resolution, at a risk of slowing down sampling in some processes.
Differential Revision: https://phabricator.services.mozilla.com/D117626