5 ms·
Speeding up Rails 4.2
- VeejayRampay 12y agoSam Saffron has great write-ups. His article on Ruby 2.1 and garbage collection fine-tuning [1] is a must-read [1] http://samsaffron.com/archive/2014/04/08/ruby-2-1-garbage-collection-ready-for-production http://samsaffron.com/archive/2014/04/08/ruby-2-1-garbage-co...
- stanislavb 12y agoAmazing 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.
- akanet 12y agoThis 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.
- dynjo 12y agoYou guys might like our latest gem, it outputs ruby-prof as FlameGraphs https://github.com/oozou/ruby-prof-flamegraph https://github.com/oozou/ruby-prof-flamegraph
- jpgvm 12y agoAwesome, I love flamegraphs for finding performance bottlenecks.
- matthewmacleod 12y agoThis 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?
- jpgvm 12y agoIt 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.
- gavingmiller 12y agoSam has also blogged about this for Ruby specifically: http://samsaffron.com/archive/2013/12/11/call-to-action-long-running-ruby-benchmark http://samsaffron.com/archive/2013/12/11/call-to-action-long...
- patio11 12y agoThanks, 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.
- mikecmpbll 12y agoGreat write-up, and thanks Sam and Sean! 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! ..
- jrochkind1 12y agoMakes 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?
- deleted 12y ago[deleted]
- grk 12y agoRuby 2.2 will add almost-automatic-freezing of string hash keys[1]. I wonder how big of an impact this will have on Rails performance. [1] http://www.sitepoint.com/unraveling-string-key-performance-ruby-2-2/ http://www.sitepoint.com/unraveling-string-key-performance-r...
- solutionyogi 12y agoSam is a smart guy and an awesome developer. He contributed tons of code for .NET community when he worked at Stack Overflow. I have done a fair amount of performance optimization work in .NET/C#, so I was curious as to what kind of optimizations are involved in Ruby. One of the optimization was this: https://github.com/SamSaffron/rails/commit/9aa2b2d7bf52c0f3974090cd033341be2edeae6d https://github.com/SamSaffron/rails/commit/9aa2b2d7bf52c0f39... Three lessons: 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. Here's another: https://github.com/SamSaffron/rails/commit/a668b09ee387bf241a3481a764a18a5c8a4df8cd https://github.com/SamSaffron/rails/commit/a668b09ee387bf241... Same story.
- m0th87 12y agoString interning has nothing to do with static typing. AFAIK Ruby supports it with symbols and Python with strings in general.
- riffraff 12y agoRecent 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.
- Yadi 12y agoYou are the man! Thanks for the great insight on the performance.