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

Does it work at all? #43

Closed
varyform opened this issue Oct 1, 2015 · 12 comments
Closed

Does it work at all? #43

varyform opened this issue Oct 1, 2015 · 12 comments

Comments

@varyform
Copy link

varyform commented Oct 1, 2015

Hi,
I don't see any improvements. Am I doing something wrong?

oleh@imac:~/projects/project (master)$ rm -rf tmp/cache/assets public/assets && time rake assets:precompile 2>/dev/null

real  0m40.022s
user  0m35.192s
sys 0m5.305s

oleh@imac:~/projects/project (master)$ git checkout experiments/sassc
Switched to branch 'experiments/sassc'
oleh@imac:~/projects/project (experiments/sassc)$ rm -rf tmp/cache/assets public/assets && time rake assets:precompile 2>/dev/null

real  0m49.738s
user  0m38.643s
sys 0m11.520s

oleh@imac:~/projects/project (experiments/sassc)$ d master Gemfile | grep sass
-gem 'sass-rails', '~> 4.0.3'
+gem 'sassc-rails'

oleh@imac:~/projects/project (experiments/sassc)$ d master Gemfile.lock | grep sass
-    sass (3.2.19)
-    sass-rails (4.0.5)
-      sass (~> 3.2.2)
+    sass (3.4.18)
+    sassc (1.6.0)
+      sass (>= 3.3.0)
+    sassc-rails (1.1.0)
+      sass
+      sassc (~> 1.6)
-  sass-rails (~> 4.0.3)
+  sassc-rails

rails 4.4.11
sprockets (3.3.5)
sprockets-rails (2.3.3)

@bolandrm
Copy link
Member

bolandrm commented Oct 1, 2015

I see you've got sass-rails installed. That's probably conflicting.

See here: #6 (comment)

@varyform
Copy link
Author

varyform commented Oct 1, 2015

@bolandrm no, I don't, check the diff

@bolandrm
Copy link
Member

bolandrm commented Oct 1, 2015

Ah, ok. After you check out the other branch, did you bundle and spring stop ?

@varyform
Copy link
Author

varyform commented Oct 1, 2015

I don't use spring and yeah, I did bundle :)

@bolandrm
Copy link
Member

bolandrm commented Oct 1, 2015

interesting... perhaps you need to run bundle exec rake assets:precompile? not sure.

Failing that, can you run bundle open sassc-rails and add some puts statements to see if the SassC::Rails template is being used?

    # lib/sassc/rails/template.rb

    module Sprockets3
      def call(input)
        context = input[:environment].context_class.new(input)

        puts "using sassc rails"         # <-------------

or if using sprockets 2

   # lib/sassc/rails/template.rb

    module Sprockets2
     # ..

      def evaluate(context, locals, &block)
        puts "using sassc rails"          # <-------------

see if that prints anything out during assets precompile...

@varyform
Copy link
Author

varyform commented Oct 1, 2015

Yeah, I tried that too y-day, and it's definitely using sassc-rails b/c compilation time is ~15-20% slower vs ruby sass.

oleh@varyform-mbp:~/projects/project (experiments/sassc)$ rm -rf tmp/cache/assets public/assets && time bundle exec rake assets:precompile 2>/dev/null
using sassc rails
using sassc rails
using sassc rails
using sassc rails
using sassc rails
using sassc rails
using sassc rails
using sassc rails
using sassc rails
using sassc rails
using sassc rails
using sassc rails

real  0m49.870s
user  0m40.718s
sys 0m9.516s
oleh@varyform-mbp:~/projects/project (experiments/sassc)$ git checkout master
Switched to branch 'master'
oleh@varyform-mbp:~/projects/project (master)$ rm -rf tmp/cache/assets public/assets && time bundle exec rake assets:precompile 2>/dev/null

real  0m43.718s
user  0m38.205s
sys 0m5.963s

@bolandrm
Copy link
Member

bolandrm commented Oct 1, 2015

I'm not sure what's going on then. Here are my results:

# With sassc-rails:
bundle exec rake assets:precompile 2> /dev/null  29.52s user 6.44s system 99% cpu 36.180 total
# with normal sass-rails:
bundle exec rake assets:precompile 2> /dev/null  33.41s user 6.51s system 97% cpu 40.826 total

assets:precompile is noisy though, because it's compiling a bunch of stuff that isn't css. Could you try the benchmark that i have in the readme? (in rails console)

@varyform
Copy link
Author

varyform commented Oct 1, 2015

When I try one file it's 4.53s with sassc vs 6.16 with ruby sass.
Not even close to 4x, but still an improvement :)
The reason complete suit takes longer may be related to cache.
I have 2 big CSS files in my app, both have ±15 imports, but some of those imports match.
So ruby sass probably reuses compiled files for 2nd import.

Here in 2nd pass I don't remove tmp/cache/assets and the difference is visible.

oleh@imac:~/projects/project (master)$ rm -rf tmp/cache/assets public/assets && time bundle exec rake assets:precompile 2>/dev/null

real  0m44.866s
user  0m37.571s
sys 0m6.530s
oleh@imac:~/projects/project (master)$ rm -rf public/assets && time bundle exec rake assets:precompile 2>/dev/null

real  0m11.291s
user  0m9.291s
sys 0m1.805s

@bolandrm
Copy link
Member

bolandrm commented Oct 1, 2015

Are you using sass import statement, or sprockets require?

I could be wrong, but I don't believe that ruby sass can cache imported files. Just because you could have set different variables before importing the file, which would affect the compilation of the file.

On the other hand, sprockets require can be cached.

@varyform
Copy link
Author

varyform commented Oct 1, 2015

Imports only.

And my last comparison was not correct, b/c I have a lot of JS files (which are cached by sprockets) and some standalone sass files (specified in config/initializers/assets.rb)

When I only keep those 2 big files in assets.rb and remove sprockets cache – there is no difference at all with ruby sass.

And the same flow on sassc branch gives me 7s vs 22s.

Will probably try to do some more benchmarks to figure out what exactly makes whole suit to take more time in my case.

The issue can be closed, sorry for wasting your time :)

@bolandrm
Copy link
Member

bolandrm commented Oct 1, 2015

No problem. Let me know if you find any interesting results. Thanks!

@bolandrm bolandrm closed this as completed Oct 1, 2015
@varyform
Copy link
Author

varyform commented Oct 1, 2015

The problem was in sprockets: master branch was using 2.12.4, while sassc 3.3.5.
Updating sprockets on master to same 3.3.5 gave the following results:

  • master before sprockets update: 41s
  • master after sprockets update: 59s
  • sassc: 49s

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

No branches or pull requests

2 participants