We only need one sweep time measurement without lazy sweep.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43427 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* gc.c (GC_MALLOC_LIMIT): change default value to 16MB.
* gc.c (GC_MALLOC_LIMIT_GROWTH_FACTOR): change default value to 2.0.
* gc.c (gc_before_sweep): change decrease ratio of `malloc_limit'
from 1/4 to 1/10.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43425 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
gc_rest_sweep() can reduce malloc_increase, so try it before GC.
Otherwise, malloc_increase can be less than malloc_limit at
gc_before_sweep(). This means that re-calculation of malloc_limit
may be wrong value.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43424 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
After rb_gc_force_recycle() for a object blonging to heap->freelist,
`heap->using_page->freelist' is not null.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43421 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Share `increment' information with heaps.
* gc.c: change ratio of heap_pages_free_min_page
to 0.80.
This change means slow down page freeing speed.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43397 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Tomb heap is where zombie objects and ghost (freed slot) lived in.
Separate from other heaps (now there is only eden heap) at sweeping
helps freeing pages more efficiently.
Before this patch, even if there is an empty page at former phase
of sweeping, we can't free it.
Algorithm:
(1) Sweeping all pages in a heap and move empty pages from the
heap to tomb_heap.
(2) Check all exsisting pages and free a page
if all slots of this page are empty and
there is enough empty slots (checking by swept_num)
To introduce this pach, there are several tuning of GC parameters.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43395 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Now, objects are managed by page. And a set of pages is called heap.
This commit supports multiple heaps in the object space.
* Functions heap_* and rb_heap_t manages heap data structure.
* Functions heap_page_* and struct heap_page manage page data
strcuture.
* Functions heap_pagse_* and struct rb_objspace_t::heap_pages
maintains all pages.
For example, pagaes are allocated from the heap_pages.
See https://bugs.ruby-lang.org/projects/ruby-trunk/wiki/GC_design
and https://bugs.ruby-lang.org/attachments/4015/data-heap_structure_with_multiple_heaps.png
for more deitals.
Now, there is only one heap called `eden', which is a space for all
new generated objects.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43388 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
There is a bug that T_ZOMBIE objects are not collected.
Because there is a pass to miss finalizer postponed job
with multi-threading. This patch solve this issue.
* vm_trace.c (rb_postponed_job_register_one): set
RUBY_VM_SET_POSTPONED_JOB_INTERRUPT(th) if another same job
is registered.
There is a possibility to remain a postponed job without
interrupt flag.
* vm_trace.c (rb_postponed_job_register_one): check interrupt
carefully.
* vm_trace.c (rb_postponed_job_register_one): use additional space
to avoid buffer full.
* gc.c (gc_finalize_deferred_register): check failure.
* thread.c (rb_threadptr_execute_interrupts): check
`postponed_job_interrupt' immediately. There is a possibility
to miss this flag.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43383 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* make "struct heap" and move most of variables
in rb_objspace_t::heap.
* rename rb_objspace_t::heap::sorted to
rb_objspace_t::heap_sorted_pages
and make a macro heap_sorted_pages.
* rename rb_objspace_t::heap::range to
rb_objspace_t::heap_range and rename macros
lomem/himem to heap_lomem/heap_himem.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43360 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Change "slot" to "page". "Slot" is a space of RVALUE.
1. "Heap" consists of a set of "heap_page"s (pages).
2. Each "heap_page" has "heap_page_body".
3. "heap_page_body" has RVALUE (a.k.a. "slot") spaces.
4. "sorted" is a sorted array of "heap_page"s, sorted
by address of heap_page_body (for "is_pointer_to_heap").
See https://bugs.ruby-lang.org/attachments/4008/data-heap_structure.png.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43350 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This macro enable checker compare with allocated memory and
declared old_size of sized_xfree and sized_xrealloc.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43336 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This API provides information which objects are root objects.
`category' shows what kind of root objects.
* gc.c (gc_mark_roots): separate from gc_marks_body().
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43294 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* vm.c, vm_core.h (rb_vm_add_root_module): added to register as a
defined root module or class.
This guard helps mark miss from defined classes/modules they are
only refered from C's global variables in C-exts.
Basically, it is extension's bug.
Register to hash object VM has.
Marking a hash objects allows generational GC supports.
* gc.c (RGENGC_PRINT_TICK): disable (revert).
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43263 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Each symbols has String objects respectively to represent
Symbols.
These objects are marked only when:
* full marking
* new symbols are added
This hack reduce symbols (related strings) marking time.
For example, on my Linux environment, the following code
"20_000_000.times{''}"
with 40k symbols (similar symbol number on Rails 3.2.14 app,
@jugyo tells me) boosts, from 7.3sec to 4.2sec.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43255 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* gc.c: rename heap.free_num as heap.swept_num to clarify meaning and
avoid confusion with objspace_free_num().
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43140 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* gc.c (objspace_free_num): new method for available/free slots on
heap. [ruby-core:57633] [Bug #8983]
* gc.c (gc_stat): change heap_free_num definition to use new method.
* test/ruby/test_gc.rb: test for above.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43139 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* gc.c: add rb_objspace.limit to keep accurate count of total heap
slots [ruby-core:57633] [Bug #8983]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43138 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* gc.c (GC_MALLOC_LIMIT_MAX): change default value
(256MB -> 512MB) and permit zero to ignore max value.
* gc.c (vm_malloc_increase, vm_xrealloc): do not cause GC on realloc.
* gc.c (gc_before_sweep): change debug messages.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43119 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This fix may solve a failure of
TestTracepointObj#test_tracks_objspace_events
[test/-ext-/tracepoint/test_tracepoint.rb:43].
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43092 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
RUBY_GC_MALLOC_LIMIT_MAX and RUBY_GC_MALLOC_LIMIT_GROWTH_FACTOR.
See r43067 for details.
* gc.c (rb_gc_set_params): refactoring. And change verbose notation.
Mostly duplicated functions get_envparam_int/double is not cool.
Please rewrite it.
* test/ruby/test_gc.rb: fix a test for this change.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43072 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
If you enable RGENGC_PRINT_TICK to 1, then profiling results by RDTSC
(on x86/amd64 environment) are printed at last.
Thanks Yoshii-san.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43068 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Now, malloc_limit is increased/decreased by mysterious logic.
This fix simplify malloc_limit increase/decrease logic such as:
if (malloc_increase > malloc_limit) /* so many malloc */
malloc_limit += malloc_limit * (GC_MALLOC_LIMIT_FACTOR-1);
else
malloc_limit -= malloc_limit * (GC_MALLOC_LIMIT_FACTOR-1)/4;
Default value of GC_MALLOC_LIMIT_FACTOR is 1.8.
malloc_limit is bounded by GC_MALLOC_LIMIT_MAX (256MB by default).
This logic runs at before_sweeep(). So there are no effect from
caused by lazy sweep. And we can remove malloc_increase2.
* gc.c (HEAP_MIN_SLOTS, FREE_MIN, HEAP_GROWTH_FACTOR): rename to
GC_HEAP_MIN_SLOTS, GC_FREE_MIN, GC_HEAP_GROWTH_FACTOR respectively.
Check them by `#ifndef' so you can specify these values outside gc.c.
* gc.c (ruby_gc_params_t): add initial_malloc_limit_factor and
initial_malloc_limit_max.
* gc.c (vm_malloc_prepare, vm_xrealloc): use vm_malloc_increase to
add and check malloc_increase.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43067 b2dd03c8-39d4-4d8f-98ff-823fe69b080e