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(WebCOOPCOEP, WithCoopCoep);
|
||||
PROCTYPE_TO_WEBIDL_CASE(WebServiceWorker, WebServiceWorker);
|
||||
PROCTYPE_TO_WEBIDL_CASE(Inference, Inference);
|
||||
|
||||
#define GECKO_PROCESS_TYPE(enum_value, enum_name, string_name, proc_typename, \
|
||||
process_bin_type, procinfo_typename, \
|
||||
@@ -1579,6 +1580,8 @@ already_AddRefed<Promise> ChromeUtils::RequestProcInfo(GlobalObject& aGlobal,
|
||||
type = mozilla::ProcType::PrivilegedMozilla;
|
||||
} else if (remoteType == PREALLOC_REMOTE_TYPE) {
|
||||
type = mozilla::ProcType::Preallocated;
|
||||
} else if (remoteType == INFERENCE_REMOTE_TYPE) {
|
||||
type = mozilla::ProcType::Inference;
|
||||
} else if (StringBeginsWith(remoteType, DEFAULT_REMOTE_TYPE)) {
|
||||
type = mozilla::ProcType::Web;
|
||||
} else {
|
||||
|
||||
@@ -775,6 +775,7 @@ enum WebIDLProcType {
|
||||
"rdd",
|
||||
"socket",
|
||||
"remoteSandboxBroker",
|
||||
"inference",
|
||||
#ifdef MOZ_ENABLE_FORKSERVER
|
||||
"forkServer",
|
||||
#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.
|
||||
|
||||
|
||||
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
|
||||
""""""""""""""""""""
|
||||
|
||||
|
||||
@@ -2701,6 +2701,8 @@ mozilla::ipc::IPCResult ContentChild::RecvRemoteType(
|
||||
SetProcessName("Privileged Content"_ns, nullptr, &aProfile);
|
||||
} else if (aRemoteType == PRIVILEGEDMOZILLA_REMOTE_TYPE) {
|
||||
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) {
|
||||
// The profiler can sanitize out the eTLD+1
|
||||
nsDependentCSubstring etld =
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
#define EXTENSION_REMOTE_TYPE "extension"_ns
|
||||
#define PRIVILEGEDABOUT_REMOTE_TYPE "privilegedabout"_ns
|
||||
#define PRIVILEGEDMOZILLA_REMOTE_TYPE "privilegedmozilla"_ns
|
||||
#define INFERENCE_REMOTE_TYPE "inference"_ns
|
||||
|
||||
#define DEFAULT_REMOTE_TYPE WEB_REMOTE_TYPE
|
||||
|
||||
|
||||
@@ -1985,6 +1985,9 @@ pref("dom.ipc.processCount.webIsolated", 1);
|
||||
pref("dom.ipc.processCount.webIsolated", 4);
|
||||
#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.
|
||||
// e.g. we do not want to throw content processes out every time we navigate
|
||||
// away from about:newtab.
|
||||
|
||||
@@ -531,6 +531,9 @@ var View = {
|
||||
case "utility":
|
||||
fluentName = "about-processes-utility-process";
|
||||
break;
|
||||
case "inference":
|
||||
fluentName = "about-processes-inference-process";
|
||||
break;
|
||||
// The following are probably not going to show up for users
|
||||
// but let's handle the case anyway to avoid heisenoranges
|
||||
// during tests in case of a leftover process from a previous
|
||||
|
||||
@@ -282,7 +282,7 @@ export class EngineProcess {
|
||||
const browser = doc.createXULElement("browser");
|
||||
browser.setAttribute("id", id);
|
||||
browser.setAttribute("remote", "true");
|
||||
browser.setAttribute("remoteType", "web");
|
||||
browser.setAttribute("remoteType", "inference");
|
||||
browser.setAttribute("disableglobalhistory", "true");
|
||||
browser.setAttribute("type", "content");
|
||||
browser.setAttribute("src", url);
|
||||
|
||||
@@ -38,6 +38,16 @@ async function setup({ disabled = false, prefs = [] } = {}) {
|
||||
|
||||
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() {
|
||||
const { cleanup, remoteClients } = await setup();
|
||||
|
||||
@@ -47,6 +57,9 @@ add_task(async function test_ml_engine_basics() {
|
||||
info("Get summarizer");
|
||||
const summarizer = mlEngineParent.getEngine(PIPELINE_OPTIONS);
|
||||
|
||||
info("Check the inference process is running");
|
||||
Assert.equal(await checkForRemoteType("inference"), true);
|
||||
|
||||
info("Run the summarizer");
|
||||
const inferencePromise = summarizer.run({ data: "This gets echoed." });
|
||||
|
||||
|
||||
@@ -47,6 +47,7 @@ enum class ProcType {
|
||||
PrivilegedMozilla,
|
||||
WebCOOPCOEP,
|
||||
WebServiceWorker,
|
||||
Inference,
|
||||
// the rest matches GeckoProcessTypes.h
|
||||
#define GECKO_PROCESS_TYPE(enum_value, enum_name, string_name, proc_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-preallocated-process = Preallocated ({ $pid })
|
||||
about-processes-utility-process = Utility ({ $pid })
|
||||
about-processes-inference-process = Inference ({ $pid })
|
||||
|
||||
# Unknown process names
|
||||
# Variables:
|
||||
|
||||
@@ -52,6 +52,9 @@ process-type-socket = Socket
|
||||
# process used to decode media
|
||||
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-type-utility = Sandboxed IPC Actor
|
||||
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
|
||||
extension: "process-type-extension",
|
||||
file: "process-type-file",
|
||||
inference: "process-type-inference",
|
||||
prealloc: "process-type-prealloc",
|
||||
privilegedabout: "process-type-privilegedabout",
|
||||
privilegedmozilla: "process-type-privilegedmozilla",
|
||||
|
||||
Reference in New Issue
Block a user