You can clone with
Some people are experiencing seemingly exponential blowups in time taken to compile in compressed style.
This happens when compiling with production settings in the Rails asset pipeline (rake assets:precompile) when config.assets.compress = true.
config.assets.compress = true
When running rake with --trace and INTerrupting at any time during the compilation, one discovers that the hang is inside Sass::Tree::CommentNode#normalize_indentation every time.
In this method, a very large number of large arrays is being created. So many arrays that perhaps the GC is thrashing.
The inner loop of this method should be modified to be much more memory-conservative. In particular, instead of Array#+, favor rewriting to use Array#<<.
This should dramatically reduce the number of large arrays being created, and speed up compilation in compressed style.
Can you provide an example of input that causes this exponential increase? I'd like to have something to test against so I can know when I've solved the problem.
twbs/bootstrap-sass#62 provides a good example.
I've gisted that example here: https://gist.github.com/e302bb4bc1f373a9b934.
Is there a way to do it without setting up a Rails app? If not, could you put the Rails app in a repo somewhere?
It's really just a brand new rails app.
Add the gem bootstrap-sass to Gemfile.
Create the following app/assets/stylesheets/application.css.sass:
I have created a Rails application repo: yfeldblum/sass-337. I've removed everything except the bare necessity for running rake assets:precompile.
+1 I can see the code hang on Sass::Tree::CommentNode#normalize_indentation when attaching the perftools.rb to use as a profiler with a blank Rails app containing the bootstrap-sass gem.
Fix a perf bug with CommentNode#normalize_indentation.
When a single line had ridiculously long preceding whitespace,
This was also related to sass-rails#101, which was causing the massive input to #normalize_indentation in the first place by running the already-compressed Sass code through Sass again.
@nex3 Do you still need the sample app?
No, I don't.
I am still experiencing this issue. On an older and slower test server I was getting times of about an hour to precompile assets. Turning off the compression it drops to a couple of minutes. I am using bootstrap-sass 2.3.1 on a windows machine with ruby 1.9.3p125.
@lgebhardt Can you produce a sample app that demonstrates the issue?
@nex3, I have an app up at https://github.com/lgebhardt/simple_bs_app_demo. Sorry it took so long.
@lgebhardt As far as I can tell, your example doesn't have exponential compile time. Adding more content to the stylesheet doesn't seem to increase the compile time any more than linearly. It looks like the "compress" flag just adds some additional, constant overhead (about 5s on my machine).
Closing again because I can't reproduce.
@nex3, what platform did you test this on? I was running it on a Windows box. I'll test the same code on mac or linux soon.