Ruby is a popular object-oriented programming language, and the performance of the Ruby garbage collector (GC) directly affects the execution time of Ruby programs. Ruby 2.0 and earlier versions employed an inefficient non-generational conservative mark-and-sweep GC. To improve this and make it a generational collector, it is necessary to introduce write barriers (WBs), but this requires huge modification to existing source code, including third-party C-extensions. To avoid the need for adding WBs around legacy code, we invented a new concept called ``WB-unprotected objects'', which indicates to the GC to treat such objects more conservatively. By leveraging this design, we were able to improve the performance of Ruby 2.1 with a generational GC and of Ruby 2.2 with an incremental GC while preserving compatibility with existing C-extensions. Another significant advantage of this approach is that WBs can be added gradually, which reduces the difficulties associated with updating existing code.
[1]
Joel F. Bartlett,et al.
Mostly-Copying Garbage Collection Picks Up Generations and C++
,
1999
.
[2]
Dave Thomas,et al.
Agile Web Development with Rails
,
2005
.
[3]
Scott Shenker,et al.
Mostly parallel garbage collection
,
1991,
PLDI '91.
[4]
Hanspeter Mössenböck,et al.
An object storage model for the truffle language implementation framework
,
2014,
PPPJ '14.
[5]
Richard E. Jones,et al.
The Garbage Collection Handbook: The art of automatic memory management
,
2011,
Chapman and Hall / CRC Applied Algorithms and Data Structures Series.
[6]
Kathryn S. McKinley,et al.
In or out?: putting write barriers in their place
,
2002,
ISMM '02.