Hasty Briefsbeta

Bilingual

Unlocking Ractors: Object_id

a year ago
  • #Performance
  • #Ruby
  • #Ractors
  • Ractors in Ruby are evolving with efforts to fix bugs and reduce contention points, improving performance.
  • Recent changes include replacing the fstring_table with a lock-free Hash-Set, doubling the speed of Ractor JSON benchmarks.
  • The #object_id method has become a contention point due to its implementation changes in Ruby 2.7, which introduced internal hash tables for stability during GC compaction.
  • Proposed optimizations for #object_id include lazy initialization of the ID-to-object table and storing object IDs inline within objects to reduce synchronization needs.
  • Challenges remain with objects that cannot store instance variables inline (like T_STRING, T_ARRAY), requiring alternative solutions to avoid global synchronization.
  • The patch aims to make #object_id access lock-free in many cases, though further work is needed for generic objects and lock-free shape creation.