Граф коммитов

883 Коммитов

Автор SHA1 Сообщение Дата
ktsj ad367a256e * gc.c: catch up recent changes to compile on GC_DEBUG,
RGENGC_CHECK_MODE.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43434 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-10-26 10:42:07 +00:00
ko1 b848aad5bf * gc.c (gc_profile_dump_on): use "Page" terminology.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43428 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-10-26 05:35:43 +00:00
ko1 d03912898e * gc.c (gc_sweep, gc_heap_lazy_sweep): fix measurement code.
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 04:31:10 +00:00
ko1 286d567bbf * gc.c: tuning parameters.
* 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 02:46:30 +00:00
ko1 6c458aec30 * gc.c (vm_malloc_increase): do gc_rest_sweep() before GC.
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-26 02:34:23 +00:00
tarui 59735e2c61 * gc.c (gc_before_heap_sweep): Restructure code to mean clearly.
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 21:37:39 +00:00
ko1 98feb2b9bf * gc.c (gc_before_heap_sweep): fix freelist management.
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-25 19:09:14 +00:00
tmm1 b906f0ed17 * gc.c: add new initial_growth_max tuning parameter. [ruby-core:57928] [Bug #9035]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43409 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-10-23 22:47:29 +00:00
tmm1 dd117ea118 * gc.c: Rename free_min to min_free_slots and free_min_page to 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 15:05:22 +00:00
ko1 602241142f * gc.c: move increment from heap to heap_pages.
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 10:16:01 +00:00
ko1 99c4e43d6a * gc.c (heap_pages_free_unused_pages): cast to (int) for size_t
variable `i'.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43396 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-10-23 08:52:38 +00:00
ko1 69d787ff6d * gc.c: introduce tomb heap.
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 08:48:54 +00:00
ko1 29ffa2c273 * gc.c (gc_prof_sweep_timer_stop): catch up recent changes
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-23 05:22:10 +00:00
ko1 3d85d6edb5 * gc.c (Init_heap): move logics from heap_pages_init() and remove
heap_pages_init().



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43389 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-10-22 10:54:44 +00:00
ko1 d6fe84b6f3 * gc.c: allow multiple heaps.
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 10:28:31 +00:00
ko1 f5b15f0e3f * vm_trace.c: exterminate Zombies.
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-22 06:24:54 +00:00
nobu 6bf78ee633 gc.c: fix arity
* 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 23:50:13 +00:00
ko1 14c08fdb88 * gc.c: fix rb_objspace_t.
* 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 23:33:55 +00:00
nobu ffcf1df1b5 * gc.c (wmap_inspect_i): fix inspect format.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43354 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-10-18 07:06:43 +00:00
nobu 24b97da7ef * gc.c (wmap_inspect_i): fix callback argument.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43353 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-10-18 07:04:42 +00:00
nobu 936b96e9b7 gc.c: ObjectSpace::WeakMap inspection and iteration methods
* 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-18 06:59:14 +00:00
nobu e12799fd31 gc.c: ObjectSpace::WeakMap#key?
* 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 06:59:12 +00:00
ko1 b443d83a77 * gc.c: change terminology of heap.
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-18 06:33:36 +00:00
ko1 ee4da732e3 * gc.c (CALC_EXACT_MALLOC_SIZE_CHECK_OLD_SIZE): introduced.
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 09:51:41 +00:00
ko1 76b06555d0 * gc.c, internal.h: rename ruby_xsizefree/realloc to
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 08:41:23 +00:00
ko1 8ac4f421e1 * gc.c, internal.h: add new internal memory mangement functions.
* 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-17 07:57:03 +00:00
ko1 82d06c5ade * gc.c (objspace_each_objects): do not skip empty RVALUEs.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43313 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-10-16 20:41:49 +00:00
tmm1 2370e623c4 * gc.c (gc_mark_roots): rename roots to be categories instead of function names.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43296 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-10-15 22:33:36 +00:00
nobu 4d94977775 * remove trailing spaces.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43295 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-10-15 13:12:03 +00:00
ko1 f241016825 * gc.h (rb_objspace_reachable_objects_from_root): added.
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-15 10:22:33 +00:00
ko1 52c1331763 * class.c, variable.c, gc.c (rb_class_tbl): removed.
* 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-11 18:27:18 +00:00
ko1 9d70a17541 revert r43259 because it is possible to mark miss classes defined in C-exts. Thanks charliesome.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43261 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-10-11 18:03:43 +00:00
ko1 7aecb95637 * class.c, variable.c, gc.c (rb_class_tbl): removed.
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 17:33:44 +00:00
ko1 432834dd35 * gc.c: use terminology `full_mark' instead of `minor_gc'
in mark functions.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43257 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-10-11 12:00:35 +00:00
ko1 f6fcb9cc94 * gc.c: use __GNUC__ instead of __GCC__.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43256 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-10-11 11:46:42 +00:00
ko1 f44b0e5b4f * gc.c, parse.y: support generational Symbol relatetd marking.
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-11 11:45:38 +00:00
tmm1 8d9e3cd9c6 gc.c: rename heap.free_num to heap.swept_num
* 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-04 10:52:25 +00:00
tmm1 907a03fee5 gc.c: add objspace_free_num and make GC.stat[:heap_free_num] use it
* 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-04 10:05:40 +00:00
tmm1 a24705cfa5 gc.c: add rb_objspace.limit
* 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-04 10:05:37 +00:00
ko1 fa105e6c20 * gc.c: define gc_profile_record::allocated_size if
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-03 09:03:06 +00:00
ko1 8c0033a7b6 * gc.c: relax GC condition due to malloc_limit.
* 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-10-02 09:56:04 +00:00
nobu 6a1a08c945 gc.c: suppress warnings
* 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 08:06:20 +00:00
ko1 1d90d0ced9 * gc.c (rb_gc_disable): do rest_sweep() before disable GC.
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-30 02:20:28 +00:00
ko1 2c0d74b708 * gc.c: add two GC tuning environment variables.
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 09:36:48 +00:00
ko1 a31ff891a1 * gc.c (GC_MALLOC_LIMIT): 8,000,000 -> 8 * 1,024 * 1,024.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43071 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-09-27 08:45:45 +00:00
ko1 78a49728b2 * gc.c (gc_before_sweep): cast to size_t to suppress warnings.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43070 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-09-27 08:20:19 +00:00
ko1 752cc234f6 * gc.c: add some fine-grained profiling codes to tuning marking phase.
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 08:12:31 +00:00
ko1 f365cd2c9a * gc.c: simplify threshold of GC caused by malloc_increase.
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-27 08:01:14 +00:00
nobu 4190cdddbb * gc.c (vm_xrealloc): use TRY_WITH_GC().
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43049 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-09-26 07:22:43 +00:00
naruse 165ebcb467 Fix compilation on gcc 4.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
2013-09-26 06:06:19 +00:00