Skip to content

Speedup unused compress option for already minified code#1024

Merged
rvanvelzen merged 1 commit intomishoo:masterfrom
kzc:speedup-unused
Mar 29, 2016
Merged

Speedup unused compress option for already minified code#1024
rvanvelzen merged 1 commit intomishoo:masterfrom
kzc:speedup-unused

Conversation

@kzc
Copy link
Copy Markdown
Contributor

@kzc kzc commented Mar 28, 2016

Fixes: #321 #917 #1022

@kzc
Copy link
Copy Markdown
Contributor Author

kzc commented Mar 28, 2016

Before fix:

$ uglifyjs -V
uglify-js 2.6.2

$ curl http://builds.emberjs.com/release/ember.min.js | time uglifyjs -c
...
      219.52 real       219.01 user         0.12 sys

After fix:

$ curl http://builds.emberjs.com/release/ember.min.js | time bin/uglifyjs -c
...
       10.58 real        10.25 user         0.14 sys

@rvanvelzen rvanvelzen merged commit 45ddb9c into mishoo:master Mar 29, 2016
@rvanvelzen
Copy link
Copy Markdown
Collaborator

Looks totally okay to me. Merged as 45ddb9c, thanks!

@kzc
Copy link
Copy Markdown
Contributor Author

kzc commented Mar 29, 2016

I tested the fix against a dozen popular 200K+ minified JS files and a couple 1MB+ JS files and they had the same output shasum as the code prior to the fix.

My only concern was if any SymbolDef instances were copied through means other than using new SymbolDef - but I could not find anything like that in the sources. id must be unique and non-mutable for each SymbolDef instance for the algorithm to work.

The fix doesn't slow down normal compress minification, and it can even speed up compressing large non-minified files.

@fresheneesz
Copy link
Copy Markdown

Do people need to do something specific to fix their problems with slow run-times for pre-minified code, or does it speed up things automatically?

@kzc
Copy link
Copy Markdown
Contributor Author

kzc commented May 9, 2016

It works automatically.

Note: this code has yet to be released on npm.

@fresheneesz
Copy link
Copy Markdown

fresheneesz commented May 9, 2016

Excited to see it released! It would literally cut my deployment time by 80% - most of my deployment is waiting for ugilfy to slog through the one or two minified files in my project.

@kzc
Copy link
Copy Markdown
Contributor Author

kzc commented May 9, 2016

Interim workaround use compress option unused=false to see if applicable to your code.

@VitaliyR
Copy link
Copy Markdown

@kzc tried this workaround and it is at least building in 10 secs (before was 6 mins!). I'm raising a flag, guys, it is really awful performance. The file which should be minified is ~1.3mb

@kzc
Copy link
Copy Markdown
Contributor Author

kzc commented May 24, 2016

uglify-js@2.6.2 does not contain this optimization.

If unused=false speeds up your build then once uglify-js is released with this optimization you will experience a similar speed up with unused=true.

I don't control when uglify-js releases are made.

/cc @mishoo

@VitaliyR
Copy link
Copy Markdown

What do you mean? How it could help me?

@kzc
Copy link
Copy Markdown
Contributor Author

kzc commented May 24, 2016

What do you mean? How it could help me?

This PR fixed the unused=true slowness. Once the next uglify-js release is made this fix will be in that release.

@FrendEr
Copy link
Copy Markdown

FrendEr commented Jun 22, 2016

The PR had release in @2.6.3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants