New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
AR Performance regression in 3.1 #1717
Comments
About half of the runtime looks to be from the apply_default_scope assignment introduced in c69111b, which @jonleighton has said he would be changing. |
Thanks @jhawthorn. I did mean to fix that, not sure how it escaped my attention. Have pushed a fix now, but leaving this open as master is still about twice as slow as 3-0-stable. |
Just to update this, it looks like we're making more (greater than 0) calls to Edit: added links to larger images. |
I think we can close this now. I used this script for benchmarking: require 'active_record'
require 'benchmark'
p ActiveRecord::VERSION::STRING
ActiveRecord::Base.establish_connection(
:adapter => "sqlite3",
:database => ":memory:"
)
ActiveRecord::Base.connection.execute("CREATE TABLE active_record_models (id INTEGER UNIQUE, title STRING, text STRING)")
class ActiveRecordModel < ActiveRecord::Base; end
ActiveRecordModel.new
N = 100_000
Benchmark.bm { |x| x.report('new') { N.times { ActiveRecordModel.new } } } I got these results:
Times would vary slightly. Sometimes 3.1.0 would be faster, sometimes not. They are approximately the same speed, so I think we can close this ticket. A few interesting things:
It took these commits to bring the time down: e0fae72 remove useless assignment @paul thank you for reporting this issue. I appreciate it! :-) |
https://gist.github.com/fabfaf1bd8503fbf6d32
The text was updated successfully, but these errors were encountered: