Closed Bug 1129563 Opened 5 years ago Closed 5 years ago

Reduce startup time by avoiding mozHasPendingMessages()


(Firefox OS Graveyard :: Gaia::Gallery, defect)

Not set


(b2g-v2.2 fixed, b2g-master fixed)

2.2 S5 (6feb)
Tracking Status
b2g-v2.2 --- fixed
b2g-master --- fixed


(Reporter: djf, Assigned: djf)




(1 file)

Gallery calls mozHasPendingMessages() to see whether it was invoked as the result of a pick activity. That turns out to be somewhat expensive, and it is easier and faster to just check for window.location.hash === '#pick'.  So let's make that change.
Assignee: nobody → dflanagan
Blocks: 1127078
My baseline startup time stats on a 1gb Flame running today's nightly, and a dozens of random photos and videos:

STARTUP (ms) t: 1135 t̄: 1159 σ: 38 n: 15 median: 1161 min: 1091 max: 1231 

This means that over 15 trials, the average startup time was 1159ms with a standard deviation of 38ms. During the test, two trials were discarded because the startup time was greater than two standard deviations above average and I assume the phone happened to be busy doing something in the background for those.
With this simple patch I'm about to attach, I get these startup stats:

STARTUP (ms) t: 1112 t̄: 1134 σ: 57 n: 30 median: 1120 min: 1043 max: 1238 

I had to run 30 trials instead of 15 because there were some long startup times in the early trials. So I started out with a high standard deviation and the outliers didn't get discarded until I'd run enough trials to bring the deviation down.
Comment on attachment 8559403 [details] [review]
[PullReq] davidflanagan:bug1129563 to mozilla-b2g:master

Punam, would you review this, please?

I'm hoping to uplift this to 2.2, so it is relatively high priority.
Attachment #8559403 - Flags: review?(pdahiya)
Another round of testing to confirm that this patch does substantially improve startup time on Flame:

STARTUP (ms) t: 1203 t̄: 1117 σ: 47 n: 15 median: 1108 min: 1025 max: 1203
Hi David

I used the utility ( to record start up time improvements. Here are the numbers:
On latest master:
Content JS LOG: STARTUP (ms) t: 1059 t̄: 1193 σ: 99 n: 20 median: 1173 min: 1056 max: 1383 

With the patch:
Content JS LOG: STARTUP (ms) t: 1144 t̄: 1080 σ: 50 n: 20 median: 1076 min: 1000 max: 1168 

Patch looks good, a nit noted in github and with that it looks good to land. Thanks!
Noticed that gaia-try hasn't run on attached patch, not sure why, hopefully your updated patch gets picked by gaia-try.
Attachment #8559403 - Flags: review?(pdahiya) → review+
Keywords: checkin-needed
Closed: 5 years ago
Resolution: --- → FIXED
Comment on attachment 8559403 [details] [review]
[PullReq] davidflanagan:bug1129563 to mozilla-b2g:master

This patch improves gallery startup time. It is not specifically quad-core related, but should help us meet CAF's quadcore startup time goals.

[Approval Request Comment]
[Bug caused by] (feature/regressing bug #): not a regression

[User impact] if declined: gallery app startup will be slower than necessary

[Testing completed]: yes

[Risk to taking this patch] (and alternatives if risky): a trivial change that should be completely safe. Gallery should have done this long ago.

[String changes made]: none
Attachment #8559403 - Flags: approval-gaia-v2.2?(bbajaj)
Attachment #8559403 - Flags: approval-gaia-v2.2?(bbajaj) → approval-gaia-v2.2+
You need to log in before you can comment on or make changes to this bug.