Bug 1905599 - Add a new remote type inference r=smaug,fluent-reviewers,flod
Differential Revision: https://phabricator.services.mozilla.com/D215476
This commit is contained in:
@@ -1395,6 +1395,7 @@ static WebIDLProcType ProcTypeToWebIDL(mozilla::ProcType aType) {
|
|||||||
PROCTYPE_TO_WEBIDL_CASE(PrivilegedMozilla, Privilegedmozilla);
|
PROCTYPE_TO_WEBIDL_CASE(PrivilegedMozilla, Privilegedmozilla);
|
||||||
PROCTYPE_TO_WEBIDL_CASE(WebCOOPCOEP, WithCoopCoep);
|
PROCTYPE_TO_WEBIDL_CASE(WebCOOPCOEP, WithCoopCoep);
|
||||||
PROCTYPE_TO_WEBIDL_CASE(WebServiceWorker, WebServiceWorker);
|
PROCTYPE_TO_WEBIDL_CASE(WebServiceWorker, WebServiceWorker);
|
||||||
|
PROCTYPE_TO_WEBIDL_CASE(Inference, Inference);
|
||||||
|
|
||||||
#define GECKO_PROCESS_TYPE(enum_value, enum_name, string_name, proc_typename, \
|
#define GECKO_PROCESS_TYPE(enum_value, enum_name, string_name, proc_typename, \
|
||||||
process_bin_type, procinfo_typename, \
|
process_bin_type, procinfo_typename, \
|
||||||
@@ -1579,6 +1580,8 @@ already_AddRefed<Promise> ChromeUtils::RequestProcInfo(GlobalObject& aGlobal,
|
|||||||
type = mozilla::ProcType::PrivilegedMozilla;
|
type = mozilla::ProcType::PrivilegedMozilla;
|
||||||
} else if (remoteType == PREALLOC_REMOTE_TYPE) {
|
} else if (remoteType == PREALLOC_REMOTE_TYPE) {
|
||||||
type = mozilla::ProcType::Preallocated;
|
type = mozilla::ProcType::Preallocated;
|
||||||
|
} else if (remoteType == INFERENCE_REMOTE_TYPE) {
|
||||||
|
type = mozilla::ProcType::Inference;
|
||||||
} else if (StringBeginsWith(remoteType, DEFAULT_REMOTE_TYPE)) {
|
} else if (StringBeginsWith(remoteType, DEFAULT_REMOTE_TYPE)) {
|
||||||
type = mozilla::ProcType::Web;
|
type = mozilla::ProcType::Web;
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -775,6 +775,7 @@ enum WebIDLProcType {
|
|||||||
"rdd",
|
"rdd",
|
||||||
"socket",
|
"socket",
|
||||||
"remoteSandboxBroker",
|
"remoteSandboxBroker",
|
||||||
|
"inference",
|
||||||
#ifdef MOZ_ENABLE_FORKSERVER
|
#ifdef MOZ_ENABLE_FORKSERVER
|
||||||
"forkServer",
|
"forkServer",
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -181,6 +181,18 @@ Shared Web Content
|
|||||||
|
|
||||||
The shared web content process is used to host content which is not isolated into one of the other web content process types. This includes almost all web content with Fission disabled, and web content which cannot be attributed to a specific origin with Fission enabled, such as user-initiated ``data:`` URI loads.
|
The shared web content process is used to host content which is not isolated into one of the other web content process types. This includes almost all web content with Fission disabled, and web content which cannot be attributed to a specific origin with Fission enabled, such as user-initiated ``data:`` URI loads.
|
||||||
|
|
||||||
|
|
||||||
|
Inference Content
|
||||||
|
"""""""""""""""""
|
||||||
|
|
||||||
|
:remoteType: ``inference``
|
||||||
|
:default count: 1 (``dom.ipc.processCount.inference``)
|
||||||
|
|
||||||
|
The inference content process is used to isolate inference runtimes, currently ONNX runtime and Bergamot. This process hosts chrome workers that are running WASM runtimes along with some Javascript to perform inference tasks like translation or image-to-text.
|
||||||
|
|
||||||
|
The models can allocate large amounts of memory, which can cause the process to be killed by the OS in memory-constrained environments like Android. This separation ensures other important processes like content processes are not killed.
|
||||||
|
|
||||||
|
|
||||||
Isolated Web Content
|
Isolated Web Content
|
||||||
""""""""""""""""""""
|
""""""""""""""""""""
|
||||||
|
|
||||||
|
|||||||
@@ -2701,6 +2701,8 @@ mozilla::ipc::IPCResult ContentChild::RecvRemoteType(
|
|||||||
SetProcessName("Privileged Content"_ns, nullptr, &aProfile);
|
SetProcessName("Privileged Content"_ns, nullptr, &aProfile);
|
||||||
} else if (aRemoteType == PRIVILEGEDMOZILLA_REMOTE_TYPE) {
|
} else if (aRemoteType == PRIVILEGEDMOZILLA_REMOTE_TYPE) {
|
||||||
SetProcessName("Privileged Mozilla"_ns, nullptr, &aProfile);
|
SetProcessName("Privileged Mozilla"_ns, nullptr, &aProfile);
|
||||||
|
} else if (aRemoteType == INFERENCE_REMOTE_TYPE) {
|
||||||
|
SetProcessName("Inference"_ns, nullptr, &aProfile);
|
||||||
} else if (remoteTypePrefix == WITH_COOP_COEP_REMOTE_TYPE) {
|
} else if (remoteTypePrefix == WITH_COOP_COEP_REMOTE_TYPE) {
|
||||||
// The profiler can sanitize out the eTLD+1
|
// The profiler can sanitize out the eTLD+1
|
||||||
nsDependentCSubstring etld =
|
nsDependentCSubstring etld =
|
||||||
|
|||||||
@@ -20,6 +20,7 @@
|
|||||||
#define EXTENSION_REMOTE_TYPE "extension"_ns
|
#define EXTENSION_REMOTE_TYPE "extension"_ns
|
||||||
#define PRIVILEGEDABOUT_REMOTE_TYPE "privilegedabout"_ns
|
#define PRIVILEGEDABOUT_REMOTE_TYPE "privilegedabout"_ns
|
||||||
#define PRIVILEGEDMOZILLA_REMOTE_TYPE "privilegedmozilla"_ns
|
#define PRIVILEGEDMOZILLA_REMOTE_TYPE "privilegedmozilla"_ns
|
||||||
|
#define INFERENCE_REMOTE_TYPE "inference"_ns
|
||||||
|
|
||||||
#define DEFAULT_REMOTE_TYPE WEB_REMOTE_TYPE
|
#define DEFAULT_REMOTE_TYPE WEB_REMOTE_TYPE
|
||||||
|
|
||||||
|
|||||||
@@ -1985,6 +1985,9 @@ pref("dom.ipc.processCount.webIsolated", 1);
|
|||||||
pref("dom.ipc.processCount.webIsolated", 4);
|
pref("dom.ipc.processCount.webIsolated", 4);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// For now we allow a single inference process
|
||||||
|
pref("dom.ipc.processCount.inference", 1);
|
||||||
|
|
||||||
// Keep a single privileged about process alive for performance reasons.
|
// Keep a single privileged about process alive for performance reasons.
|
||||||
// e.g. we do not want to throw content processes out every time we navigate
|
// e.g. we do not want to throw content processes out every time we navigate
|
||||||
// away from about:newtab.
|
// away from about:newtab.
|
||||||
|
|||||||
@@ -531,6 +531,9 @@ var View = {
|
|||||||
case "utility":
|
case "utility":
|
||||||
fluentName = "about-processes-utility-process";
|
fluentName = "about-processes-utility-process";
|
||||||
break;
|
break;
|
||||||
|
case "inference":
|
||||||
|
fluentName = "about-processes-inference-process";
|
||||||
|
break;
|
||||||
// The following are probably not going to show up for users
|
// The following are probably not going to show up for users
|
||||||
// but let's handle the case anyway to avoid heisenoranges
|
// but let's handle the case anyway to avoid heisenoranges
|
||||||
// during tests in case of a leftover process from a previous
|
// during tests in case of a leftover process from a previous
|
||||||
|
|||||||
@@ -282,7 +282,7 @@ export class EngineProcess {
|
|||||||
const browser = doc.createXULElement("browser");
|
const browser = doc.createXULElement("browser");
|
||||||
browser.setAttribute("id", id);
|
browser.setAttribute("id", id);
|
||||||
browser.setAttribute("remote", "true");
|
browser.setAttribute("remote", "true");
|
||||||
browser.setAttribute("remoteType", "web");
|
browser.setAttribute("remoteType", "inference");
|
||||||
browser.setAttribute("disableglobalhistory", "true");
|
browser.setAttribute("disableglobalhistory", "true");
|
||||||
browser.setAttribute("type", "content");
|
browser.setAttribute("type", "content");
|
||||||
browser.setAttribute("src", url);
|
browser.setAttribute("src", url);
|
||||||
|
|||||||
@@ -38,6 +38,16 @@ async function setup({ disabled = false, prefs = [] } = {}) {
|
|||||||
|
|
||||||
const PIPELINE_OPTIONS = new PipelineOptions({ taskName: "moz-echo" });
|
const PIPELINE_OPTIONS = new PipelineOptions({ taskName: "moz-echo" });
|
||||||
|
|
||||||
|
async function checkForRemoteType(remoteType) {
|
||||||
|
let procinfo3 = await ChromeUtils.requestProcInfo();
|
||||||
|
for (const child of procinfo3.children) {
|
||||||
|
if (child.type === remoteType) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
add_task(async function test_ml_engine_basics() {
|
add_task(async function test_ml_engine_basics() {
|
||||||
const { cleanup, remoteClients } = await setup();
|
const { cleanup, remoteClients } = await setup();
|
||||||
|
|
||||||
@@ -47,6 +57,9 @@ add_task(async function test_ml_engine_basics() {
|
|||||||
info("Get summarizer");
|
info("Get summarizer");
|
||||||
const summarizer = mlEngineParent.getEngine(PIPELINE_OPTIONS);
|
const summarizer = mlEngineParent.getEngine(PIPELINE_OPTIONS);
|
||||||
|
|
||||||
|
info("Check the inference process is running");
|
||||||
|
Assert.equal(await checkForRemoteType("inference"), true);
|
||||||
|
|
||||||
info("Run the summarizer");
|
info("Run the summarizer");
|
||||||
const inferencePromise = summarizer.run({ data: "This gets echoed." });
|
const inferencePromise = summarizer.run({ data: "This gets echoed." });
|
||||||
|
|
||||||
|
|||||||
@@ -47,6 +47,7 @@ enum class ProcType {
|
|||||||
PrivilegedMozilla,
|
PrivilegedMozilla,
|
||||||
WebCOOPCOEP,
|
WebCOOPCOEP,
|
||||||
WebServiceWorker,
|
WebServiceWorker,
|
||||||
|
Inference,
|
||||||
// the rest matches GeckoProcessTypes.h
|
// the rest matches GeckoProcessTypes.h
|
||||||
#define GECKO_PROCESS_TYPE(enum_value, enum_name, string_name, proc_typename, \
|
#define GECKO_PROCESS_TYPE(enum_value, enum_name, string_name, proc_typename, \
|
||||||
process_bin_type, procinfo_typename, \
|
process_bin_type, procinfo_typename, \
|
||||||
|
|||||||
@@ -52,6 +52,7 @@ about-processes-remote-sandbox-broker-process = Remote Sandbox Broker ({ $pid })
|
|||||||
about-processes-fork-server-process = Fork Server ({ $pid })
|
about-processes-fork-server-process = Fork Server ({ $pid })
|
||||||
about-processes-preallocated-process = Preallocated ({ $pid })
|
about-processes-preallocated-process = Preallocated ({ $pid })
|
||||||
about-processes-utility-process = Utility ({ $pid })
|
about-processes-utility-process = Utility ({ $pid })
|
||||||
|
about-processes-inference-process = Inference ({ $pid })
|
||||||
|
|
||||||
# Unknown process names
|
# Unknown process names
|
||||||
# Variables:
|
# Variables:
|
||||||
|
|||||||
@@ -52,6 +52,9 @@ process-type-socket = Socket
|
|||||||
# process used to decode media
|
# process used to decode media
|
||||||
process-type-rdd = RDD
|
process-type-rdd = RDD
|
||||||
|
|
||||||
|
# process used to run inference
|
||||||
|
process-type-inference = Inference
|
||||||
|
|
||||||
# process used to run some IPC actor in their own sandbox
|
# process used to run some IPC actor in their own sandbox
|
||||||
process-type-utility = Sandboxed IPC Actor
|
process-type-utility = Sandboxed IPC Actor
|
||||||
process-type-utility-actor-audio-decoder-generic = Utility Generic Audio Decoder
|
process-type-utility-actor-audio-decoder-generic = Utility Generic Audio Decoder
|
||||||
|
|||||||
@@ -30,6 +30,7 @@ export const ProcessType = Object.freeze({
|
|||||||
// Keys defined in dom/ipc/RemoteType.h
|
// Keys defined in dom/ipc/RemoteType.h
|
||||||
extension: "process-type-extension",
|
extension: "process-type-extension",
|
||||||
file: "process-type-file",
|
file: "process-type-file",
|
||||||
|
inference: "process-type-inference",
|
||||||
prealloc: "process-type-prealloc",
|
prealloc: "process-type-prealloc",
|
||||||
privilegedabout: "process-type-privilegedabout",
|
privilegedabout: "process-type-privilegedabout",
|
||||||
privilegedmozilla: "process-type-privilegedmozilla",
|
privilegedmozilla: "process-type-privilegedmozilla",
|
||||||
|
|||||||
Reference in New Issue
Block a user