Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

r.js 2.1.3 (and greater) is four times slower than 2.1.2 #451

Closed
mdaniel opened this issue May 24, 2013 · 6 comments
Closed

r.js 2.1.3 (and greater) is four times slower than 2.1.2 #451

mdaniel opened this issue May 24, 2013 · 6 comments

Comments

@mdaniel
Copy link

mdaniel commented May 24, 2013

$ wget -O r-2.1.2.js https://github.com/jrburke/r.js/raw/2.1.2/dist/r.js
$ time /usr/bin/node r-2.1.2.js -o target/js-config/app.build.js
real    1m9.357s
user    1m8.717s
sys 0m0.498s
$ wget -O r-2.1.3.js https://github.com/jrburke/r.js/raw/2.1.3/dist/r.js
$ time /usr/bin/node r-2.1.3.js -o target/js-config/app.build.js
real    4m31.063s
user    4m29.710s
sys 0m0.876s
https://raw.github.com/jrburke/r.js/2.1.4/dist/r.js
real    4m27.894s
user    4m26.718s
sys 0m0.743s
https://raw.github.com/jrburke/r.js/2.1.5/dist/r.js
real    4m27.136s
user    4m26.043s
sys 0m0.698s
https://raw.github.com/jrburke/r.js/2.1.6/dist/r.js
real    4m40.676s
user    4m39.208s
sys 0m0.895s

This is with nodejs v0.10.7, Linux amd64.

app.build.js is {
"optimize": "uglify2"
, "optimizeCss": "standard"
, "generateSourceMaps":true
, "preserveLicenseComments":false
, "useStrict": true
} // and some other parts that I doubt are relevant; let me know if you need the specifics

@jrburke
Copy link
Member

jrburke commented Jun 7, 2013

My first guess is that it is the source map work, if you set generateSourceMaps: false, does that perform better?

@mdaniel
Copy link
Author

mdaniel commented Jun 7, 2013

It doesn't seem to help.
with 2.1.6:
real 4m28.787s
user 4m27.493s
sys 0m0.748s

with 2.1.2:
real 1m4.882s
user 1m4.347s
sys 0m0.393s

@jrburke
Copy link
Member

jrburke commented Jun 11, 2013

Looking at the things changed for 2.1.3:
https://github.com/jrburke/r.js/issues?milestone=21&state=closed

There was a fix for uglify2js, I was inlining it incorrectly so it was missing some content for some WHITESPACE_CHARS, fixed in #323, perhaps that would explain it? Another candidate may be #245 since it does some extra AST work, but that should only come into play if namespace: something is in the build config.

So, what may be interesting to try is to use optimize: 'uglify' which uses uglifyjs1, and if with that setting the times are similar between 2.1.2 and 2.1.3, then it seems like the culprit is just uglify2. 'uglify' does not support source maps so you will need to turn that option off too for that test.

@mdaniel
Copy link
Author

mdaniel commented Jun 11, 2013

Yup, I can confirm that optimize: 'uglify' moves the execution times back to 0m50 for all the versions.

Do I need to file a subsequent issue with Uglify2, citing this issue?

@jrburke
Copy link
Member

jrburke commented Jun 11, 2013

Ideally, create a JS file you want to run through uglify-js. Try it with the stand-alone uglify-js and record the times between uglify1 and uglify2, and hopefully pass that JS file to the uglify folks to ask what accounts for the slow down.

By generating the numbers with standalone uglifyjs, that will hopefully not confuse them by thinking it is an issue with r.js.

Going to close this as it is something uglify will need to address itself.

@gamelover42
Copy link

I'm not sure if this is related to the problem described above but it is worth mentioning that there is a known performance issue with uglify2 and pre-minified files mishoo/UglifyJS#321

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
3 participants