Last Comment Bug 684443 - Make unpacking files from the APK faster
: Make unpacking files from the APK faster
: mobile, perf
Product: Core
Classification: Components
Component: Widget: Android (show other bugs)
: unspecified
: x86 Linux
: -- normal (vote)
: mozilla9
Assigned To: Nobody; OK to take it and work on it
Depends on:
  Show dependency treegraph
Reported: 2011-09-02 20:51 PDT by Mark Finkle (:mfinkle) (use needinfo?)
Modified: 2011-09-05 11:48 PDT (History)
1 user (show)
See Also:
Crash Signature:
QA Whiteboard:
Iteration: ---
Points: ---
Has Regression Range: ---
Has STR: ---

patch (2.83 KB, patch)
2011-09-02 20:51 PDT, Mark Finkle (:mfinkle) (use needinfo?)
dougt: review+
Details | Diff | Review

Description Mark Finkle (:mfinkle) (use needinfo?) 2011-09-02 20:51:21 PDT
Created attachment 558026 [details] [diff] [review]

During a firstrun after installing or updating, Firefox Mobile will extract a small set of files out of the APK to the filesystem. We do this because some parts of Gecko can't load those resources from a JAR. Examples currently include:
* application.ini and other app/update files (these are usually small)
* Add-on XPIs
* Hyphenation files (these are usually large and we have ~20 files)

Once these files are extracted, subsequent launches skip the unpacking stage.

This patch streamlines the unpacking method:
* Moves the splash screen update out of the function. We don't need to render the splash screen for each file. Once is enough.
* Drops a file.exist() check since the file.lasModified() check will accomplish the same thing.
* Fixes a bug where we attempt to create the parent directory structure, if it doesn't exist. The current code checks to see if the new file exists and if it doesn't, we create the parent directories. This will always fail, so we always attempt to create the parent directories, This hurts when 20+ files are in the same folder.
* Increases the buffer from 8KB to 32KB. The hyphenation files are usually >100KB, so a larger buffer helps a little.
* Moves the check for zombies outside the unpack function. We only want to check once anyway.

Using this patch, I tested the unpacking time on 3 devices. I made 3 runs, and had to uninstall/reinstall before each run, so the unpacking process was forced to happen. Below are the averages of the 3 runs, with and without the patch

device      w/o      w/       improvement
Galaxy Tab  8206ms   7058ms   1148ms
Nexus One   1727ms   1353ms    374ms
Acer A500    615ms    144ms    451ms

Remember, this is just the unpacking time, not the complete time for startup. The patch makes a sizeable dent in firstrun startup time after install/update.
Comment 1 Mark Finkle (:mfinkle) (use needinfo?) 2011-09-05 07:11:57 PDT
Comment 2 :Ehsan Akhgari (busy, don't ask for review please) 2011-09-05 11:48:01 PDT

Note You need to log in before you can comment on or make changes to this bug.