1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* gc.c (get_envparam_double): take an upper_bound.

And also take an accept_zero flag which allow to accept zero
  even if lower_bound is set.

* gc.c (ruby_gc_set_params): fix parameters.

  RUBY_GC_HEAP_FREE_SLOTS_MAX_RATIO set 0.9 as *lower_bound*, so that
  it should be upper_bound.
  Set RUBY_GC_HEAP_FREE_SLOTS_MIN_RATIO as lower bound.

  Also set lower/upper bound of RUBY_GC_HEAP_FREE_SLOTS_GOAL_RATIO to
  RUBY_GC_HEAP_FREE_SLOTS_MIN/MAX_RATIO.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54481 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
ko1 2016-04-04 08:41:55 +00:00
parent 60f14c29f2
commit 3287bad257
2 changed files with 46 additions and 12 deletions

View file

@ -1,3 +1,19 @@
Mon Apr 4 17:36:52 2016 Koichi Sasada <ko1@atdot.net>
* gc.c (get_envparam_double): take an upper_bound.
And also take an accept_zero flag which allow to accept zero
even if lower_bound is set.
* gc.c (ruby_gc_set_params): fix parameters.
RUBY_GC_HEAP_FREE_SLOTS_MAX_RATIO set 0.9 as *lower_bound*, so that
it should be upper_bound.
Set RUBY_GC_HEAP_FREE_SLOTS_MIN_RATIO as lower bound.
Also set lower/upper bound of RUBY_GC_HEAP_FREE_SLOTS_GOAL_RATIO to
RUBY_GC_HEAP_FREE_SLOTS_MIN/MAX_RATIO.
Mon Apr 4 16:41:32 2016 Koichi Sasada <ko1@atdot.net>
* vm.c (Init_VM): should pass tokens.

42
gc.c
View file

@ -7316,7 +7316,7 @@ get_envparam_size(const char *name, size_t *default_value, size_t lower_bound)
}
static int
get_envparam_double(const char *name, double *default_value, double lower_bound)
get_envparam_double(const char *name, double *default_value, double lower_bound, double upper_bound, int accept_zero)
{
char *ptr = getenv(name);
double val;
@ -7328,14 +7328,29 @@ get_envparam_double(const char *name, double *default_value, double lower_bound)
if (RTEST(ruby_verbose)) fprintf(stderr, "invalid string for %s: %s\n", name, ptr);
return 0;
}
if (val >= lower_bound) {
if (accept_zero && val == 0.0) {
goto accept;
}
else if (val <= lower_bound) {
if (RTEST(ruby_verbose)) {
fprintf(stderr, "%s=%f (default value: %f) is ignored because it must be greater than %f.\n",
name, val, *default_value, lower_bound);
}
}
else if (upper_bound != 0.0 && /* ignore upper_bound if it is 0.0 */
val > upper_bound) {
if (RTEST(ruby_verbose)) {
fprintf(stderr, "%s=%f (default value: %f) is ignored because it must be lower than %f.\n",
name, val, *default_value, upper_bound);
}
}
else {
accept:
if (RTEST(ruby_verbose)) fprintf(stderr, "%s=%f (default value: %f)\n", name, val, *default_value);
*default_value = val;
return 1;
}
else {
if (RTEST(ruby_verbose)) fprintf(stderr, "%s=%f (default value: %f) is ignored because it must be greater than %f.\n", name, val, *default_value, lower_bound);
}
}
return 0;
}
@ -7416,16 +7431,19 @@ ruby_gc_set_params(int safe_level)
gc_set_initial_pages();
}
get_envparam_double("RUBY_GC_HEAP_GROWTH_FACTOR", &gc_params.growth_factor, 1.0);
get_envparam_double("RUBY_GC_HEAP_GROWTH_FACTOR", &gc_params.growth_factor, 1.0, 0.0, FALSE);
get_envparam_size ("RUBY_GC_HEAP_GROWTH_MAX_SLOTS", &gc_params.growth_max_slots, 0);
get_envparam_double("RUBY_GC_HEAP_FREE_SLOTS_MIN_RATIO", &gc_params.heap_free_slots_min_ratio, 0.1);
get_envparam_double("RUBY_GC_HEAP_FREE_SLOTS_GOAL_RATIO", &gc_params.heap_free_slots_goal_ratio, 0.0);
get_envparam_double("RUBY_GC_HEAP_FREE_SLOTS_MAX_RATIO", &gc_params.heap_free_slots_max_ratio, 0.9);
get_envparam_double("RUBY_GC_HEAP_OLDOBJECT_LIMIT_FACTOR", &gc_params.oldobject_limit_factor, 0.0);
get_envparam_double("RUBY_GC_HEAP_FREE_SLOTS_MIN_RATIO", &gc_params.heap_free_slots_min_ratio,
0.0, 1.0, FALSE);
get_envparam_double("RUBY_GC_HEAP_FREE_SLOTS_MAX_RATIO", &gc_params.heap_free_slots_max_ratio,
gc_params.heap_free_slots_min_ratio, 1.0, FALSE);
get_envparam_double("RUBY_GC_HEAP_FREE_SLOTS_GOAL_RATIO", &gc_params.heap_free_slots_goal_ratio,
gc_params.heap_free_slots_min_ratio, gc_params.heap_free_slots_max_ratio, TRUE);
get_envparam_double("RUBY_GC_HEAP_OLDOBJECT_LIMIT_FACTOR", &gc_params.oldobject_limit_factor, 0.0, 0.0, TRUE);
get_envparam_size ("RUBY_GC_MALLOC_LIMIT", &gc_params.malloc_limit_min, 0);
get_envparam_size ("RUBY_GC_MALLOC_LIMIT_MAX", &gc_params.malloc_limit_max, 0);
get_envparam_double("RUBY_GC_MALLOC_LIMIT_GROWTH_FACTOR", &gc_params.malloc_limit_growth_factor, 1.0);
get_envparam_double("RUBY_GC_MALLOC_LIMIT_GROWTH_FACTOR", &gc_params.malloc_limit_growth_factor, 1.0, 0.0, FALSE);
#if RGENGC_ESTIMATE_OLDMALLOC
if (get_envparam_size("RUBY_GC_OLDMALLOC_LIMIT", &gc_params.oldmalloc_limit_min, 0)) {
@ -7433,7 +7451,7 @@ ruby_gc_set_params(int safe_level)
objspace->rgengc.oldmalloc_increase_limit = gc_params.oldmalloc_limit_min;
}
get_envparam_size ("RUBY_GC_OLDMALLOC_LIMIT_MAX", &gc_params.oldmalloc_limit_max, 0);
get_envparam_double("RUBY_GC_OLDMALLOC_LIMIT_GROWTH_FACTOR", &gc_params.oldmalloc_limit_growth_factor, 1.0);
get_envparam_double("RUBY_GC_OLDMALLOC_LIMIT_GROWTH_FACTOR", &gc_params.oldmalloc_limit_growth_factor, 1.0, 0.0, FALSE);
#endif
}