activerecord 2.3.5's create & find slower than activerecord 2.1.2?

[I posted this on rubyonrails-talk, but it was suggested I post it
here as well. I apologize for the cross-post.]

Can anyone help me understand what's going on here? We updated one of
our apps from 2.1.2 to 2.3.5 hoping largely to get a little
performance boost since I know there was a lot of performance
improvements in the 2.3.x line. However we discovered instead that
our test suite is now running around 40% slower. Looking around on
line we found some reports of slowness with the built-in memcache
client, but we're not using it. So we started reducing code looking
for the performance differences and eventually arrived at what appears
to be around a 35% slowdown in AR::B.find & around a 20% slowdown in
AR::B.create.

To test this we created to bare rails apps, one 2.1.2 the other
2.3.5. Both were set to use mysql for the database:

$ rails-2.1.2 bench212 -d mysql
$ rails-2.3.5 bench235 -d mysql

Then we run this in each
$ ./script/generate model Foo
$ rake db:create
$ rake db:migrate

Then drop this ( http://gist.github.com/277319 ) in the script
directory of each. The results are pretty consistently thus:

Rails 2.3.5
25000 finds (7330.0ms) (7.33)
25000 creates (32942.4ms) (32.942)

Rails 2.1.2
25000 finds (5.37473)
25000 creates (26.60233)

Looking at the profile trees, the only one difference that stands out
is in 2.3.5, 3.11% of the time is spent in
ActiveRecord::ConnectionAdapters::ConnectionHandler#retrieve_connection_pool
which doesn't appear in 2.1.2.

We've tried this on two different machines (one mac running macport
installed ruby, the other an x86-64 ubuntu box running stock ruby 1.8)
and see similar results on each. Is this slowdown expected? Or is
there something flawed in our benchmarks?

Thanks!

Ben

Looking at the profile trees, the only one difference that stands out
is in 2.3.5, 3.11% of the time is spent in
ActiveRecord::ConnectionAdapters::ConnectionHandler#retrieve_connection_poo l
which doesn't appear in 2.1.2.

that's not 40% worth...what else is different speed-wise/profile wise?
-r

Looking at the profile trees, the only one difference that stands out
is in 2.3.5, 3.11% of the time is spent in
ActiveRecord::ConnectionAdapters::ConnectionHandler#retrieve_connection_poo l
which doesn't appear in 2.1.2.

I played around with git bisect and it would seem that the move to
connection pools is what slows down your benchmark.

Fred

I played around with git bisect and it would seem that the move to
connection pools is what slows down your benchmark.

Does it still cause the slow down if you explicitly turn off the
pooling in database.yml? e.g. pool: 1

Turning off pooling does indeed reduce the slow down. It brings
AR::B.create right back in line with 2.1.2 & find is now just ~9%
slower. So that does explain most of what we're seeing in this
benchmark. Thanks for the suggestion!

-Ben

Out of interest, how does 3.0 perform?