Skip to content

Instantly share code, notes, and snippets.

View kenmazaika's full-sized avatar

ken mazaika kenmazaika

View GitHub Profile
@kenmazaika
kenmazaika / run_a_single_test.rb
Created February 8, 2013 17:05
run a single test. THANKS ALEX
ruby -I "lib:test" path_to_test_file -n name_of_the_method
class CreateYolos < ActiveRecord::Migration
def change
create_table :yolos do |t|
# The correct way to add a `longtext` field to table
t.text :swag, :limit => 0xffffffff
t.timestamps
end
end
end
@kenmazaika
kenmazaika / gc_and_patched_ruby_tests
Last active December 13, 2015 18:18
Benchmarks on tests when doing optimizations
using rbenv and: https://gist.github.com/burke/1688857?utm_source=rubyweekly&utm_medium=email
GC Collection + Patched Version of Ruby
Finished tests in 378.267123s, 3.5768 tests/s, 10.8918 assertions/s.
Finished tests in 272.069772s, 2.5545 tests/s, 7.8767 assertions/s.
Total: 650.336895
Shaves off: 48.43049799999994 seconds from GC'ed version.
Total Savings with both: 234.41349000000002seconds, 3.9068915000000004 minutes, 26.5%
# for more info: https://gist.github.com/1120938

So. You want faster rails tests so you can spend less time waiting for rake and more time sipping gatorpagne. I get it.

Step 1 - Garbage Collection Tuning (system change)

Add the following to your .bash_profile. It's based off the 37 signals REE tuning.

# Ruby GC Tuning
export RUBY_HEAP_MIN_SLOTS=600000
@kenmazaika
kenmazaika / 0-readme.md
Last active December 13, 2015 19:38 — forked from samgranieri/0-readme.md

ruby-1.9.3-p385 cumulative performance patch for rbenv

This installs a patched ruby 1.9.3-p385 with various performance improvements and a backported COW-friendly GC, all courtesy of funny-falcon.

Requirements

You will also need a C Compiler. If you're on Linux, you probably already have one or know how to install one. On OS X, you should install XCode, and brew install autoconf using homebrew.

2013-02-27T00:04:39.661249+00:00 f: <local2> l: <info> <...undefined> method `host' for nil:NilClass
initialize at /var/cache/jetty/data/Jetty_0_0_0_0_8080_pantar.war__pantar__6lxakj/webapp/WEB-INF/gems/gems/jmongo-1.1.5/lib/jmongo/connection.rb:58
_from_uri at /var/cache/jetty/data/Jetty_0_0_0_0_8080_pantar.war__pantar__6lxakj/webapp/WEB-INF/gems/gems/jmongo-1.1.5/lib/jmongo/mongo/connection.rb:41
from_uri at /var/cache/jetty/data/Jetty_0_0_0_0_8080_pantar.war__pantar__6lxakj/webapp/WEB-INF/gems/gems/jmongo-1.1.5/lib/jmongo/connection.rb:74
connection at /var/cache/jetty/data/Jetty_0_0_0_0_8080_pantar.war__pantar__6lxakj/webapp/WEB-INF/lib/mongo_dbh.rb:14
db at /var/cache/jetty/data/Jetty_0_0_0_0_8080_pantar.war__pantar__6lxakj/webapp/WEB-INF/lib/mongo_dbh.rb:19
collection at /var/cache/jetty/da...
2013-02-27T00:04:39.661437+00:00 f: <local2> l: <info> <...ta/Jetty_0_0_0_0_8080_pantar.war__pantar__6lxakj/webapp/WEB-INF/lib/mongo_dbh.rb> 29
2013-02-28T18:03:08.457017+00:00 f: <daemon> l: <info> <jsvc.exec> 273606561 [pool-1-thread-1446] INFO /pantar - INFO: pool was empty - getting new application instance
2013-02-28T18:03:27.156752+00:00 f: <daemon> l: <err> <jsvc.exec> /var/cache/jetty/data/Jetty_0_0_0_0_8080_pantar.war__pantar__6lxakj/webapp/WEB-INF/gems/gems/bundler-1.3.0/lib/bundler/resolver.rb:294:in `resolve'
2013-02-28T18:03:27.156752+00:00 f: <daemon> l: <err> <jsvc.exec> :
2013-02-28T18:03:27.156989+00:00 f: <daemon> l: <err> <jsvc.exec> You have requested:
2013-02-28T18:03:27.156989+00:00 f: <daemon> l: <err> <jsvc.exec> (
2013-02-28T18:03:27.156989+00:00 f: <daemon> l: <err> <jsvc.exec> Bundler::GemNotFound
2013-02-28T18:03:27.157084+00:00 f: <daemon> l: <err> <jsvc.exec> )
2013-02-28T18:03:27.157084+00:00 f: <daemon> l: <err> <jsvc.exec> bson >= 0
2013-02-28T18:03:27.157084+00:00 f: <user> l: <notice> <The> bundle currently has bson locked at 1.8.2.
2013-02-28T18:03:27.157084+00:00 f: <user> l: <notice> <Try> running `bundle u
cd ~/.rbenv/plugins/ruby-build && git pull origin master
rbenv install 2.0.0-p0