Closed Bug 1804868 Opened 3 years ago Closed 3 years ago

Create a POC that introduces ZygotePreload API for better memory space usage of content processes

Categories

(GeckoView :: General, task, P1)

All
Android
task

Tracking

(Not tracked)

RESOLVED WORKSFORME

People

(Reporter: kaya, Assigned: kaya)

References

(Depends on 1 open bug, Blocks 1 open bug)

Details

(Whiteboard: [geckoview:m110] [geckoview:m111])

As mentioned in the doc: https://docs.google.com/document/d/1s9AqQ9Ixi-NzoitztuhEeP67-hvcUq7DHDZ6YbiWlS4/edit#heading=h.srfuo4fz9v8i

ZygotePreload api can be introduced to preload libxul to save memory consumption due to memory relocations and loading the code. The isolated content processes will share more code in a CoW way. The prerequisite of this issue is to make the content processes isolated.

Whiteboard: [geckoview:m110]
Severity: -- → N/A
Whiteboard: [geckoview:m110] → [geckoview:m110] [geckoview:m111]
Rank: 110

I was able to make the content processes isolated in A-C and Fenix finally by some local workarounds and bug fixes. Then, I was able to create a custom Zygote process for each of them and loaded some shared native libraries in it. As a result, Zygote POC is finished!
The ZygotePreload api loads the following shared libraries: mozglue and xul. This can be improved by loading nss and sqlite libraries as well which requires more effort and code changes.

The results of the POC (TLDR):
AC (sample browser app) -> around 35 percent decrease [in memory usage] for each content process (foreground and cached) when native libs are preloaded via custom Zygote process.
Fenix -> around 33 percent decrease [in memory usage] for each content process (foreground and cached) when native libs are preloaded via custom Zygote process.
Please note that the experiments are done with simple urls like google.com. I suspected that complex urls (websites with media players etc) may be buggy because the isolated processes are not fully functioning atm. However, as this variable (the url that is loaded) is kept constant for all the experiments, the results are also consistent/valid and showing the difference between "when Zygote preload api exits" and "when not".

For the detailed analysis results please visit Q&A document: https://docs.google.com/document/d/1s9AqQ9Ixi-NzoitztuhEeP67-hvcUq7DHDZ6YbiWlS4/edit#heading=h.i4h3wu7l4tgx.

What is up next?
1- Enable isolated process flag i.e make the content processes isolated. (https://bugzilla.mozilla.org/show_bug.cgi?id=1565196)
2- As this POC had proven itself with promising local results as a starter, we can take it into the codebase considering additional security implementations!.

Status: NEW → RESOLVED
Closed: 3 years ago
Resolution: --- → WORKSFORME
You need to log in before you can comment on or make changes to this bug.