Question

I have read some where that ruby fork are COW friendly ok here the link

But then when I happen to google around for more info on it I found out that Ruby does not support COW (copy on write)

Now I'm actually a bit confuse whether ruby actually support or not COW functionality

I'm also aware that REE and Rubinius has a COW friendly GC so does that me REE and Rubinius support COW functionality

I yes I'm dying to test it , can anyone suggest me that if ruby support COW functionality then how to write a sample code to test COW concept in Ruby

Thanks

Was it helpful?

Solution

fork being copy-on-write is a property of your operating system kernel, not Ruby. On most UNIX-like systems, it is.

On Linux, for example, you can look in /proc/pid/smaps and look for how much of the heap mapping is shared. Here is an example from bash doing a fork:

02020000-023cd000 rw-p 00000000 00:00 0                                  [heap]
Size:               3764 kB
Rss:                3716 kB
Pss:                1282 kB
Shared_Clean:          0 kB
Shared_Dirty:       3652 kB
Private_Clean:         0 kB
Private_Dirty:        64 kB
Referenced:          144 kB
Anonymous:          3716 kB
AnonHugePages:         0 kB
Swap:                  0 kB
KernelPageSize:        4 kB
MMUPageSize:           4 kB
Locked:                0 kB

So, out of its 3764k heap, 3652k is shared. See proc.txt for documentation on the files in /proc.

Of course, Ruby may have something that causes the COW pages to be copied (e.g., maybe its garbage collector writes to each page), but you'll be able to see that by the shared count going to 0.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top