zmoazeni / csscss

A CSS redundancy analyzer that analyzes redundancy.
http://zmoazeni.github.io/csscss/
MIT License
2.92k stars 151 forks source link

CSSCSS performance tanks with this particular CSS file #75

Closed mohsen1 closed 10 years ago

mohsen1 commented 11 years ago

I've started this task to analyze our 1.3MB CSS file at uk.nook.com:

csscss -v http://www2.nookassets.com/assets/application-095f49b5ae11ad8bf9ac81f54dc0c0aa.css

How long it's gonna take. It's already 1 hour and the process using 100% CPU and 500MB of RAM. Is it even working?

zmoazeni commented 11 years ago

An hour is pretty nuts. Just glancing at the contents, perhaps it is getting bogged down with the data: elements. I know I had to do some special parsing for that.

Our CSS is a fraction of your size at 286KB but that only takes about two minutes. :/

∴ time csscss -v http://cache.harvestapp.com/assets/screen.css > /dev/null                                      

real    1m40.338s
user    1m37.780s
sys    0m1.045s

That's still too long for me.

Have you tried breaking up the file into parts and seeing if one section takes substantially longer than another?

How long it's gonna take.

I dunno. Maybe another hour? :trollface:

zmoazeni commented 11 years ago

Parsing still takes a long time, but that's not the culprit:

∴ time be ruby -Ilib test/just_parse.rb tmp/nook-terrible-performance.css 

real    1m46.138s
user    1m43.455s
sys     0m2.108s

∴ time be ruby -Ilib test/just_parse.rb tmp/harvestapp-screen.css 

real    0m18.422s
user    0m17.850s
sys     0m0.532s
mohsen1 commented 11 years ago

We are using compass. It didn't work with --compass flag for our CSS for some reason. Thanks for replying. I'll update you when it finished (if ever did)

mohsen1 commented 11 years ago

OK, after 8 hours I decided to kill this thread.

Here is my output in case if it's useful

~/Projects/NookWeb/nook.com (master) ▶ csscss ~/Desktop/application.css\?body\=1
^C/Users/mazimi/.rvm/gems/ruby-1.9.3-p194@nookweb/gems/csscss-1.3.1/lib/csscss/redundancy_analyzer.rb:100:in `hash': Interrupt
    from /Users/mazimi/.rvm/gems/ruby-1.9.3-p194@nookweb/gems/csscss-1.3.1/lib/csscss/redundancy_analyzer.rb:100:in `hash'
    from /Users/mazimi/.rvm/gems/ruby-1.9.3-p194@nookweb/gems/csscss-1.3.1/lib/csscss/redundancy_analyzer.rb:100:in `block (2 levels) in redundancies'
    from /Users/mazimi/.rvm/gems/ruby-1.9.3-p194@nookweb/gems/csscss-1.3.1/lib/csscss/redundancy_analyzer.rb:99:in `each'
    from /Users/mazimi/.rvm/gems/ruby-1.9.3-p194@nookweb/gems/csscss-1.3.1/lib/csscss/redundancy_analyzer.rb:99:in `block in redundancies'
    from /Users/mazimi/.rvm/gems/ruby-1.9.3-p194@nookweb/gems/csscss-1.3.1/lib/csscss/redundancy_analyzer.rb:97:in `each'
    from /Users/mazimi/.rvm/gems/ruby-1.9.3-p194@nookweb/gems/csscss-1.3.1/lib/csscss/redundancy_analyzer.rb:97:in `each_with_index'
    from /Users/mazimi/.rvm/gems/ruby-1.9.3-p194@nookweb/gems/csscss-1.3.1/lib/csscss/redundancy_analyzer.rb:97:in `redundancies'
    from /Users/mazimi/.rvm/gems/ruby-1.9.3-p194@nookweb/gems/csscss-1.3.1/lib/csscss/cli.rb:40:in `execute'
    from /Users/mazimi/.rvm/gems/ruby-1.9.3-p194@nookweb/gems/csscss-1.3.1/lib/csscss/cli.rb:17:in `run'
    from /Users/mazimi/.rvm/gems/ruby-1.9.3-p194@nookweb/gems/csscss-1.3.1/lib/csscss/cli.rb:203:in `run'
    from /Users/mazimi/.rvm/gems/ruby-1.9.3-p194@nookweb/gems/csscss-1.3.1/bin/csscss:4:in `<top (required)>'
    from /Users/mazimi/.rvm/gems/ruby-1.9.3-p194@nookweb/bin/csscss:19:in `load'
    from /Users/mazimi/.rvm/gems/ruby-1.9.3-p194@nookweb/bin/csscss:19:in `<main>'
    from /Users/mazimi/.rvm/gems/ruby-1.9.3-p194@nookweb/bin/ruby_noexec_wrapper:14:in `eval'
    from /Users/mazimi/.rvm/gems/ruby-1.9.3-p194@nookweb/bin/ruby_noexec_wrapper:14:in `<main>'
zmoazeni commented 10 years ago

@mohsen1 Have you tried running csscss with jruby and plenty of ram? I recently found a big perf boost while tinkering with it. https://gist.github.com/zmoazeni/8091325