Issue #3322 has been updated by nahi.

Description updated
Assignee set to authorNari


----------------------------------------
Feature #3322: Simple Patch to make ruby copy-on-write-friendly
https://bugs.ruby-lang.org/issues/3322#change-24713

Author: Dan42
Status: Open
Priority: Normal
Assignee: authorNari
Category: core
Target version: 


=begin
 A lot has been said about ruby's lack of COW-friendliness; a full solution like REE has a performance impact, but I think I've come up with a simple trick that solves the problem of pre-forking servers. Basically, this patch implements GC.leak which marks all existing objects as ineligible for GC, and existing heaps as ineligible for allocation of new objects. It may sound hacky, but it's exactly the point of pre-forking in most cases: load a bunch of code & data and then keep it in memory forever.
 
 Compare the memory usage of these:
   ./ruby -e 'x=(1..40_000_000).map{""};          Process.fork; x=[]; GC.start; sleep 10'
   ./ruby -e 'x=(1..40_000_000).map{""}; GC.leak; Process.fork; x=[]; GC.start; sleep 10'
 
 This patch has the advantage of being 
   1) simple
   2) free of negative performance impact
   3) implemented and available now
 
 PS: As far as I can tell the patch works fine, but I'm not terribly well-versed about the innards of ruby so I'd appreciate some code review. Thanks.
=end



-- 
http://bugs.ruby-lang.org/