summaryrefslogtreecommitdiff
path: root/gc.c
AgeCommit message (Collapse)Author
2013-10-26* gc.c: catch up recent changes to compile on GC_DEBUG,ktsj
RGENGC_CHECK_MODE. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43434 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-10-26* gc.c (gc_profile_dump_on): use "Page" terminology.ko1
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43428 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-10-26* gc.c (gc_sweep, gc_heap_lazy_sweep): fix measurement code.ko1
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
2013-10-26* gc.c: tuning parameters.ko1
* 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
2013-10-26* gc.c (vm_malloc_increase): do gc_rest_sweep() before GC.ko1
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
2013-10-25 * gc.c (gc_before_heap_sweep): Restructure code to mean clearly.tarui
heap->freelist is connected to end of list. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43423 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-10-25* gc.c (gc_before_heap_sweep): fix freelist management.ko1
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
2013-10-23* gc.c: add new initial_growth_max tuning parameter. [ruby-core:57928] [Bug ↵tmm1
#9035] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43409 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-10-23* gc.c: Rename free_min to min_free_slots and free_min_page to ↵tmm1
max_free_slots. The algorithm for heap growth is: if (swept_slots < min_free_slots) pages++ if (swept_slots > max_free_slots) pages-- git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43399 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-10-23* gc.c: move increment from heap to heap_pages.ko1
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
2013-10-23* gc.c (heap_pages_free_unused_pages): cast to (int) for size_tko1
variable `i'. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43396 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-10-23* gc.c: introduce tomb heap.ko1
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
2013-10-23* gc.c (gc_prof_sweep_timer_stop): catch up recent changesko1
to compile on GC_PROFILE_MORE_DETAIL=1. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43394 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-10-22* gc.c (Init_heap): move logics from heap_pages_init() and removeko1
heap_pages_init(). git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43389 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-10-22* gc.c: allow multiple heaps.ko1
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
2013-10-22* vm_trace.c: exterminate Zombies.ko1
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
2013-10-18gc.c: fix aritynobu
* gc.c (Init_GC): fix arity of key? method. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43361 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-10-18* gc.c: fix rb_objspace_t.ko1
* 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
2013-10-18* gc.c (wmap_inspect_i): fix inspect format.nobu
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43354 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-10-18* gc.c (wmap_inspect_i): fix callback argument.nobu
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43353 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-10-18gc.c: ObjectSpace::WeakMap inspection and iteration methodsnobu
* gc.c (wmap_inspect, wmap_each, wmap_each_key, wmap_each_value), (wmap_keys, wmap_values): add inspection and iteration methods to ObjectSpace::WeakMap for debug. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43352 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-10-18gc.c: ObjectSpace::WeakMap#key?nobu
* gc.c (wmap_each_i): add ObjectSpace::WeakMap#key? method. * lib/weakref.rb (WeakRef#weakref_alive): use above method. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43351 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-10-18* gc.c: change terminology of heap.ko1
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
2013-10-17* gc.c (CALC_EXACT_MALLOC_SIZE_CHECK_OLD_SIZE): introduced.ko1
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
2013-10-17* gc.c, internal.h: rename ruby_xsizefree/realloc toko1
rb_sized_free/realloc. * array.c: catch up these changes. * string.c: ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43333 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-10-17* gc.c, internal.h: add new internal memory mangement functions.ko1
* void *ruby_xsizedrealloc(void *ptr, size_t new_size, size_t old_size) * void ruby_xsizedfree(void *x, size_t size) These functions acccept additional size parameter to calculate more accurate malloc_increase parameter which control GC timing. [Feature #8985] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43330 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-10-16* gc.c (objspace_each_objects): do not skip empty RVALUEs.ko1
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43313 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-10-15* gc.c (gc_mark_roots): rename roots to be categories instead of function names.tmm1
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43296 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-10-15* remove trailing spaces.nobu
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43295 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-10-15* gc.h (rb_objspace_reachable_objects_from_root): added.ko1
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
2013-10-11* class.c, variable.c, gc.c (rb_class_tbl): removed.ko1
* 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
2013-10-11revert r43259 because it is possible to mark miss classes defined in C-exts. ↵ko1
Thanks charliesome. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43261 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-10-11* class.c, variable.c, gc.c (rb_class_tbl): removed.ko1
rb_class_tbl is no longer used. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43259 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-10-11* gc.c: use terminology `full_mark' instead of `minor_gc'ko1
in mark functions. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43257 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-10-11* gc.c: use __GNUC__ instead of __GCC__.ko1
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43256 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-10-11* gc.c, parse.y: support generational Symbol relatetd marking.ko1
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
2013-10-04gc.c: rename heap.free_num to heap.swept_numtmm1
* 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
2013-10-04gc.c: add objspace_free_num and make GC.stat[:heap_free_num] use ittmm1
* 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
2013-10-04gc.c: add rb_objspace.limittmm1
* 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
2013-10-03* gc.c: define gc_profile_record::allocated_size ifko1
CALC_EXACT_MALLOC_SIZE is true. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43130 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-10-02* gc.c: relax GC condition due to malloc_limit.ko1
* 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
2013-09-30gc.c: suppress warningsnobu
* gc.c (gc_before_sweep): use PRIuSIZE instead of "%zu" directly. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43094 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-09-30* gc.c (rb_gc_disable): do rest_sweep() before disable GC.ko1
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
2013-09-27* gc.c: add two GC tuning environment variables.ko1
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
2013-09-27* gc.c (GC_MALLOC_LIMIT): 8,000,000 -> 8 * 1,024 * 1,024.ko1
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43071 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-09-27* gc.c (gc_before_sweep): cast to size_t to suppress warnings.ko1
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43070 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-09-27* gc.c: add some fine-grained profiling codes to tuning marking phase.ko1
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
2013-09-27* gc.c: simplify threshold of GC caused by malloc_increase.ko1
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
2013-09-26* gc.c (vm_xrealloc): use TRY_WITH_GC().nobu
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43049 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-09-26Fix compilation on gcc 4.6naruse
if __has_feature is not defined, it can't compile git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43048 b2dd03c8-39d4-4d8f-98ff-823fe69b080e