summaryrefslogtreecommitdiff
path: root/gc.c
AgeCommit message (Collapse)Author
2013-11-06 * gc.c (gc_before_sweep): Change algorithm of malloc_limit totarui
conservative for closing to memory consumption of ruby 2.0. * gc.c (GC_MALLOC_LIMIT, GC_MALLOC_LIMIT_GROWTH_FACTOR): Adjust parameters for new algorithm. Example: make gcbench-rdoc on a pc time maxrss 2.0.0p343 285.27 281853952 trunk before patch 207.19 690405376 trunk after patch 211.59 312500224 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43558 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-11-06* gc.c: define RGENGC_ESTIMATE_OLDSPACE == 0 if USE_RGENGC is 0.ko1
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43546 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-11-05* gc.c (Init_GC): add GC::OPTS to show options.ko1
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43544 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-11-05 * gc.c (is_live_object): A hidden object may be a live object.tarui
[ruby-dev:47788] [Bug #9072] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43539 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-11-05* remove trailing spaces.nobu
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43534 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-11-05* gc.c: add support to estimate increase of oldspace memory usage.ko1
This is another approach to solve an issue discussed at r43530. This feature is diabled as default. This feature measures an increment of memory consuption by oldgen objects. It measures memory consumption for each objects when the object is promoted. However, measurement of memory consumption is not accurate now. So that this measurement is `estimation'. To implement this feature, move memsize_of() function from ext/objspace/objspace.c and expose rb_obj_memsize_of(). Some memsize() functions for T_DATA (T_TYPEDDATA) have problem to measure memory size, so that we ignores T_DATA objects now. For example, some functions skip NULL check for pointer. The macro RGENGC_ESTIMATE_OLDSPACE enables/disables this feature, and turned off as default. We need to compare 3gen GC and this feature carefully. (it is possible to enable both feature) We need a help to compare them. * internal.h: expose rb_obj_memsize_of(). * ext/objspace/objspace.c: use rb_obj_memsize_of() function. * cont.c (fiber_memsize): fix to check NULL. * variable.c (autoload_memsize): ditto. * vm.c (vm_memsize): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43532 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-11-04* gc.c (GC_MALLOC_LIMIT_MAX): fix default value 512MB -> 384MB.ko1
512MB is huge. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43531 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-11-04* gc.c: add 3gen GC patch, but disabled as default.ko1
RGenGC is designed as 2 generational GC, young and old generation. Young objects will be promoted to old objects after one GC. Old objects are not collect until major (full) GC. The issue of this approach is some objects can promoted as old objects accidentally and not freed until major GC. Major GC is not frequently so short-lived but accidentally becoming old objects are not freed. For example, the program "loop{Array.new(1_000_000)}" consumes huge memories because short lived objects (an array which has 1M elements) are promoted while GC and they are not freed before major GC. To solve this problem, generational GC with more generations technique is known. This patch implements three generations gen GC. At first, newly created objects are "Infant" objects. After surviving one GC, "Infant" objects are promoted to "Young" objects. "Young" objects are promoted to "Old" objects after surviving next GC. "Infant" and "Young" objects are collected if it is not marked while minor GC. So that this technique solves this problem. Representation of generations: * Infant: !FL_PROMOTED and !oldgen_bitmap [00] * Young : FL_PROMOTED and !oldgen_bitmap [10] * Old : FL_PROMOTED and oldgen_bitmap [11] The macro "RGENGC_THREEGEN" enables/disables this feature, and turned off as default because there are several problems. (1) Failed sometimes (Heisenbugs). (2) Performance down. Especially on write barriers. We need to detect Young or Old object by oldgen_bitmap. It is slower than checking flags. To evaluate this feature on more applications, I commit this patch. Reports are very welcome. This patch includes some refactoring (renaming names, etc). * include/ruby/ruby.h: catch up 3gen GC. * .gdbinit: fix to show a prompt "[PROMOTED]" for promoted objects. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43530 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-11-04* include/ruby/ruby.h: rename FL_OLDGEN to FL_PROMOTED.ko1
This flag represents that "this object is promoted at least once." * gc.c, debug.c, object.c: catch up this change. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43527 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-11-03gc.c: use booleannobu
* gc.c (obj_free): use free_immediately as boolean. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43520 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-11-03gc.c: suppress warningnobu
* gc.c (obj_free): suppress a false shorten-64-to-32 warning, RUBY_TYPED_FREE_IMMEDIATELY never exceed the limit of int. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43516 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-11-01gc.c: mark live objects onlynobu
* gc.c (wmap_mark_map): mark live objects only, but delete zombies. [ruby-dev:47787] [Bug #9069] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43509 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-11-01 * gc.c (struct heap_page, gc_page_sweep, gc_sweep): Refactoring fortarui
performance. Add before_sweep condition to heap_page structure. * gc.c (rb_gc_force_recycle): Use before_sweep member. * gc.c (heap_is_before_sweep, is_before_sweep): Remove. They has not already been used. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43508 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-11-01 * gc.c (make_deferred): Refactoring. Collect codes which should betarui
atomic. * gc.c (make_io_deferred, obj_free, rb_objspace_call_finalizer, gc_page_sweep): Correspond to the above. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43506 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-11-01 * gc.c (typedef struct rb_objspace): Refactoring. Move some memberstarui
into profile member. * gc.c (newobj_of): Correspond to the above. * gc.c (finalize_list): Ditto. * gc.c (objspace_live_num): Ditto. * gc.c (gc_page_sweep): Ditto. * gc.c (rb_gc_force_recycle): Ditto. * gc.c (garbage_collect_body): Ditto. * gc.c (rb_gc_count): Ditto. * gc.c (gc_stat): Ditto. * gc.c (gc_prof_set_heap_info): Ditto. * gc.c (gc_profile_dump_on): Ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43505 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-11-01gc.c: zombie is not alivenobu
* gc.c (is_live_object): finalizer may not run because of lazy-sweep. [ruby-dev:47786] [Bug #9069] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43502 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-10-29* add RUBY_TYPED_FREE_IMMEDIATELY to data types which only useko1
safe functions during garbage collection such as xfree(). On default, T_DATA objects are freed at same points as fianlizers. This approach protects issues such as reported by [ruby-dev:35578]. However, freeing T_DATA objects immediately helps heap usage. Most of T_DATA (in other words, most of dfree functions) are safe. However, we turned off RUBY_TYPED_FREE_IMMEDIATELY by default for safety. * cont.c: ditto. * dir.c: ditto. * encoding.c: ditto. * enumerator.c: ditto. * error.c: ditto. * file.c: ditto. * gc.c: ditto. * io.c: ditto. * iseq.c: ditto. * marshal.c: ditto. * parse.y: ditto. * proc.c: ditto. * process.c: ditto. * random.c: ditto. * thread.c: ditto. * time.c: ditto. * transcode.c: ditto. * variable.c: ditto. * vm.c: ditto. * vm_backtrace.c: ditto. * vm_trace.c: ditto. * ext/bigdecimal/bigdecimal.c: ditto. * ext/objspace/objspace.c: ditto. * ext/stringio/stringio.c: ditto. * ext/strscan/strscan.c: ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43466 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-10-29* include/ruby/ruby.h: introduce new flags for T_TYPEDDATA.ko1
* RUBY_TYPED_FREE_IMMEDIATELY: free the data given by DATA_PTR() with dfree function immediately. Otherwise (default), the data freed at finalizaton point. * RUBY_TYPED_WB_PROTECTED: make this object with FL_WB_PROTECT (not shady). * gc.c (obj_free): support RUBY_TYPED_FREE_IMMEDIATELY. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43463 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-10-29* gc.c (vm_malloc_increase): decrease it more carefully.ko1
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43462 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-10-29* gc.c (heap_page_resurrect): return a page in tomb heap even ifko1
freelist is NULL. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43461 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-10-29* gc.c (gc_profile_total_time): fix off-by-one error in GC::Profiler.total_time.tmm1
* test/ruby/test_gc.rb (class TestGc): test for above. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43457 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
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