ndbroadbent / turbo-sprockets-rails3

Speeds up your Rails 3 assets:precompile by only recompiling changed files, and only compiling once to generate all assets
MIT License
975 stars 78 forks source link

multi-threaded? #34

Open aaronjensen opened 11 years ago

aaronjensen commented 11 years ago

I'm not sure if this would be the right gem for it, but it seems like there could be a benefit to compiling assets w/ multiple threads. There's a project that does it w/ multiple processes:

https://github.com/hornairs/sprockets-rails-parallel/

And someone has converted that to be multiple threads:

https://github.com/hornairs/sprockets-rails-parallel/pull/1

I've not tried it yet, but the monkey patching is frightening.

What do you think about the idea of multi-threading it? There is a danger as sometimes this happens on live servers and you probably don't want to slam every core at once if the servers are still serving content.

ndbroadbent commented 11 years ago

Sorry I haven't replied to this yet. I like the idea of compiling on multiple threads, but agree that you don't want to necessarily slam your production servers with that kind of load. I probably won't have time to look into that myself, but would be open to any further discussions / suggestions / pull requests :)

aaronjensen commented 11 years ago

I got this working. There are some hacks in there specific to our project which are needed to deal with compass sprites as they cannot be easily compiled in parallel.

https://github.com/aaronjensen/turbo-sprockets-rails3/pull/1

Also strange was that in our specific project I had to disable the circular dependency detection. I don't know why, but it failed when that was enabled.

The pull should be considered total work in progress but it is a template for others who may want to do the same thing. It reduced our asset compilation time from 47 seconds to 17.