Ruby 2.1 Garbage Collection to Address Criticism on Large Scale Deployments
Matz, the creator of Ruby, announced last weekend at Baruco (Barcelona Ruby Conference) the move to generational garbage collection (GC) in Ruby MRI version 2.1 in what is expected to be an important performance boost for the language. Ruby 2.1 is expected to be released before the end of this year.
Coincidentally in another talk that same day Vicent Martí from Github strongly criticized the Ruby MRI garbage collection implementation, calling the current mark & sweep algorithm a “2-headed monster”. Vincent explained how often times Github’s large scale Ruby deployment was affected by the GC limitations.
On one hand because of its slow marking phase (in which the entire object graph is traversed sequentially to identify active objects, effectively stopping the application during that time). On the other hand because of inaccuracies in the sweeping phase which can end up freeing Ruby objects that are actually still in use (pointed by) C extensions.
Vincent mentioned that using tools like Valgrind or performing static analysis beforehand can help minimize these issues, but highlighted that the current implementation of Ruby GC in MRI is fundamentally flawed, recommending large scale Ruby deployments to move to JRuby or Rubinius once they achieve the same feature set as MRI.
In his talk Chris Kelly from New Relic coincided on the slowness of the current GC implementation, highlighting that a typical Rails application starts up with hundreds of thousands objects which need to be analyzed over and over during the marking phase of the GC execution. However, Chris also shared results from New Relic’s Ruby GC benchmarking showing a 48% decrease in garbage collection execution time between Ruby 1.8 and 1.9.
According to Chris this shows that there are major improvements being done by the MRI team which will level up the Ruby implementation in this area, in particular with the announced move to generational garbage collection (expected to reduce marking phase duration by half according to Matz).
There was also some criticism in some talks on the lack of English documentation about the garbage collection implementation on Ruby MRI, with Chris listing some recommendations in his presentation, such as “Rare Are GC Talks”.
Some other enhancements announced by Matz for Ruby 2.1 include string suffixes (“i” for complex numbers, “r” for rational numbers, “f” for frozen strings), refinements (full feature) and (around 15%) faster RDoc generation.
How Can We Use Our Creative Power and Technological Opportunity to Address the Challenges of the 21st Century?
Gyorgyi Galik Feb 26, 2015