Keep your gems clean!
Posted: Sat, 11 January 2014 | permalink | No comments
Ruby has a reputation for being slow. But there’s slow, and then there’s
“three seconds to show the help for a fairly command line program”. That’s
not slow, that’s ridiculous. The
gem cleanup command is the solution.
Rubygems has a nice feature whereby you can have multiple versions of a gem installed at once. That’s neat, because it allows programs with different gem version requirements to co-exist on the system. Unfortunately, over time, you can end up with many versions of a gem installed, as upgrades pull in ever-newer versions of all your gems.
Couple this accumulation of cruft with a need for Rubygems to look at every one of them on every startup, and you can see how you could very quickly end up with a three second startup time.
gem cleanup, you’ll have the opportunity to nuke all the
out-of-date versions of your gems. It takes into account dependencies, so
it will at least ask you before nuking a gem that another gem absolutely
depends on (I’d prefer a command-line switch to say, “Don’t even think about
uninstalling something that another gem depends on!”, but you can’t have
everything). If you’ve got non-gem things on your system that rely on
out-of-date gems (anything using bundler, for instance), those will assplode
the next time you run them, but you can always re-run
bundle install to get
just the specific versions of gems back you need.
The end result of my little spring cleaning? Down from three seconds to three quarters of a second. A 75% improvement. Win!
Post a comment
All comments are held for moderation; markdown formatting accepted.