This is really great – but I guess I'm a little concerned that large performance regressions aren't being caught at an earlier stage. I wonder if there's scope to automatically keep tabs on Rails Edge performance?
It would be great if there was a performance benchmark run on CI stack or something and writing output in parseable format so it could be graphed over time etc.
This is exceedingly great work. This is the stuff I love coming to HN for. I had no idea Discourse had a dual-boot mode, much less that it had become a de-facto macro benchmark for both Ruby and Rails. That is awesome.
1. Always use profiler to identify code bottlenecks. I don't think I would have ever guessed that the string literal is costing memory allocations causing performance issues.
2. I find it sad that this kind of optimization is required in 2015. In any statically typed language, this would be completely unnecessary.
3. Performance optimization makes code less readable. I think it would make sense to add comment explaining why constant ID was declared.
Recent rubys also supports it for frozen strings (which is the reason it's a frozen string in the commit, probably).
The reason it's not done by default is that with mutable strings it would be more complicates/would require a different string implementation, I guess.
Makes me wonder how bad it would have been without Adequate Record? I would imagine it's a bit disheartening for Aaron that all his hard work making AR 2-times faster have been obliterated by other stuff! ..
Makes me wonder if Adequate Record has much impact at all on typical app patterns. Has AdRec been obliterated by other stuff, or is it a microbenchmark that just didn't effect the OP's app much?
Thanks, this is both enormously helpful work for those in the Rails community who depend on the new hotness, and a great writeup for increasing engineering skill levels throughout the community.
Amazing work! I've bookmarked this post. I think that this approach of profiling Discourse on Rails could be use for any other app/service that is to be migrated to Rails 4.2.