Company
Date Published
Author
Aaron Patterson
Word count
791
Language
English
Hacker News points
None

Summary

GitHub's recent upgrade to Ruby 2.6 has introduced an optimization that reduces memory usage by approximately 3% by eliminating the "mark array," which previously prevented garbage collection of string literals referenced in instruction sequences. Ruby's virtual machine, MRI, processes code through various phases, including tokenization, parsing, and conversion to an Abstract Syntax Tree (AST) before compiling it into byte code for execution. The optimization in Ruby 2.6 involves disassembling instruction sequences to mark operands allocated by the garbage collector, thereby eliminating the need for the mark array. Despite the additional expense of disassembly, the change results in a reduction of live objects in the heap without affecting throughput, as only 30% of instruction sequences contain objects that require marking and Ruby's generational garbage collector processes them infrequently.