Bug 1745444 - Expand FOG IPC to Socket process, to collect CPU time used there, r=chutten,necko-reviewers,valentin.

Differential Revision: https://phabricator.services.mozilla.com/D133491
This commit is contained in:
Florian Quèze 2021-12-15 16:27:56 +00:00
parent 5edb88e27a
commit 90b4404217
8 changed files with 48 additions and 0 deletions

View File

@ -31,6 +31,8 @@ include NeckoChannelParams;
include PrefsTypes;
include PSMIPCTypes;
include "mozilla/ipc/ByteBufUtils.h";
using mozilla::dom::NativeThreadId from "mozilla/dom/NativeThreadId.h";
using mozilla::dom::TabId from "mozilla/dom/ipc/IdType.h";
using mozilla::Telemetry::HistogramAccumulation from "mozilla/TelemetryComms.h";
@ -140,6 +142,11 @@ parent:
async OnConsoleMessage(nsString aMessage);
// Sent from time-to-time to limit the amount of telemetry vulnerable to loss
// Buffer contains bincoded Rust structs.
// https://firefox-source-docs.mozilla.org/toolkit/components/glean/dev/ipc.html
async FOGData(ByteBuf buf);
child:
async Init(SocketPorcessInitAttributes aAttributes);
async PreferenceUpdate(Pref pref);
@ -190,6 +197,11 @@ child:
async RecheckIPConnectivity();
async RecheckDNS();
// Tells the Socket process to flush any pending telemetry.
// Used in tests and ping assembly. Buffer contains bincoded Rust structs.
// https://firefox-source-docs.mozilla.org/toolkit/components/glean/dev/ipc.html
async FlushFOGData() returns (ByteBuf buf);
both:
async PFileDescriptorSet(FileDescriptor fd);
async PDNSRequest(nsCString hostName, nsCString trrServer, uint16_t type,

View File

@ -15,6 +15,7 @@
#include "mozilla/Atomics.h"
#include "mozilla/Components.h"
#include "mozilla/dom/MemoryReportRequest.h"
#include "mozilla/FOGIPC.h"
#include "mozilla/ipc/CrashReporterClient.h"
#include "mozilla/ipc/BackgroundChild.h"
#include "mozilla/ipc/BackgroundParent.h"
@ -178,6 +179,10 @@ void SocketProcessChild::ActorDestroy(ActorDestroyReason aWhy) {
ProcessChild::QuickExit();
}
// Send the last bits of Glean data over to the main process.
glean::FlushFOGData(
[](ByteBuf&& aBuf) { glean::SendFOGData(std::move(aBuf)); });
if (mProfilerController) {
mProfilerController->Shutdown();
mProfilerController = nullptr;
@ -666,5 +671,11 @@ mozilla::ipc::IPCResult SocketProcessChild::RecvRecheckDNS() {
return IPC_OK();
}
mozilla::ipc::IPCResult SocketProcessChild::RecvFlushFOGData(
FlushFOGDataResolver&& aResolver) {
glean::FlushFOGData(std::move(aResolver));
return IPC_OK();
}
} // namespace net
} // namespace mozilla

View File

@ -148,6 +148,8 @@ class SocketProcessChild final
mozilla::ipc::IPCResult RecvRecheckIPConnectivity();
mozilla::ipc::IPCResult RecvRecheckDNS();
mozilla::ipc::IPCResult RecvFlushFOGData(FlushFOGDataResolver&& aResolver);
protected:
friend class SocketProcessImpl;
~SocketProcessChild();

View File

@ -12,6 +12,7 @@
#include "SocketProcessHost.h"
#include "mozilla/Components.h"
#include "mozilla/dom/MemoryReportRequest.h"
#include "mozilla/FOGIPC.h"
#include "mozilla/ipc/FileDescriptorSetParent.h"
#include "mozilla/ipc/IPCStreamAlloc.h"
#include "mozilla/ipc/PChildToParentStreamParent.h"
@ -470,5 +471,10 @@ mozilla::ipc::IPCResult SocketProcessParent::RecvOnConsoleMessage(
return IPC_OK();
}
mozilla::ipc::IPCResult SocketProcessParent::RecvFOGData(ByteBuf&& aBuf) {
glean::FOGData(std::move(aBuf));
return IPC_OK();
}
} // namespace net
} // namespace mozilla

View File

@ -125,6 +125,8 @@ class SocketProcessParent final
const HttpConnectionInfoCloneArgs& aArgs);
mozilla::ipc::IPCResult RecvOnConsoleMessage(const nsString& aMessage);
mozilla::ipc::IPCResult RecvFOGData(ByteBuf&& aBuf);
private:
SocketProcessHost* mHost;
UniquePtr<dom::MemoryReportRequestHost> mMemoryReportRequest;

View File

@ -122,6 +122,9 @@ fn register_process_shutdown(process_type: u32) {
nsIXULRuntime::PROCESS_TYPE_RDD => {
// RDD process shutdown is handled in RDDParent::ActorDestroy.
}
nsIXULRuntime::PROCESS_TYPE_SOCKET => {
// Socket process shutdown is handled in SocketProcessChild::ActorDestroy.
}
_ => {
// We don't yet support other process types.
log::error!("Process type {} tried to use FOG, but isn't supported! (Process type constants are in nsIXULRuntime.rs)", process_type);

View File

@ -138,6 +138,7 @@ FOG supports messaging between the following types of child process and the pare
(for now. See [bug 1641989](https://bugzilla.mozilla.org/show_bug.cgi?id=1641989))
* gpu children (via `PGPU`)
* rdd children (via `PRDD`)
* socket children (via `PSocketProcess`)
See
[the process model docs](../../../../dom/ipc/process_model.html)

View File

@ -14,6 +14,8 @@
#include "mozilla/gfx/GPUParent.h"
#include "mozilla/gfx/GPUProcessManager.h"
#include "mozilla/MozPromise.h"
#include "mozilla/net/SocketProcessChild.h"
#include "mozilla/net/SocketProcessParent.h"
#include "mozilla/ProcInfo.h"
#include "mozilla/RDDChild.h"
#include "mozilla/RDDParent.h"
@ -112,6 +114,11 @@ void FlushAllChildData(
}
}
if (net::SocketProcessParent* socketParent =
net::SocketProcessParent::GetSingleton()) {
promises.EmplaceBack(socketParent->SendFlushFOGData());
}
if (promises.Length() == 0) {
// No child processes at the moment. Resolve synchronously.
fog_ipc::flush_durations.Cancel(std::move(timerId));
@ -165,6 +172,10 @@ void SendFOGData(ipc::ByteBuf&& buf) {
case GeckoProcessType_RDD:
Unused << mozilla::RDDParent::GetSingleton()->SendFOGData(std::move(buf));
break;
case GeckoProcessType_Socket:
Unused << net::SocketProcessChild::GetSingleton()->SendFOGData(
std::move(buf));
break;
default:
MOZ_ASSERT_UNREACHABLE("Unsuppored process type");
}