zygote pre-loads just under 2000 classes, and instantiates them in its heap

controlled by file:

package manager package scan

EVERY package is scanned at boot time

Very deep nesting, with abstraction

Not sure of exact set of purposes

But I see validation of certificates, permissions, capabilities and dependencies, etc.

Very difficult to trace

It bounces between java, c++ and kernel

And uses mmaped files (meaning accesses cause page faults)!!

So it's not even using syscalls for reading the data

Package scan call tree

[put call tree here]

parseZipArchive()

evil routine that builds an in-memory data structure for accessing a package file

scans the entire package, checking the content headers

caused read of almost entire package

touches every page in mmaped file, even if a sub-file in the archive won't be read later

e.g. entire package is scanned, when only the AndroidManifest.xml file is requested

new Resources()

reads all resources in a file

is this really necessary?

Ideas for Enhancements

First, a side note on toothpaste..

kernel speedups

optimize package scan

optimize class preloading

miscellaneous optimizations

sreadahead??

Toothpaste

Problem with optimizations are that reduction in one area causes some other problem (either in speed or size) in some other area

i.e. when you squeeze the tube of toothpaste, it just moves somewhere else, and doesn't actually come out the end

This is demonstrated with class preloading and page cache effects

I tried to improve things, but the I/O delays just moved somewhere else in the system, sometimes making things worse

e.g. AutoText - eliminated and gained 4 seconds during class preloading, but /system/frameworks/frameworks-res.apk was just loaded later in the boot

e.g. Contacts.apk - moved AndroidManifest.xml to its own package, to avoid reading the entire (1.6M) package to read this one file, but next reference to contents of Contacts.apk caused the index rebuild again (costing the entire page cache load)