[#70257] [Ruby trunk - Feature #11420] [Open] Introduce ID key table into MRI — ko1@...

Issue #11420 has been reported by Koichi Sasada.

11 messages 2015/08/06

[ruby-core:70518] [Ruby trunk - Bug #11101] Forking is killing my memory when running GC

From: ko1@...
Date: 2015-08-21 15:23:09 UTC
List: ruby-core #70518
Issue #11101 has been updated by Koichi Sasada.


Results on versions:

Without nakayoshi-fork:

```
ruby version 1.9.3
   time   pid message             shared    private
 4.034s 25939 Parent pre GC           85          0
 4.034s 25941 Child  pre GC           85          0
 8.052s 25941 Child  post GC           5         84
 8.068s 25939 Parent post GC           5         80
terminate child

ruby version 2.0.0
   time   pid message             shared    private
 4.030s 25944 Parent pre GC           67          0
 4.030s 25947 Child  pre GC           67          0
 8.045s 25947 Child  post GC           5         65
 8.066s 25944 Parent post GC           5         62
terminate child

ruby version 2.1.5
   time   pid message             shared    private
 4.032s 25950 Parent pre GC           68          0
 4.032s 25952 Child  pre GC           68          0
 8.048s 25952 Child  post GC           5         66
 8.064s 25950 Parent post GC           5         63
terminate child

ruby version 2.2.3
   time   pid message             shared    private
 4.045s 25957 Child  pre GC           71          0
 4.045s 25955 Parent pre GC           71          0
 8.072s 25957 Child  post GC           5         67
 8.081s 25955 Parent post GC           4         66
terminate child

ruby version 2.3.0
   time   pid message             shared    private
 4.032s 25964 Child  pre GC           70          0
 4.032s 25962 Parent pre GC           70          0
 8.053s 25964 Child  post GC           5         66
 8.064s 25962 Parent post GC           5         65
terminate child
```

With nakayoshi-fork:

```
ruby version 2.0.0
   time   pid message             shared    private
 4.032s 25974 Parent pre GC           67          0
 4.032s 25976 Child  pre GC           67          0
 8.065s 25974 Parent post GC           5         62
 8.065s 25976 Child  post GC           5         66
terminate child

ruby version 2.1.5
   time   pid message             shared    private
 4.071s 25982 Child  pre GC           70          1
 4.071s 25980 Parent pre GC           70          1
 8.062s 25982 Child  post GC          64          7
 8.101s 25980 Parent post GC          64          7
terminate child

ruby version 2.2.3
   time   pid message             shared    private
 4.034s 25985 Parent pre GC           70          2
 4.036s 25987 Child  pre GC           70          2
 8.034s 25987 Child  post GC          63          8
 8.073s 25985 Parent post GC          63          8
terminate child

ruby version 2.3.0
   time   pid message             shared    private
 4.019s 26035 Child  pre GC           70          1
 4.020s 26032 Parent pre GC           70          1
 8.019s 26035 Child  post GC          63          8
 8.053s 26032 Parent post GC          63          8
terminate child
```

I'm not sure why Ruby 2.0.0 is not CoW frinedly.


----------------------------------------
Bug #11101: Forking is killing my memory when running GC
https://bugs.ruby-lang.org/issues/11101#change-53921

* Author: Thomas Kalmus
* Status: Open
* Priority: Normal
* Assignee: Koichi Sasada
* ruby -v: 2.2.1
* Backport: 2.0.0: UNKNOWN, 2.1: UNKNOWN, 2.2: UNKNOWN
----------------------------------------

Memory is duplicated when forking and calling GC in 2.2.1. The main issue here is that we are operating with huge data, going up to 3GB, and one fork is enough to kill our machine.

We have written a small program that reproduces the issue (see attached file).

    The program instantiates an object and then forks into two processes.
    The GC is called in the child process.
    The memory allocation (as given by /proc/pid/smaps) changes from shared to private, thereby indicating a doubling of memory consumption.

Here is the output of the program (size is in mb):

ruby version 2.1.3
   time   pid message             shared    private
 4.011s  4723 Parent pre GC           68          0
 4.013s  4737 Child  pre GC           68          0
 8.019s  4723 Parent post GC           5         62
 8.093s  4737 Child  post GC           5         66

We have tested the program on Ubuntu 14.04 with ruby 1.9.3 and 2.2.1. The tests have been performed on a freshly installed Ubuntu machine.

We have also tried to fork 10 children and see a 10 doubling of the memory consumption, the issue only occurs after running the GC.


---Files--------------------------------
mem.rb (1.25 KB)


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

In This Thread

Prev Next