reduce android boot time

499 views
Skip to first unread message

vkmgeek

unread,
Apr 26, 2010, 8:16:44 AM4/26/10
to android-platform
Hi ,

We try to do preloading of the classes in the zygote to share them
between app processes.
But the time to do preload takes about 23 seconds, which is a
significantly long time.

I am trying to reduce Android boot time. I am thinking about
following approaches.

1: First of all , preloading of the classes is sequential , can we
not do that in parallel ?
We came across a discussion , where forking of a thread in Zygote
is a strict no no ....
"http://osdir.com/ml/android-platform/2009-07/msg00271.html"

2: Also we preload the class only when as found in "$(MYDROID)/
frameworks/base/tools/preload
/WritePreloadedClassFile.java"

That is the list is created to optimize as much as possible both
the startup time of apps and
the per-process overhead of them.

Which means that we just can't go and cut down some of the
classes to reduce the boot time because then it will
significantly affect application launch time.
But can this list change based on my device configuration which
is having 1GHz CPU and much RAM? How?

3 : Can we create a service to do this in the background ?
But in this are the preloaded classes shared umongst the
different applications ?

ie : We try to preload the classes in Zygote just before it
forks so that the preloded classes will be in the shared
memory and hence every application will use classes the
same shared memory. But how can this be achieved
when we create a service in the background ?

Or any other options? approach? Your any help/pointers would be
appreciated.

Thanks,
Smital Desai

--
You received this message because you are subscribed to the Google Groups "android-platform" group.
To post to this group, send email to android-...@googlegroups.com.
To unsubscribe from this group, send email to android-platfo...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/android-platform?hl=en.

fadden

unread,
Apr 27, 2010, 7:39:00 PM4/27/10
to android-platform
On Apr 26, 5:16 am, vkmgeek <viral....@gmail.com> wrote:
> 1:  First  of all , preloading of the classes is sequential , can we
> not do that in parallel ?
>      We came across a discussion , where forking of a thread in Zygote
> is a strict no no  ....
>     "http://osdir.com/ml/android-platform/2009-07/msg00271.html"

The zygote is one thread in one process. Unless there's a lot of disk
activity, you're not going to get a performance boost on a single-CPU
system while pre-loading classes.


> 2:  Also we preload the class only when as found in "$(MYDROID)/
> frameworks/base/tools/preload
>      /WritePreloadedClassFile.java"
....
>      But can this list change based on my device configuration which
> is having 1GHz CPU and much RAM? How?

There are two costs, class loading and class initialization. It's
usually class init that hurts -- some of the initializers (e.g. some
of the SSL stuff) take a long time. You want to pay this cost once
for a class that gets used a lot.

Loading and initializing expensive classes usually takes longer during
app startup, because there's a lot of other stuff going on in the
system. Right after boot up there isn't a lot of RAM in use, but when
an app starts it might be necessary for the kernel to evict some pages
(or kill a process) to make room for the new stuff. So init times
tend to multiply.

Of course, you don't want to pre-load too much, because not all apps
need all classes, and it slows down boot time and takes away from the
16MB or 24MB that each app has to play in.

It's more art than science. :-)


> 3 : Can we create a service to do this in the background  ?

No, because the zygote is the point from which everything else starts,
and if we don't do the preload up front then we won't do a very good
job of sharing the loaded classes. The preload needs to finish before
we start sprouting apps.
Reply all
Reply to author
Forward
0 new messages