aboutsummaryrefslogtreecommitdiffstats
path: root/gc.c
Commit message (Collapse)AuthorAgeFilesLines
* * gc.c: catch up recent changes to compile on GC_DEBUG,ktsj2013-10-261-7/+7
| | | | | | RGENGC_CHECK_MODE. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43434 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * gc.c (gc_profile_dump_on): use "Page" terminology.ko12013-10-261-1/+1
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43428 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * gc.c (gc_sweep, gc_heap_lazy_sweep): fix measurement code.ko12013-10-261-2/+8
| | | | | | | | 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: tuning parameters.ko12013-10-261-3/+3
| | | | | | | | | | | * 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.c (vm_malloc_increase): do gc_rest_sweep() before GC.ko12013-10-261-1/+11
| | | | | | | | | | | 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
* * gc.c (gc_before_heap_sweep): Restructure code to mean clearly.tarui2013-10-251-11/+4
| | | | | | | 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
* * gc.c (gc_before_heap_sweep): fix freelist management.ko12013-10-251-1/+12
| | | | | | | | | 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
* * gc.c: add new initial_growth_max tuning parameter. [ruby-core:57928] [Bug ↵tmm12013-10-231-0/+11
| | | | | | #9035] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43409 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * gc.c: Rename free_min to min_free_slots and free_min_page to ↵tmm12013-10-231-24/+24
| | | | | | | | | 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
* * gc.c: move increment from heap to heap_pages.ko12013-10-231-34/+39
| | | | | | | | | | | 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
* * gc.c (heap_pages_free_unused_pages): cast to (int) for size_tko12013-10-231-1/+1
| | | | | | | | variable `i'. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43396 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * gc.c: introduce tomb heap.ko12013-10-231-129/+192
| | | | | | | | | | | | | | | | | | | 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
* * gc.c (gc_prof_sweep_timer_stop): catch up recent changesko12013-10-231-1/+1
| | | | | | | | 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
* * gc.c (Init_heap): move logics from heap_pages_init() and removeko12013-10-221-22/+18
| | | | | | | | heap_pages_init(). git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43389 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * gc.c: allow multiple heaps.ko12013-10-221-280/+335
| | | | | | | | | | | | | | | | | | | | 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
* * vm_trace.c: exterminate Zombies.ko12013-10-221-1/+3
| | | | | | | | | | | | | | | | | | | | | | | 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
* gc.c: fix aritynobu2013-10-181-1/+1
| | | | | | | * 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
* * gc.c: fix rb_objspace_t.ko12013-10-181-48/+53
| | | | | | | | | | | | | | | * 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
* * gc.c (wmap_inspect_i): fix inspect format.nobu2013-10-181-1/+4
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43354 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * gc.c (wmap_inspect_i): fix callback argument.nobu2013-10-181-2/+2
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43353 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* gc.c: ObjectSpace::WeakMap inspection and iteration methodsnobu2013-10-181-0/+167
| | | | | | | | * 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
* gc.c: ObjectSpace::WeakMap#key?nobu2013-10-181-0/+10
| | | | | | | | * 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
* * gc.c: change terminology of heap.ko12013-10-181-221/+221
| | | | | | | | | | | | | | 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
* * gc.c (CALC_EXACT_MALLOC_SIZE_CHECK_OLD_SIZE): introduced.ko12013-10-171-7/+18
| | | | | | | | | 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
* * gc.c, internal.h: rename ruby_xsizefree/realloc toko12013-10-171-4/+4
| | | | | | | | | | 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
* * gc.c, internal.h: add new internal memory mangement functions.ko12013-10-171-23/+50
| | | | | | | | | | | | * 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
* * gc.c (objspace_each_objects): do not skip empty RVALUEs.ko12013-10-161-18/+5
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43313 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * gc.c (gc_mark_roots): rename roots to be categories instead of function names.tmm12013-10-151-11/+11
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43296 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * remove trailing spaces.nobu2013-10-151-1/+1
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43295 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * gc.h (rb_objspace_reachable_objects_from_root): added.ko12013-10-151-47/+106
| | | | | | | | | | 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
* * class.c, variable.c, gc.c (rb_class_tbl): removed.ko12013-10-111-5/+1
| | | | | | | | | | | | | | | * 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
* revert r43259 because it is possible to mark miss classes defined in C-exts. ↵ko12013-10-111-7/+6
| | | | | | Thanks charliesome. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43261 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * class.c, variable.c, gc.c (rb_class_tbl): removed.ko12013-10-111-5/+6
| | | | | | | | rb_class_tbl is no longer used. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43259 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * gc.c: use terminology `full_mark' instead of `minor_gc'ko12013-10-111-19/+22
| | | | | | | | in mark functions. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43257 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * gc.c: use __GNUC__ instead of __GCC__.ko12013-10-111-1/+1
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43256 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * gc.c, parse.y: support generational Symbol relatetd marking.ko12013-10-111-1/+1
| | | | | | | | | | | | | | | | | 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 to heap.swept_numtmm12013-10-041-9/+9
| | | | | | | * 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: add objspace_free_num and make GC.stat[:heap_free_num] use ittmm12013-10-041-1/+7
| | | | | | | | | * 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.limittmm12013-10-041-2/+7
| | | | | | | * 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: define gc_profile_record::allocated_size ifko12013-10-031-3/+4
| | | | | | | | CALC_EXACT_MALLOC_SIZE is true. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43130 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * gc.c: relax GC condition due to malloc_limit.ko12013-10-021-9/+17
| | | | | | | | | | | * 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
* gc.c: suppress warningsnobu2013-09-301-1/+1
| | | | | | * 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
* * gc.c (rb_gc_disable): do rest_sweep() before disable GC.ko12013-09-301-0/+2
| | | | | | | | | | 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
* * gc.c: add two GC tuning environment variables.ko12013-09-271-56/+62
| | | | | | | | | | | | | 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
* * gc.c (GC_MALLOC_LIMIT): 8,000,000 -> 8 * 1,024 * 1,024.ko12013-09-271-1/+1
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43071 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * gc.c (gc_before_sweep): cast to size_t to suppress warnings.ko12013-09-271-2/+2
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43070 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * gc.c: add some fine-grained profiling codes to tuning marking phase.ko12013-09-271-7/+94
| | | | | | | | | | 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
* * gc.c: simplify threshold of GC caused by malloc_increase.ko12013-09-271-39/+73
| | | | | | | | | | | | | | | | | | | | | | | | 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
* * gc.c (vm_xrealloc): use TRY_WITH_GC().nobu2013-09-261-9/+1
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43049 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Fix compilation on gcc 4.6naruse2013-09-261-2/+6
| | | | | | 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