mul overflow efficiently.
* include/ruby/ruby.h (rb_alloc_tmp_buffer2): use rb_mul_size_overflow
and avoid division where it can define DSIZE_T.
* gc.c (xmalloc2_size): moved from ruby.h and use rb_mul_size_overflow.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54704 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
avoid duplicated check of size.
* gc.c (ruby_xmalloc2): added to keep separate layers.
* include/ruby/ruby.h (rb_alloc_tmp_buffer2): added to check
the size more statically.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54664 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
used by objspace_xmalloc and objspace_xcalloc.
objspace_xmalloc introduces its own check in this commit.
objspace_xcalloc checks with xmalloc2_size (ruby_xmalloc2_size).
* gc.c (objspace_xmalloc0): common xmalloc function.
* gc.c (objspace_xmalloc): introduce its own size check.
* gc.c (objspace_xmalloc2): separated from ruby_xmalloc2 to clarify
the layer who has the responsibility to check the size.
* gc.c (objspace_xrealloc): remove duplicated size check.
* gc.c (ruby_xmalloc2): use objspace_xmalloc2.
* include/ruby/ruby.h (ruby_xmalloc2_size): follow the size limit
as SSIZE_MAX. Note that ISO C says size_t is unsigned integer.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54661 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
RUBY_GC_HEAP_FREE_SLOTS_MIN_RATIO 0.3 -> 0.2
RUBY_GC_HEAP_FREE_SLOTS_MAX_RATIO 0.8 -> 0.65
These values are same as Ruby 2.0.0.
This change cause GC counts.
However, generational GC reduced each (minor) GC time and
increase memory locality. So that not so big impact on my
benchmarking results.
(surprizingly, this fix speed up programs on some cases)
You can change these values by environment variables
if you feel wrong.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54482 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
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
Introduce new environement variable
GC_HEAP_FREE_SLOTS_GOAL_RATIO (goal_ratio) to calculate the ratio
of additional memory.
Before this change, we add pages with the following formula
(when free_slots < total_pages * RUBY_GC_HEAP_FREE_SLOTS_MIN_RATIO):
next_pages = total_pages * RUBY_GC_HEAP_GROWTH_FACTOR
This addition can allocate too much.
With this change, we increase pages to satisfy the following formula:
next_free_slots = next_total_slots * goal_ratio
where
next_free_slots = free_slots + adding_slots
next_total_slots = total_slots + adding_slots.
If you want to prepare many free slots, increase this ratio.
If this variable is 0, then simply multiply
RUBY_GC_HEAP_GROWTH_FACTOR.
* gc.c (get_envparam_double): enable to accept 0.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54453 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Before this change, heap_pages_min_slots are calculated at the
beggining sweeping phase. And this value is used at the end of
*next* marking phase.
To simplify it, we use this value at the end of this marking phase.
It means that we don't need to store this value as global state.
Also heap_pages_max_slots is calculated at the begging of sweeping
phase and used at the end of sweeping phase.
To simplify this logic, we introduced new global value
heap_pages_freeable_pages it means extra pages count we can free.
gc_sweep_step() checks this value and moves empty pages to tomb_heap
not more than this value.
Because of this fix, heap_pages_swept_slots is no longer needed.
* gc.c (rb_objspace_t::heap_pages): restruct the objspace global
status.
remove the following fileds
* swept_slots (and heap_pages_swept_slots)
* min_free_slots (and heap_pages_min_free_slots)
* max_free_slots (and heap_pages_max_free_slots)
And add the following filed.
* freeable_pages (and heap_pages_freeable_pages)
* gc.c (heap_pages_free_unused_pages): unlink tomb heap pages
because tomb heap should have only freeable pages.
* gc.c (heap_extend_pages): add parameters for future extension.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54451 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* RUBY_GC_HEAP_FREE_SLOTS_MIN_RATIO:
allocate additional pages when free slots is lower than
the value (total_slots * (this ratio)).
* RUBY_GC_HEAP_FREE_SLOTS_MAX_RATIO:
allow to free pages when free slots is greater thatn
the value (total_slots * (this ratio)).
Before this change, these values are hard coded.
* gc.c (ruby_gc_params_t): ditto.
* gc.c (ruby_gc_set_params): ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54450 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* gc.c (gc_sweep_step): use returned free slots count.
* gc.c (gc_sweep_step): change variable name `next'
to `next_sweep_page'.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54447 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* gc.c (tick): Use __builtin_ppc_get_timebase for POWER arch.
[Fix GH-1291]
This gives a little performance improvement
user system total real
Before: 20.870000 0.000000 20.870000 ( 20.893959)
After: 20.720000 0.000000 20.720000 ( 20.733970)
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54145 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* gc.c (mark_stack_locations): extract the common part from
mark_current_machine_context and rb_gc_mark_machine_stack.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54116 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* gc.c (rb_objspace_of): macro to get the objspace from a thread.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54115 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
because there is a same name (no related) function gc_stat().
Also gc_stat_* are renamed to gc_mode_*,
gc_stat_transition() to gc_mode_transition(),
rb_objspace:🎏:stat is renamed to rb_objspace:🎏:mode.
Change rb_objspace:🎏:mode from 2 bits to 3 bits because VC++
returns negative enum value with 2 bits.
* gc.c (gc_mode): add a macro to access rb_objspace:🎏:mode
with verification code (verification is enabled only on
RGENGC_CHECK_MODE > 0).
* gc.c (gc_mode_set): same macro for setter.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53996 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* error.c (rb_assert_failure): assertion with stack dump.
* ruby_assert.h (RUBY_ASSERT): new header for the assertion.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53615 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Keys of GC::INTERNAL_CONSTANTS are also renamed.
* test/ruby/test_gc.rb: catch up this fix.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53468 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
`page_length' is not clear (we may understand with length of
a page).
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53464 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
whether a page is in a tomb or not. Instead of this field,
heap_page:🎏:in_tomb (1 bit field) is added.
Also type of heap_page::(total|free|final)_slots are changed from
int to short. 2B is enough for them.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53461 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* gc.c (internal_object_p): should not expose singleton classes
without a metaclass. based on patches by ko1 and shugo.
[Bug #11740]
* class.c (rb_singleton_class_object_p): added.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53243 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Suppress "syntax error: empty declaration" warnings by
Oracle Solaris Studio 12.x on Solaris. [Bug #11821]
* hash.c: ditto, after NOINSERT_UPDATE_CALLBACK().
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53129 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
NULL checking is finished Before call of memsize functions.
See r52979.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52986 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* gc.c (rb_objspace_data_type_memsize): consider NULL data uses no
memory without calling dsize function as well as other functions.
fix SEGV in test/objspace with RUBY_ISEQ_DUMP_DEBUG=to_binary.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52979 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
even if it is GC.disable'd.
* test/ruby/test_gc.rb: add a test.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52672 b2dd03c8-39d4-4d8f-98ff-823fe69b080e