jeremyevans / home_run

Fast Date/DateTime classes for ruby :: Unmaintained, unnecessary on ruby 1.9.3+
Other
465 stars 10 forks source link

home_run in Gemfile and site but not getting loaded automatically #40

Closed jaylevitt closed 13 years ago

jaylevitt commented 13 years ago

I installed it:

home_run --install
cp lib/date.rb /Users/jay/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/site_ruby/1.9.1
mkdir -p /Users/jay/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/site_ruby/1.9.1/date
cp lib/date/format.rb /Users/jay/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/site_ruby/1.9.1/date
cp lib/date_ext.bundle /Users/jay/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/site_ruby/1.9.1/x86_64-darwin10.8.0

And I added it to the Gemfile:

gem 'home_run', :require=>'date'

But I only get the speed boost when I launch rails console via home_run:

$ rails c profile
Loading profile environment (Rails 3.1.1.rc2)
in irbrc
ruby-1.9.2-p290 :001 > Benchmark.measure {User.all.first}                         User Load (114.6ms)  SELECT "users".* FROM "users" 
 =>   0.130000   0.000000   0.130000 (  0.157448)

ruby-1.9.2-p290 :002 > quit
$ home_run rails c profile
Loading profile environment (Rails 3.1.1.rc2)
in irbrc
ruby-1.9.2-p290 :001 > Benchmark.measure {User.all.first}                         User Load (21.9ms)  SELECT "users".* FROM "users" 
 =>   0.040000   0.000000   0.040000 (  0.063232)

ruby-1.9.2-p290 :002 > quit
jeremyevans commented 13 years ago

Can you run p $: in your rails c to see what load paths bundler is using? That will at least give an idea of where the problem might be. Also, does irb -r date load home_run (you can see the output of p Date.today to check)? If irb -r date loads home_run, but rails c does not, the problem is obviously in rails/bundler and not in home_run.

jaylevitt commented 13 years ago

And confirmation that it's not getting loaded:

$ rails c profile
ruby-1.9.2-p290 :001 > Date.method(:s3e).source_location
 => ["/Users/jay/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/site_ruby/1.9.1/date/format.rb", 148] 

$ home_run rails c profile
ruby-1.9.2-p290 :001 > Date.method(:s3e).source_location
 => ["/Users/jay/.rvm/gems/ruby-1.9.2-p290/gems/home_run-1.0.4/lib/date/format.rb", 148] 
jeremyevans commented 13 years ago

Actually, you see the site_ruby part? It is loading home_run. Why it's slower I'm not sure. Did you run those benchmarks multiple times each way? Try doing a Date::Format::STYLE in both cases to see if home_run is loaded (if not, it will raise a NameError).

jeremyevans commented 13 years ago

jaylevitt, any feedback on this? Are things working now?

jaylevitt commented 13 years ago

Content preview: No, something got even weirder.. you're right, it was getting loaded whether I used the home_run launcher or not, and the variation in run times was due to randomness. But - User.all.first wasn't any faster than without home_run at all, and it has ten timestamp columns! So something's wrong. (Yet benchmarking Date.parse proves that it is in fact far faster with home_run loaded.) [...]

Content analysis details: (-1.9 points, 5.0 required)

pts rule name description


-0.0 T_RP_MATCHES_RCVD Envelope sender domain matches handover relay domain -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000]

No, something got even weirder.. you're right, it was getting loaded whether I used the home_run launcher or not, and the variation in run times was due to randomness. But - User.all.first wasn't any faster than without home_run at all, and it has ten timestamp columns! So something's wrong. (Yet benchmarking Date.parse proves that it is in fact far faster with home_run loaded.)

I'm hoping to dig into it later today.

jeremyevans commented 13 years ago

Ah. The lack of a performance difference in User.all.first is probably because you weren't attempting to access the column values, the database adapter you are using returns the date/timestamp column values as strings, and ActiveRecord does type conversion lazily. If you do User.all.each{|c| c.attributes}, I think that will show a significant difference. Anyway, I'm closing this as it doesn't appear to be an issue with home_run.