github/rails — pull request #65 by charliesome (2014-04-29 07:56:05+00:00)
Title: [3.0] Faster attr lookup

This PR cherry-picks a few commits from 3-1-stable, and makes a minor change. The biggest change however is in be62675.

`respond_to?` is quite expensive on an AR object in 3.0, so nuking this call speeds up attribute lookup by about 10x.

**Before:**

```
λ ruby x.rb
0.750000 0.010000 0.760000 ( 0.757399)
0.740000 0.000000 0.740000 ( 0.736764)
0.710000 0.000000 0.710000 ( 0.709113)
0.740000 0.000000 0.740000 ( 0.744087)
0.750000 0.000000 0.750000 ( 0.755690)
```

**After:**

```
λ ruby x.rb
0.090000 0.000000 0.090000 ( 0.086189)
0.070000 0.000000 0.070000 ( 0.075418)
0.080000 0.000000 0.080000 ( 0.074675)
0.070000 0.000000 0.070000 ( 0.074134)
0.080000 0.000000 0.080000 ( 0.074326)
```

The benchmark code:

```ruby
5.times do
puts Benchmark.measure {
50_000.times do
$u.login
end
}
end
```

cc @github/perf @github/rails3