This marks the 1-year-and-1-month anniversary of the Rails 5 release, it looks like 5.1.3 will be out soon (second release candidate lands today). Wondering if there have been any thoughts on upgrading Discourse to Rails 5.x anytime soon? Why or why not?
I think our main problem is that Active Record gets slower in each release? Not sure, but we worry much more about “keeping up with the Joneses” for Ember (client side JS) releases than Rails on the server side, which is quite mature.
It is on my list to get us to the latest Rails but it isn’t our priority at the moment because none of the new features are useful for us. Right now, we’re working with a GSOC student to get our Rails benchmarks back in order on https://rubybench.org to have an idea of how performance is going to be like on Rails 5.
undefined method `xhr' for #<RSpec::ExampleGroups::AdminDashboardController::WhileLoggedInAsAnAdmin::Index::VersionCheckingIsDisabled:0x00564a2c54c820>
Rails 5.1 is now deployed on meta. I’m seeing performance regressed on the topics and categories page ATM so we can’t roll it out immediately to everyone. Another notable change is that Activerecord’s pluck is notably slower which I’ve submit a PR for in
Note that we actually override the default ActiveRecord#pluck and use our own implementation of fast_pluck. However, they code path being fixed here is shared between both implementation.
I’ll continue to profile the topics and categories page to see where the extra time is being spent on.
OK @tgxworld says this is ActiveRecord getting slower and slower in each new version, such that even the simple / basic queries are contributing a lot to general slowdown In a particular kick in the pants, even our “fast pluck” @sam wrote got slower because it relied on parts of Rails internals that also got substantially slower!
Here are our priorities for the Rails 5 upgrade:
We need to bypass ActiveRecord since it keeps getting slower, especially on the topic page. This is the most important page in our application! Let’s target a 20% speed improvement on the topic page, by bypassing ActiveRecord and doing raw queries.
Make sure our https://rubybench.org/ reflects this loss in performance so we can (cough) encourage people to take action on this.
The categories page, and other key pages, should be at roughly the same speed as Rails 4, within 5%.
That sounds true, but it also seems like a huge drag. I’m still (almost?) a Rails novice, but it seems like ActiveRecord is sort of the basis of the whole endeavor. And then writing around it will make things all the more fragile for future updates. Yuck.
Unavoidable since the performance is dismal, if you ever care about performance. Also not quite true, it won’t be fragile – the database is the model, not the code.
Some updates on this, it turns out that our profile script used an incorrect topic_id in the URL which means that we’ve been profiling against a private message page with one post instead of a public topics page with multiple posts. I’ve fixed it in
About a 22% increase for the 50th percentile. Note that this isn’t Rails 5.1 related, just a performance regression that we’ve been carrying around for some time.
On the Rails 5 front, I’ve basically been adding more benchmarks to RubyBench so that I can use those metrics to work with the Rails team and get us back up to speed.
@codinghorror We’re not going to be able to bypass Active Record entirely and drop straight to raw SQL since we have alot of logic baked in to our serializers that we use to form the json payload. So for, I’ve skipped AR in favor of SQL on the topics code path whenever possible.
Not quite… I’m going to use the results I’m getting from profiling with ruby-prof since the results I’m getting from our profiling script varies quite between each run and between each day I run the benchmarks. @sam I’m not sure if you noticed this previously?