Closed
Bug 837111
Opened 12 years ago
Closed 12 years ago
Minify js source
Categories
(Firefox OS Graveyard :: Gaia, defect)
Tracking
(blocking-b2g:tef+, b2g18+ fixed, b2g18-v1.0.1 fixed)
RESOLVED
FIXED
blocking-b2g | tef+ |
People
(Reporter: jrmuizel, Assigned: vingtetun)
References
Details
(Whiteboard: [FFOS_perf] QARegressExclude)
Attachments
(2 files, 1 obsolete file)
13.59 KB,
patch
|
vingtetun
:
review+
|
Details | Diff | Splinter Review |
135.36 KB,
patch
|
Details | Diff | Splinter Review |
It looks like we currently do not minify our js source code. Minify it should help with memory usage and improve startup time because of less time spent parsing and compressing the source.
Reporter | ||
Updated•12 years ago
|
blocking-b2g: --- → tef?
Comment 1•12 years ago
|
||
Bug 813396 landed opt-in support for concatenation on gaia/master:
https://github.com/mozilla-b2g/gaia/commit/53c83ac323095856522bc00aa41d20fda1594224
Only calendar was opted in.
For e-mail, we ran into the problem that minifiers based on performing full parse passes would break on us because they do not understand the entire 'dialect' of JS that SpiderMonkey understands. Some of the ActiveSync code-base uses a combination of ES6-expected-legal stuff and possibly a few Mozilla-specific JS1.7+-isms. https://bugzilla.mozilla.org/show_bug.cgi?id=812396#c0 implies that 'mince' should work, so I'll give it a spin, but otherwise I've had bad luck and would appreciate being pointed at known usable things.
See Also: → 812396
Reporter | ||
Comment 2•12 years ago
|
||
(In reply to Andrew Sutherland (:asuth) from comment #1)
> Some of the ActiveSync
> code-base uses a combination of ES6-expected-legal stuff and possibly a few
> Mozilla-specific JS1.7+-isms.
How easy is it remove the use of these features?
Comment 3•12 years ago
|
||
(In reply to Jeff Muizelaar [:jrmuizel] from comment #2)
> How easy is it remove the use of these features?
Easy compared to the alternatives, but I just got the node-jsmin2 port variant from https://github.com/twolfson/node-jsmin2 of Crockford's (C implemented) jsmin working on e-mail. jsmin is fairly naive and just eats whitespace and comments, which seems generally desirable anyways as compared to variable renaming. I did verify that it does not suffer from the "+ ++" => "+++" problem in the primary node-jsmin port.
The results aren't horrible and seem to work for me when I run with it:
gaia-email-opt.js: 1,277,298
gaia-email-opt.min.js: 582,173
Changes are on:
https://github.com/mozilla-b2g/gaia-email-libs-and-more/pull/119
We could change the ActiveSync code to allow a more extreme minifier to run, but more legwork would be required to be able to run our back-end unit tests to verify there is no breakage.
Other options in terms of better integrating with gaia and branching would be to run with https://github.com/mozilla-b2g/gaia-email-libs-and-more/pull/86 which copies over the files individually, and then concatenate/minify within gaia proper. We might need some enhancements to the concatenation logic to support before/after stuff if it doesn't have it now, since we'd still want to net out to the same thing.
Assignee | ||
Comment 4•12 years ago
|
||
This seems to have a positive impact on all apps. So let's add that to the build system directly.
Assignee: nobody → 21
Attachment #710697 -
Flags: review?(poirot.alex)
Comment 5•12 years ago
|
||
Comment on attachment 710697 [details] [diff] [review]
Patch - add a simple minifier in the build system
Review of attachment 710697 [details] [diff] [review]:
-----------------------------------------------------------------
::: Makefile
@@ -338,4 @@
> const GAIA_INLINE_LOCALES = "$(GAIA_INLINE_LOCALES)"; \
> const GAIA_ENGINE = "xpcshell"; \
> '; \
> - $(XULRUNNERSDK) $(XPCSHELLSDK) -e "$$JS_CONSTS" -f build/utils.js "build/$(strip $1).js"
Could you use subScriptLoader in JS instead of hacking the makefile?
With something similar to what is done for l10n module.
Something like this:
let scope = {};
Services.scriptloader.loadSubScript('file:///' + GAIA_DIR +
'/build/jsmin.js?reload=' + new Date().getTime(), scope);
const { JSMin } = scope;
Attachment #710697 -
Flags: review?(poirot.alex) → review+
Assignee | ||
Comment 6•12 years ago
|
||
I would like to land that on v1-train. This makes app launch faster globally. The risks is that some JS is written in a way that the minifier does not like and an error can happens. The minifier used is normally not very risky (it does not rename anything for example, just remove whitespaces and comments) but this risk always exists... So if something wrong happens once this patch lands it will always be possible to add an application to a blacklist that will resolves the issue immediatly.
Assignee | ||
Comment 7•12 years ago
|
||
Here the patch that address the review comments.
Attachment #710697 -
Attachment is obsolete: true
Attachment #710730 -
Flags: review+
Comment 8•12 years ago
|
||
Any information about performances ?
We are concern that if this patch lands we will have all errors pointed on line 1 and it will be difficult to see were the bug comes from.
Flags: needinfo?(21)
Comment 9•12 years ago
|
||
The minifier maintains newlines.
Comment 10•12 years ago
|
||
Also, it's capable of generating source-map info for tools that consume it.
Assignee | ||
Comment 11•12 years ago
|
||
(In reply to David Scravaglieri [:scravag] from comment #8)
> Any information about performances ?
> We are concern that if this patch lands we will have all errors pointed on
> line 1 and it will be difficult to see were the bug comes from.
I'm concerned about the losing some informations as well. Someone needs to spend time playing with the map generated by the minifier but it could be done in a followup.
Flags: needinfo?(21)
Assignee | ||
Comment 12•12 years ago
|
||
fba586f468f6ac035f5c3e61e25e43d8fea7896f
Assignee | ||
Comment 13•12 years ago
|
||
As soon the bug 837139 lands I will be able to give more informations about the win here...
Assignee | ||
Comment 14•12 years ago
|
||
Comment 15•12 years ago
|
||
Interesting, I think I posted
Comment 16•12 years ago
|
||
If we do end up taking this bug for v1.0.1, we'll need to take bug 839574 as well.
Reporter | ||
Updated•12 years ago
|
Blocks: Email-Startup
Comment 17•12 years ago
|
||
Given where we are in the cycle, we'll track instead of block a specific release.
blocking-b2g: tef? → -
tracking-b2g18:
--- → +
(In reply to Vivien Nicolas (:vingtetun) (:21) from comment #13)
> As soon the bug 837139 lands I will be able to give more informations about
> the win here...
Looks like it landed. What's the news?
Comment 19•12 years ago
|
||
This does not seem to be in v1-train yet, while it's tracking+.
Comment 21•12 years ago
|
||
Uplifted Bug 812396 myself, so please go ahead (hoping there is no conflict).
Comment 22•12 years ago
|
||
So, for John, the first patch landed in fba586f468f6ac035f5c3e61e25e43d8fea7896f
I'll resolve this bug and file a new one for the second patch, to make things clearer.
Status: NEW → RESOLVED
Closed: 12 years ago
Resolution: --- → FIXED
Comment 23•12 years ago
|
||
(re: tef?, do we know how much perf win this gives us?)
Comment 24•12 years ago
|
||
(tef- for now as looks like we've already encountered one regression, bug 839574. so unless the perf wins are amazing I don't think we want the risk)
blocking-b2g: tef? → -
Comment 25•12 years ago
|
||
The results are quite different depending on the app.
This patch does indeed 2 things:
- add a minifier
- concatenates all js files for all apps (previously, this was done only for calendar)
For most apps we gain between 50 and 150ms, but for email this is 300ms, going from ~2200 to ~1900ms.
Even calendar that profits only from minification seems to gain ~70ms.
However merely cherry-picking this makes the FTU fail, I'll track this down before asking for tef? again.
Comment 26•12 years ago
|
||
FTU fail was caused by Bug 842249.
I feel that taking this bug with Bug 842249 and Bug 839574 is safe (several of our developers are running with this configuration for more than 1 month already) and makes enough improvement that we want it.
You might want Bug 840455 and Bug 841852 as well, as they add a GAIA_OPTIMIZE flag that you can turn off easily in the Makefile if necessary.
ask for tef? again then.
Comment 27•12 years ago
|
||
Okay thanks, yeah that's quite significant! So I'm thinking that we don't want bug 840455 or bug 841852 on v1.0.1 because I'd prefer that the minifier be enabled in all builds for v1.0.1 by default to give us a better chance of catching any regressions introduced by this patch quicker (at the cost of reduced debugability, feedback on this trade off more than welcome!)
blocking-b2g: tef? → tef+
Comment 28•12 years ago
|
||
More information on this:
with bug 840455 and bug 841852, the optimizer is still turned on by default with |make production| or |make dogfood|.
I admit I don't know much how your builds are done :)
Flags: needinfo?(mvines)
Comment 29•12 years ago
|
||
We use the stock android build system with no build.sh thinger. PRODUCTION=1 is enabled by gaia/Android.mk for -user and -userdebug builds, which is almost enough. I'd like this enabled for -eng builds as well on v1.0.1 cause some devs like to use -eng still, so they can, ummm, enjoy any bustage as well.
Flags: needinfo?(mvines)
Updated•12 years ago
|
status-b2g18-v1.0.1:
--- → affected
Comment 30•12 years ago
|
||
v1-train: 41fe27646971241cae65a51712fb0f1611a9fc38
v1.0.1: 0bf2642f7ee4d053f7662dcd0c817105900ed726
Comment 32•12 years ago
|
||
Cannot verify, need steps to blackbox test this issue.
Comment 33•12 years ago
|
||
nothing to test here, just that the apps start faster than before.
You need to log in
before you can comment on or make changes to this bug.
Description
•