Performance : regression on performance startup between 12/12 and 12/13

RESOLVED FIXED in Firefox 11



Firefox for Android
6 years ago
6 years ago


(Reporter: nhirata, Assigned: kats)



12 Branch
Firefox 12

Firefox Tracking Flags

(firefox11 fixed, firefox12 fixed, fennec11+)



(1 attachment)

It seems like the regression between 12/12 to 12/13 is due to this change set.  I'm unsure exactly why. – Mon Dec 12 06:17:41 2011 PST (compare: )List changeset URLsSelf-serve Build API

    Kartikaya Gupta – Bug 708683 - Improve JSON generation by using JSONStringer. r=pcwalton a=java-only
    Kartikaya Gupta – Bug 708683 - Fix NaN viewport values. r=pcwalton

See the Chart at R/50 located here:

Steps to reproduce the performance test can be found :
Assignee: nobody → bugmail.mozilla
See Also: → bug 713775
Keywords: perf
Priority: -- → P1
Ok, so I've been looking at the data on that chart and I'm a little confused. From what I understand, the chart consists of 7 data points, which are average load times. The averages are taken from different builds (according to the chronologically increasing timestamp values) in order to isolate the exact changeset that introduced a regression. However, the averages are also considering different page loads. The first two times (rows 50 and 60) are of "warm - local file - onload". The next one (row 80) is "warm - local network - onload", same as row 70, which is the 6th data point on the chart. And so on. The page being loaded (startup5 vs favorites2) is also different, and I can't make any sense of this.

I loaded the dec 12 and dec 13 nightlies on my Galaxy Tab and tried to reproduce the performance measurements, and I found that the dec 13 nightly loaded startup5.html significantly faster than the dec 12 nightly - dec 12 took avg=948.4ms and dec 13 took avg=601.9ms. So basically I found a performance improvement rather than a regression.

nhirata, could you please clarify how you isolated those two changes and what the data in the spreadsheet represents?
row 50, 60, 70, 80 were incorrect.  I have corrected them; I had duplicated a previous spreadsheet and tried to get the numbers in quick.  They are all run with the local file, startup5.html.  You will have to take into account to throw away the first value and run it multiple times as indicated in the directions found in  

These values were taken on the nexus s, which I believe is a neon processor:;  That may make a difference in terms of time.
Thanks, the data makes a little more sense now. However I would still like to know which build corresponds to which changeset. Next to the cell, there is a note saying "Backed out in 50a9ea86cd44", which leads to me to believe that corresponds to dougt's changesets shown at and therefore the corresponds to the backout changeset at This means one of the last two builds listed correspond to my changes, but the performance data indicates that both of those builds are faster than their respective previous builds.

So if anything, it seems like the regression was introduced *before* my changes. Please let me know if my analysis is incorrect.

It's just that I looked closely at the two changes and it seems unlikely to me that either of them would significantly impact load time - it's possible that the JSON stringification got a little slower, but as it's used very infrequently during browser startup and page load, it shouldn't really be noticeable.
There are 2 pushes that I missed prior to dougt's pushes:
1323671178 -
1323680178 -

I'll check those out.
tracking-fennec: --- → 11+
Thanks for updating the spreadsheet, the data makes sense now. Quick summary for my future self revisiting this bug:

Changeset 1e81f179adf2 had an average load time of 2598.3571428572
Changeset bcc015450e7a had an average load time of 2463.0714285714
Changeset 73979783bac9 had an average load time of 2661.4285714286

Between 1e81f179adf2 and 73979783bac9 there were a net of 4 patches that went in (of which two were mine). There were also 4 patches by dougt that went in and were reverted. Therefore the jump from 2598 -> 2661 must have been caused by those 4 patches. There is also the 2463 time from bcc015450e7a, which contains the 2 patches that weren't mine and dougt's 4 patches. So either my patches caused the regression, or it came from one of the other two and dougt's changes caused an improvement so big that it cancelled out the regression and still managed to improve performance.

I'll look at my patches again to see how they could impact startup page/load time.
So using the JSONStringer (as in 73979783bac9) takes about 3x the time as the old manual string method. I don't think it gets called that often during startup anymore (it used to be called more often before) but I can optimize it anyway.
why did we switch to JSONStringer?
(In reply to Brad Lassey [:blassey] from comment #7)
> why did we switch to JSONStringer?

Partly because the code was cleaner, and partly because it would catch attempts to serialize NaN earlier (on the Java side, rather than in browser.js).

I wrote a few different versions of this and compared them to the old way we were doing things. Using an appropriately-sized StringBuffer resulted in a slight speed gain, but using a simple JSONSerializer class (which is much simpler than JSONStringer) was still slow. This makes me think that most of the extra overhead is actually in function calls.

I'll have a patch up shortly with the StringBuffer version, which is faster than the original version we had.
Created attachment 589960 [details] [diff] [review]
Remove JSONStringer for being slow
Attachment #589960 - Flags: review?(
Comment on attachment 589960 [details] [diff] [review]
Remove JSONStringer for being slow

Review of attachment 589960 [details] [diff] [review]:

Looks good, though is 128 characters enough? I count 114 characters needed for the viewport string without the numbers, then there are 9 numbers - leaving 14 characters for them. This leads me to think that the StringBuffer will always be expanded, would it make sense to make the initial size 256?
Attachment #589960 - Flags: review?( → review+
Good catch, changed to 256 on landing.
status-firefox11: --- → affected
status-firefox12: --- → fixed
Target Milestone: --- → Firefox 12
Last Resolved: 6 years ago
Resolution: --- → FIXED
Comment on attachment 589960 [details] [diff] [review]
Remove JSONStringer for being slow

[Approval Request Comment]
Regression caused by (bug #): bug 708683
User impact if declined: performance regression
Testing completed (on m-c, etc.): on m-c
Risk to taking this patch (and alternatives if risky): minor risk that I screwed something up during JSON serialization, which would result in a corrupt viewport (gray screen instead of page). should have showed up pretty early if that were the case though.
Attachment #589960 - Flags: approval-mozilla-aurora?
Comment on attachment 589960 [details] [diff] [review]
Remove JSONStringer for being slow

[Triage Comment]
Mobile only - approved for Aurora.
Attachment #589960 - Flags: approval-mozilla-aurora? → approval-mozilla-aurora+
status-firefox11: affected → fixed
You need to log in before you can comment on or make changes to this bug.