зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1676271 - Profile-gathering log - r=canaltinova
This is a special log that's collected while the parent is gathering all the JSON profiles (its own, and its children's). This separate log is necessary, because the gathered logs have already completed and closed their own `profilingLog` object, and it would be much more difficult to add to them now. Differential Revision: https://phabricator.services.mozilla.com/D150562
This commit is contained in:
Родитель
51ff009005
Коммит
6eab60e869
|
@ -19,6 +19,7 @@
|
|||
#include "js/JSON.h"
|
||||
#include "js/PropertyAndElement.h" // JS_SetElement
|
||||
#include "js/Value.h"
|
||||
#include "json/json.h"
|
||||
#include "mozilla/ErrorResult.h"
|
||||
#include "mozilla/SchedulerGroup.h"
|
||||
#include "mozilla/Services.h"
|
||||
|
@ -1033,6 +1034,10 @@ RefPtr<nsProfiler::GatheringPromise> nsProfiler::StartGathering(
|
|||
}
|
||||
|
||||
mGathering = true;
|
||||
mGatheringLog = mozilla::MakeUnique<Json::Value>(Json::objectValue);
|
||||
(*mGatheringLog)[Json::StaticString{
|
||||
"profileGatheringLogBegin" TIMESTAMP_JSON_SUFFIX}] =
|
||||
ProfilingLog::Timestamp();
|
||||
|
||||
if (mGatheringTimer) {
|
||||
mGatheringTimer->Cancel();
|
||||
|
@ -1197,6 +1202,21 @@ void nsProfiler::FinishGathering() {
|
|||
// Close the "processes" array property.
|
||||
mWriter->EndArray();
|
||||
|
||||
if (mGatheringLog) {
|
||||
(*mGatheringLog)[Json::StaticString{
|
||||
"profileGatheringLogEnd" TIMESTAMP_JSON_SUFFIX}] =
|
||||
ProfilingLog::Timestamp();
|
||||
mWriter->StartObjectProperty("profileGatheringLog");
|
||||
{
|
||||
nsAutoCString pid;
|
||||
pid.AppendInt(int64_t(profiler_current_process_id().ToNumber()));
|
||||
Json::String logString = mGatheringLog->toStyledString();
|
||||
mGatheringLog = nullptr;
|
||||
mWriter->SplicedJSONProperty(pid, logString);
|
||||
}
|
||||
mWriter->EndObject();
|
||||
}
|
||||
|
||||
// Close the root object of the generated JSON.
|
||||
mWriter->End();
|
||||
|
||||
|
@ -1218,6 +1238,7 @@ void nsProfiler::ResetGathering() {
|
|||
}
|
||||
mPendingProfiles.clearAndFree();
|
||||
mGathering = false;
|
||||
mGatheringLog = nullptr;
|
||||
if (mGatheringTimer) {
|
||||
mGatheringTimer->Cancel();
|
||||
mGatheringTimer = nullptr;
|
||||
|
|
|
@ -14,12 +14,17 @@
|
|||
#include "mozilla/ProfileJSONWriter.h"
|
||||
#include "mozilla/ProportionValue.h"
|
||||
#include "mozilla/TimeStamp.h"
|
||||
#include "mozilla/UniquePtr.h"
|
||||
#include "mozilla/Vector.h"
|
||||
#include "nsIProfiler.h"
|
||||
#include "nsITimer.h"
|
||||
#include "nsServiceManagerUtils.h"
|
||||
#include "ProfilerCodeAddressService.h"
|
||||
|
||||
namespace Json {
|
||||
class Value;
|
||||
} // namespace Json
|
||||
|
||||
class nsProfiler final : public nsIProfiler {
|
||||
public:
|
||||
nsProfiler();
|
||||
|
@ -88,6 +93,9 @@ class nsProfiler final : public nsIProfiler {
|
|||
mozilla::Vector<PendingProfile> mPendingProfiles;
|
||||
bool mGathering;
|
||||
nsCOMPtr<nsITimer> mGatheringTimer;
|
||||
// Supplemental log to the profiler's "profilingLog" (which has already been
|
||||
// completed in JSON profiles that are gathered).
|
||||
mozilla::UniquePtr<Json::Value> mGatheringLog;
|
||||
};
|
||||
|
||||
#endif // nsProfiler_h
|
||||
|
|
|
@ -100,6 +100,18 @@ add_task(async function test_profile_fission_no_private_browsing() {
|
|||
"number"
|
||||
);
|
||||
|
||||
Assert.equal(typeof profile.profileGatheringLog, "object");
|
||||
Assert.equal(typeof profile.profileGatheringLog[parentPid], "object");
|
||||
Assert.equal(
|
||||
typeof profile.profileGatheringLog[parentPid]
|
||||
.profileGatheringLogBegin_TSms,
|
||||
"number"
|
||||
);
|
||||
Assert.equal(
|
||||
typeof profile.profileGatheringLog[parentPid].profileGatheringLogEnd_TSms,
|
||||
"number"
|
||||
);
|
||||
|
||||
Assert.equal(typeof contentProcess.profilingLog, "object");
|
||||
Assert.equal(typeof contentProcess.profilingLog[contentPid], "object");
|
||||
Assert.equal(
|
||||
|
@ -110,6 +122,8 @@ add_task(async function test_profile_fission_no_private_browsing() {
|
|||
typeof contentProcess.profilingLog[contentPid].profilingLogEnd_TSms,
|
||||
"number"
|
||||
);
|
||||
|
||||
Assert.equal(typeof contentProcess.profileGatheringLog, "undefined");
|
||||
} finally {
|
||||
await BrowserTestUtils.closeWindow(win);
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче