Question about preload class.

1,142 views
Skip to first unread message

Neo

unread,
Feb 14, 2011, 8:59:50 PM2/14/11
to android-platform
I found that class preload was changed in Gingerbread.
In the source code "frameworks\base\tools\preload
\WritePreloadedClassFile.java"

Froyo was only check whether at least 2 processes are sharing or not.
(with >MIN_LOAD_TIME_MICROS)
But Gingerbread is also preload the class if the class is shared more
than MIN_PROCESS.
Without considering MIN_LOAD_TIME_MICROS.

Then, I think that Gingerbread could load more classes than Froyo, is
right??
Second question is that, how to calculate class load time in build
time?
Last, how to know how many processes could load the class in build
time?

Jesse Wilson

unread,
Feb 15, 2011, 5:48:09 PM2/15/11
to android-...@googlegroups.com
Neo,

The classes that get preloaded in a given release is defined in frameworks/base/preloaded-classes. That list is created using on-device class load time & space measurements that you can collect by following these steps:

1. Set LOG_CLASS_LOADING to 1 in dalvik/vm/oo/Class.c
2. Disable preloading in frameworks/base/core/java/com/android/internal/os/ZygoteInit.java by commenting out the call to preloadClasses()
3. Rebuild. If nothing else has changed, you can avoid rebuilding everything.
make -j8 dalvikvm framework snod
4. Push to device.
adb reboot bootloader && fastboot -w flashall

This will cause class loading to be logged to logcat. Feeding that output into the tools in frameworks/base/tools/preload will generate a new preloaded classes list.

The list's size has changed from release to release but not by very much. Selecting the tuning parameters for the preloading heuristic is a black art. Our goal is to balance how many applications can be resident in memory at one time with how quickly applications start up. They get tweaked from release to release with the current parameters performing reasonably well. I've found that devices with lots of memory don't benefit as much from class preloading as earlier devices.

If you've found a set of tuning parameters that work better than what's checked in, I'd love to see a patch.

Cheers,
Jesse

Neo

unread,
Feb 15, 2011, 11:35:51 PM2/15/11
to android-platform
That's exactly what I want.
Thanks for the help. :)

Rajput

unread,
Mar 4, 2011, 9:38:28 AM3/4/11
to android-platform
Hi Jesse,

Very interesting.
While Compiling the raw logcat using preload.jar I am unable to get
any memory usage information.

sudo java -cp out/host/linux-x86/framework/preload.jar Compile /home/
singhg/logcat.txt /home/singhg/logcat.compiled
is throwing the following errors.

Error getting stats for android.app.IInstrumentationWatcher$Stub.
java.io.IOException: Cannot run program "adb": java.io.IOException:
error=2, No such file or directory
at java.lang.ProcessBuilder.start(ProcessBuilder.java:460)
at java.lang.Runtime.exec(Runtime.java:593)
at java.lang.Runtime.exec(Runtime.java:466)
at MemoryUsage$MeasureWithTimeout.measure(MemoryUsage.java:
232)
at MemoryUsage$MeasureWithTimeout.run(MemoryUsage.java:213)
at java.lang.Thread.run(Thread.java:619)
Caused by: java.io.IOException: java.io.IOException: error=2, No such
file or directory
at java.lang.UNIXProcess.<init>(UNIXProcess.java:148)
at java.lang.ProcessImpl.start(ProcessImpl.java:65)
at java.lang.ProcessBuilder.start(ProcessBuilder.java:453)
... 5 more

Is there a particular environment that the preload.jar file should be
executed in or any parameters I'm missing here. I am mostly
experienced in kernel and middleware - Java novice :)

Regards

je...@swank.ca

unread,
Mar 5, 2011, 6:51:25 AM3/5/11
to android-...@googlegroups.com
These tools expect to be from the Android build tree, where the $PATH will contain 'adb' etc.

aditya kumar

unread,
Feb 22, 2018, 11:39:48 AM2/22/18
to android-platform
Hi Jesse,

In android O, below folder is not available. Do you know any option in Android O to get the information on preloading of classes with disable preloadClasses() function.

Regards,
Aditya
Reply all
Reply to author
Forward
0 new messages