# COW-friendly Ruby 1.9?

**URL:** <https://www.ruby-forum.com/t/cow-friendly-ruby-1-9/179311>\
**Category:** Ruby\
**Created:** [November 21, 2009, 9:36pm UTC](https://www.ruby-forum.com/t/cow-friendly-ruby-1-9/179311 "2009-11-21T21:36:05Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![dgm](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/df788c/32.png) [@dgm](https://www.ruby-forum.com/u/dgm)\
**Post date:** [November 21, 2009, 9:36pm UTC](https://www.ruby-forum.com/t/cow-friendly-ruby-1-9/179311/1 "2009-11-21T21:36:05Z")

</div>

Here’s my test script:

a = []  
(1024\*\*2\*10).times do  
a \<\< Object.new  
end  
puts ‘allocated’  
gets  
GC.start  
puts “GC’d”  
gets  
GC.start unless fork  
puts “GC’d and sleeping”  
sleep 10

I’m using Ruby 1.9.1 from the Ubuntu Karmic repositories on x86\_64.

This seems to use about 600 megs once it’s allocated. (I’m  
un-scientifically  
watching ‘free -m’ to see what happens.) If I don’t do the second GC,  
the  
forked child doesn’t use much more. When I do GC in the child, or in the  
parent after the fork, it pretty much exactly doubles – another 600  
megs.

This is disappointing. After all the noise from Merb, Unicorn, Phusion,  
and  
“enterprise edition”, and especially considering that forking is the  
only real  
way to make MRI scale to multiple cores, I’d have expected some sort of  
COW-  
friendly GC to have been merged already. Wasn’t someone working on this  
somewhere back in 1.9.0?

Or is there something wrong with my benchmark? I mean, it’s clearly  
artificial,  
and I haven’t tried comparing it to the various “enterprise edition”  
patches.

---

<div class="post-metadata">

**Author:** ![dgm](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/df788c/32.png) [@dgm](https://www.ruby-forum.com/u/dgm)\
**Post date:** [November 21, 2009, 10:19pm UTC](https://www.ruby-forum.com/t/cow-friendly-ruby-1-9/179311/2 "2009-11-21T22:19:23Z")

</div>

On Sat, Nov 21, 2009 at 12:26 PM, David M. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> This is disappointing. After all the noise from Merb, Unicorn, Phusion, and  
> “enterprise edition”, and especially considering that forking is the only real  
> way to make MRI scale to multiple cores, I’d have expected some sort of COW-  
> friendly GC to have been merged already. Wasn’t someone working on this  
> somewhere back in 1.9.0?

See [ruby-core:19799] for a bitmap-marking GC patch.

jeremy

---

<div class="post-metadata">

**Author:** ![dgm](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/df788c/32.png) [@dgm](https://www.ruby-forum.com/u/dgm)\
**Post date:** [November 21, 2009, 10:59pm UTC](https://www.ruby-forum.com/t/cow-friendly-ruby-1-9/179311/3 "2009-11-21T22:59:46Z")

</div>

On Saturday 21 November 2009 03:14:14 pm Jeremy K. wrote:

> On Sat, Nov 21, 2009 at 12:26 PM, David M. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:
> 
> > This is disappointing. After all the noise from Merb, Unicorn, Phusion,  
> > and “enterprise edition”, and especially considering that forking is the  
> > only real way to make MRI scale to multiple cores, I’d have expected some  
> > sort of COW- friendly GC to have been merged already. Wasn’t someone  
> > working on this somewhere back in 1.9.0?
> 
> See [ruby-core:19799] for a bitmap-marking GC patch.

Yes, I saw that. Something about SEGV in make test – and I really don’t  
see  
any follow-up to that. What’s the status of getting something like this  
actually in core and stable?

---

<div class="post-metadata">

**Author:** ![dgm](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/df788c/32.png) [@dgm](https://www.ruby-forum.com/u/dgm)\
**Post date:** [November 22, 2009, 10:34am UTC](https://www.ruby-forum.com/t/cow-friendly-ruby-1-9/179311/4 "2009-11-22T10:34:29Z")

</div>

On Nov 21, 2009, at 13:50 , David M. wrote:

> Yes, I saw that. Something about SEGV in make test – and I really don’t see  
> any follow-up to that. What’s the status of getting something like this  
> actually in core and stable?

You can help by re-asking this in ruby-core@

---

<div class="post-metadata">

**Author:** ![dgm](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/df788c/32.png) [@dgm](https://www.ruby-forum.com/u/dgm)\
**Post date:** [November 22, 2009, 2:44pm UTC](https://www.ruby-forum.com/t/cow-friendly-ruby-1-9/179311/5 "2009-11-22T14:44:55Z")

</div>

Hi,

In message “Re: COW-friendly Ruby 1.9?”  
on Sun, 22 Nov 2009 05:26:33 +0900, David M.  
[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) writes:

|Or is there something wrong with my benchmark? I mean, it’s clearly artificial,  
|and I haven’t tried comparing it to the various “enterprise edition” patches.

The REE patch made Ruby so slow on some non-Web cases. AuthorNari  
made the faster patch. But it’s still (much) slower than the original  
GC for non forking programs. Besides that, the patch had the serious  
bug which we could not identify for long time.

Ko1 is working on improvement on Ruby’s memory management (not GC).  
We have good chance to make the GC COW friendly base on that  
improvement. Stay tuned.

```
          matz.

```
