summaryrefslogtreecommitdiff
path: root/gc.c
diff options
context:
space:
mode:
authornaruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-02-19 06:00:46 +0000
committernaruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-02-19 06:00:46 +0000
commit56b6eed32320c4793ee105d5bf23041804d0a0e3 (patch)
tree2cd241ea539e0dcb3620069a4f2942b431abcb0b /gc.c
parent879ac9dec2ccb6a006ae6aa075110f6a8946547c (diff)
merge revision(s) 45021,45022,45028: [Backport #9524]
* gc.c: introduce new environment variable "RUBY_GC_HEAP_OLDOBJECT_LIMIT_FACTOR" to control major/minor GC frequency. Do full GC when the number of old objects is more than R * N where R is this factor and * test/ruby/test_gc.rb: add a test. * gc.c (get_envparam_double): fix a warning message. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@45044 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'gc.c')
-rw-r--r--gc.c20
1 files changed, 16 insertions, 4 deletions
diff --git a/gc.c b/gc.c
index 1d182310e0..bcf4769b7f 100644
--- a/gc.c
+++ b/gc.c
@@ -108,6 +108,9 @@ rb_gc_guarded_ptr(volatile VALUE *ptr)
#ifndef GC_HEAP_GROWTH_MAX_SLOTS
#define GC_HEAP_GROWTH_MAX_SLOTS 0 /* 0 is disable */
#endif
+#ifndef GC_HEAP_OLDOBJECT_LIMIT_FACTOR
+#define GC_HEAP_OLDOBJECT_LIMIT_FACTOR 2.0
+#endif
#ifndef GC_MALLOC_LIMIT_MIN
#define GC_MALLOC_LIMIT_MIN (16 * 1024 * 1024 /* 16MB */)
@@ -134,6 +137,7 @@ typedef struct {
unsigned int heap_free_slots;
double growth_factor;
unsigned int growth_max_slots;
+ double oldobject_limit_factor;
unsigned int malloc_limit_min;
unsigned int malloc_limit_max;
double malloc_limit_growth_factor;
@@ -150,6 +154,7 @@ static ruby_gc_params_t gc_params = {
GC_HEAP_INIT_SLOTS,
GC_HEAP_GROWTH_FACTOR,
GC_HEAP_GROWTH_MAX_SLOTS,
+ GC_HEAP_OLDOBJECT_LIMIT_FACTOR,
GC_MALLOC_LIMIT_MIN,
GC_MALLOC_LIMIT_MAX,
GC_MALLOC_LIMIT_GROWTH_FACTOR,
@@ -4498,10 +4503,12 @@ gc_marks(rb_objspace_t *objspace, int full_mark)
#endif
gc_marks_body(objspace, TRUE);
-
- /* Do full GC if old/remembered_shady object counts is greater than counts two times at last full GC counts */
- objspace->rgengc.remembered_shady_object_limit = objspace->rgengc.remembered_shady_object_count * 2;
- objspace->rgengc.old_object_limit = objspace->rgengc.old_object_count * 2;
+ {
+ /* See the comment about RUBY_GC_HEAP_OLDOBJECT_LIMIT_FACTOR */
+ const double r = gc_params.oldobject_limit_factor;
+ objspace->rgengc.remembered_shady_object_limit = objspace->rgengc.remembered_shady_object_count * r;
+ objspace->rgengc.old_object_limit = objspace->rgengc.old_object_count * r;
+ }
}
else { /* minor GC */
gc_marks_body(objspace, FALSE);
@@ -5706,6 +5713,10 @@ gc_set_initial_pages(void)
* - (next slots number) = (current slots number) * (this factor)
* * RUBY_GC_HEAP_GROWTH_MAX_SLOTS (new from 2.1)
* - Allocation rate is limited to this factor.
+ * * RUBY_GC_HEAP_OLDOBJECT_LIMIT_FACTOR (new from 2.1.1)
+ * - Do full GC when the number of old objects is more than R * N
+ * where R is this factor and
+ * N is the number of old objects just after last full GC.
*
* * obsolete
* * RUBY_FREE_MIN -> RUBY_GC_HEAP_FREE_SLOTS (from 2.1)
@@ -5742,6 +5753,7 @@ ruby_gc_set_params(int safe_level)
get_envparam_double("RUBY_GC_HEAP_GROWTH_FACTOR", &gc_params.growth_factor, 1.0);
get_envparam_int ("RUBY_GC_HEAP_GROWTH_MAX_SLOTS", &gc_params.growth_max_slots, 0);
+ get_envparam_double("RUBY_GC_HEAP_OLDOBJECT_LIMIT_FACTOR", &gc_params.oldobject_limit_factor, 0.0);
get_envparam_int("RUBY_GC_MALLOC_LIMIT", &gc_params.malloc_limit_min, 0);
get_envparam_int("RUBY_GC_MALLOC_LIMIT_MAX", &gc_params.malloc_limit_max, 0);