#412 Fast Rails Commands
Apr 04, 2013 | 8 minutes | Tools
Rails commands, such as generators, migrations, and tests, have a tendency to be slow because they need to load the Rails app each time. Here I show three tools to make this faster: Zeus, Spring, and Commands.
- Download:
- source code
- mp4
- m4v
- webm
- ogv
Will this make tests in autotest or guard faster?
Take a look at https://github.com/qnm/guard-zeus for Guard integration.
Wooohoo!!!
Thanks !
Thats awesome
+1
Top !!!!
Not too difficult this integration?
Not at all, very simple
+1
One tip to fasten Rails' startup : buy a SSD drive ! It will make your life easier ;)
With rvm, startups also much faster when optimization patches are used, for example ruby-1.9.3-p392-
railsexpress
or ruby-2.0.0-p0-turbo
.Hmm, I'm not able to find turbo patch for ruby 2.0, are you sure about that ?
Wow this is crazy:
1.9.3 unpached:
bundle exec rake -vT 18,51s user 2,03s system 94% cpu 21,768 total
1.9.3 pached:
bundle exec rake -vT 5,05s user 1,08s system 99% cpu 6,166 total
That is a big difference!
+1
+1
Do you have some evidence for this?
Beyond the first run, the files should be paged into RAM anyway, so I would expect CPU to be the bottleneck, rather than disk.
(SSDs are great of course, I'm just not sure that it helps in this case).
no evidence, but when I made the switch, I really felt the difference !
time rake db:migrate with normal macbook pro hdd: 2.x seconds
time rake db:migrate with samsung 840 pro ssd: 1.x seconds
I also feel the difference :)
Yeah of course !
Yeah SSD rulez !
If you would like to use zeus, guard and parallel tests together check out https://github.com/sevos/zeus-parallel_tests
Consider https://github.com/jugyo/rails-sh - works amazingly!
+1
If you're a TMUX user I've found the Tmuxinator Gem to be fantastic way to setup and control multiple Rails dev environments.
Starting and/or attaching to an app's session is as simple as
$ mux my_app
; Adding Zues or Spring into the into Tmuxinator config is something I might try in order to further automate my dev environments.If you frequently work on only 1 or 2 projects then you might not get a lot of milage out of TMUX. However, if you're like me -- I have 9 rails apps that I'm constantly switching between -- then it can make your life a lot easier.
Happy coding all :)
I'm trying to set up my tmuxinator config file to start zeus before it runs
zeus c
,zeus s
in my panes.Adding
zeus start
to thepre:
config fails, because Zeus prevents tmux from loading.I tried starting it as a daemon with
zeus start &
, but zeus tries to refresh the screen, which screws up the tmux display.How did you work with this?
Unfortunately I've been swamped with a ton of work and have not attempted to get it working yet.
If I get some free time this weekend I'll try and give the implementation a shot :)
Well, it took 10 months but I finally got around to creating a gem to do this :)
https://github.com/veloper/zeusd
run
zeusd restart --block
in your pre block and enjoy!Sadly, neither zeus or commands work under JRuby. This is because JRuby does not support Kernel#fork.
commands does work for running generate, and rake commands will also start quickly. rake 'test' also runs, but although it starts quickly, I believe it starts a separate process for the sub-tasks test:unit and test:functional.
For JRuby, you can use JRuby's bundled Nailgun server as an alternative to Spork. It'll be very familiar if you've ever run RSpec with a DRB server: http://blog.headius.com/2009/05/jruby-nailgun-support-in-130.html
Commands works fine with Jruby, I use it.
i'm getting "exit status 1" for jruby
but on a high note works great for ruby-1.9.3
If you want to run tests from within Sublime Text, check out the RubyTest package. The README has instruction on configuring it for Zeus.
Great suggestion - did not know about this. You can also change the settings to use spring, by just prepending the rspec command with it...
This is great ! Thank you, I was looking for that.
Thanks - good tips. So far I've been using "spin, combined with the kicker gem for autotests:
https://github.com/jstorimer/spin
Seems though Zeus and Spring are even easier to use.
Are there any gem that speeds up rspec/capybara testing under Windows (besides Spork)?
These tools have a few issues if you're using vagrant:
SPRING_TMP_PATH
, but I don't think zeus has a configuration option for this.Ryan,
Great screencast as always. Have you checked out https://github.com/nviennot/irb-config yet? It allows running tests from within the console as well, but it seems faster than the other tools.
Another solution is GoGo, it creates a pseudo-shell with the Rails environment preloaded. https://github.com/brianhempel/gogo
Sounds similar to https://github.com/jugyo/rails-sh
Jobby (https://github.com/Spakman/jobby) is useful for running multiple daemons under a shared environment. Allows you to spin off new processes without reloading entire rails env each time.
Any suggestions for getting Zeus and Thor to work together?
Adding a
thor
command tothor.json
and the following method incustom_plan.rb
seems to do the trickThis seems to be the only reference I can find on the net to run thor through zeus. However, I'm slightly unsure what you mean. What's
thor.json
? I've had a ganders through thor's docs and can't find a reference to it. And what'scustom_plan.rb
? Is that one of your own commands?Ah.
zeus.json
. Got it.Best way I've found for running migrations is from the console: http://stackoverflow.com/a/18782615/423384
1+
one of the interesting post thanks for share this
+1
I am very happy to find this post! It's useful for me, and contains lot of information.
Find so relevant stuff thanks
Find so relevant stuff thanks
This is the type of information I’ve long been trying to find. Thank you for writing this information
Thank you for this incredible information. It was very useful for me, I ll be looking forward your new posts.
ok
This is perfect
That's interesting, but didn't work for me. Perhaps it's due to the fact that the version we are using is newer. Any suggestions for that?
Good Post
Very good post! We will be linking to this great content on our website. Thank so much!
Thanks for the information
This is so irritating. I can find anything on this website. No fan-club registration info anywhere.