summaryrefslogtreecommitdiff
path: root/gc.c
AgeCommit message (Collapse)Author
2013-11-21* remove trailing spaces.nobu
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43756 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-11-21* gc.c: enable "RGENGC_ESTIMATE_OLDSPACE" option as default.ko1
Without this option, some application consumes huge memory. (and there are only a few performance down) Introduced new environment variables: * RUBY_GC_HEAP_OLDSPACE (default 16MB) * RUBY_GC_HEAP_OLDSPACE_MAX (default 128 MB) * RUBY_GC_HEAP_OLDSPACE_GROWTH_FACTOR (default 1.2) * gc.c (initial_malloc_limit): rename to initial_malloc_limit_min. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43755 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-11-21* gc.c (gc_marks_check): do not dump all refs.ko1
* gc.c (allrefs_dump_i): fix output format. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43746 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-11-21* remove trailing spaces.nobu
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43745 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-11-21* gc.c: change RGENGC_CHECK_MODE (>= 2) logic.ko1
Basically, make an object graph of all of living objects before and after marking and check status. [Before marking: check WB sanity] If there is a non-old object `obj' pointed from old object (`parent') then `parent' or `obj' should be remembered. [After marking: check marking miss] Traversible objects with the object graph should be marked. (However, this alert about objects pointed by machine context can be false positive. We only display alert.) [Implementation memo] objspace_allrefs() creates an object graph. The object graph is represented by st_table, key is object (VALUE) and value is referring objects. Referring objects are stored by "struct reflist". * gc.c (init_mark_stack): do not use push_mark_stack_chunk() at init. This pre-allocation causes failure on is_mark_stask_empty() without any pushing. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43744 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-11-19* gc.c (heap_is_swept_object): use heap_page::before_sweep flag.ko1
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43720 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-11-19* gc.c (rb_objspace_reachable_objects_from_root): do major marking.ko1
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43719 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-11-19* gc.c (rb_gc_resurrect): added.ko1
rb_fstring() used rb_gc_mark() to avoid freeing used string. However, rb_gc_mark() set mark bit *and* pushes mark_stack. rb_gc_resurrect() does only set mark bit if it is before sweeping. * string.c (rb_fstring): use rb_gc_resurrect. * internal.h: add decl. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43718 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-11-10* gc.c (rb_gcdebug_print_obj_condition): catch up recent changesktsj
to compile on GC_DEBUG. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43637 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-11-09gc.c: finalizer functionsnobu
* gc.c (rb_define_finalizer, rb_undefine_finalizer): rename and export finalizer functions. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43631 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-11-09* gc.c (vm_malloc_increase): sweep immediately on GC due to malloc().ko1
To reduce memory usage, sweep as soon as possible. This behavior is same as Ruby 2.0.0 and before. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43623 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-11-09gc.c: private callnobu
* gc.c (should_be_callable): allow private call since rb_eval_cmd calls even private methods. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43621 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-11-09gc.c: should_be_callablenobu
* gc.c (should_be_callable): extract duplicate code. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43620 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-11-09 * gc.c (gc_page_sweep, rgengc_rememberset_mark): Refactoring.tarui
Get bitmaps directly. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43594 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-11-09 * gc.c (RVALUE_PROMOTE_INFANT): Refactoring. Remove duplicated nonsensetarui
code. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43593 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-11-09 * gc.c (gc_marks_test): Bugfix. Fix a struct member name for buildtarui
with RGENGC_CHECK_MODE. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43592 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-11-08 * gc.c : Add GC_PROFILE_DETAIL_MEMORY option.tarui
If GC_PROFILE_MORE_DETAIL && GC_PROFILE_DETAIL_MEMORY, maxrss, minflt and majflt are added to each profile record. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43591 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-11-07gc.c: use switch for alternative BUILTIN_TYPEnobu
* gc.c (rb_objspace_call_finalizer): BUILTIN_TYPE is alternative, T_DATA object (Thread, Mutex, Fiber) cannot be T_FILE. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43576 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-11-07* gc.c (vm_malloc_increase): check GVL before gc_rest_sweep().ko1
vm_malloc_increase() can be called without GVL. However, gc_rest_sweep() assumes acquiring GVL. To avoid this problem, check GVL before gc_rest_sweep(). [Bug #9090] This workaround introduces possibility to set malloc_limit as wrong value (*1). However, this may be rare case. So I commit it. *1: Without rest_sweep() here, gc_rest_sweep() can decrease malloc_increase due to ruby_sized_xfree(). git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43574 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-11-07* gc.c: modify malloc_limit strategy.ko1
* fix default vaues: GC_MALLOC_LIMIT_GROWTH_FACTOR GC_MALLOC_LIMIT: 8MB -> 16MB GC_MALLOC_LIMIT_MAX: 384MB -> 32MB * algorithm of malloc_limit increment. if (malloc_increase < malloc_limit) { next_malloc_limit = malloc_limit * factor if (malloc_limit > malloc_limit_max) { malloc_limit = malloc_increase } } This algorithm change malloc_limit from 16MB -> 32MB slowly. If malloc_limit exceeds malloc_limit_max, then increase with malloc_increase. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43565 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
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