fenix icon indicating copy to clipboard operation
fenix copied to clipboard

Look into whether or not some part of Glean initialization can be done separately, or later after start up to reduce start up time.

Open Malclir opened this issue 6 years ago • 5 comments

Why/User Benefit/User Problem

Current Glean implementation takes a big chunk of start up time ( ~10-20% at times). I think we should try to see if we can offload some of it to after initialization, or maybe some to a worker thread. I am aware that Glean needs to register observers on the UI thread, but I think it would be worthwhile to investigate for a bit.

Impact

Faster start up time means better quality of use

Acceptance Criteria (how do I know when I’m done?)

Glean still behaves as expected but app start up is faster.

┆Issue is synchronized with this Jira Task

Malclir avatar Dec 17 '19 22:12 Malclir

The situation is actually a little different than that:

Glean initialization is mostly done asynchronously. However, it still must be done on the main thread. After the asynchronous task is created, the blocking part of the its initialization completes and startup continues. However, the problem is that the coroutine gets scheduled to execute on the main thread before the application has finished drawing. There is a "break" between when the app starts to draw and when it finishes (in order to pass control over to a separate handler method that does measurements for a particular type of layout). It is during that time that the asynchronous part of Glean completes. That means, however, that the app does not finish drawing until after Glean finishes starting up.

<------------------------------------------------------------------------------------------------------------------>
application startup | begin drawing |                        | measurement | visual completeness.
   <-glean start->                      <-glean finish->
           async

At least that is the hypothesis.

hawkinsw avatar Dec 17 '19 22:12 hawkinsw

The situation is even worse for the Applink case. Glean initialization is run after FenixApplication.onCreate() but before (the bulk of) HomeActivity.onCreate() executes and, most importantly, before GeckoView starts to load the URL.

hawkinsw avatar Dec 18 '19 08:12 hawkinsw

Most of the Glean initialization is quick but the two "bottlenecks" were the AC Migration and the GLean Scheduler which was mostly a string manipulation error. Here are the two bugzilla tickets that address those issues:

  1. AC migration
  2. String manipulation

@mcomella I'll close this since the first issue takes ~25% and the second ~37%. Fixing those two could reduce Glean start up by more than 50%. It might be hard to play more with Glean initialization since the rest has to be done on the MT ( most of it at least) and might only gain us an extra few % of Glean initialization. I think this would be too risky for the rewards we'd get.

Malclir avatar Jan 06 '20 20:01 Malclir

@MarcLeclair Thanks for investigating: I'm happy to close this issue.

I noticed 2 was closed: has it made it into Nightly? I'm curious if it has impacted our performance numbers, e.g. ND or FNPRMS. ND looks a little too noisy to tell though.

Would you mind filing issues in Fenix for 1 (linking to the Bugzilla tickets) and adding them to our project board so we can remember to monitor for changes in ND/FNPRMS? I assume it should go in the Waiting column.

mcomella avatar Jan 08 '20 02:01 mcomella

Moved to Done: I assume this can be closed.

mcomella avatar Jan 13 '20 19:01 mcomella