diff options
author | ko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2013-05-27 15:40:27 +0000 |
---|---|---|
committer | ko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2013-05-27 15:40:27 +0000 |
commit | e4c58251b736ba362774b24787dff672fd3ee41b (patch) | |
tree | 76b15521dd4ced2bea3af4b5bb552a4d3d3b506e | |
parent | c5b6c189d2933a030e68cc410b4e2deb255bba1a (diff) | |
download | ruby-e4c58251b736ba362774b24787dff672fd3ee41b.tar.gz |
* include/ruby/ruby.h, gc.c: add new internal event
RUBY_INTERNAL_EVENT_GC_END. This event invokes at the end of
after_sweep().
Time chart with lazy sweep is here:
(1) Kick RUBY_INTERNAL_EVENT_GC_START
(2) [gc_marks()]
(3) [lazy_sweep()]
(4) [... run Ruby program (mutator) with lazy_sweep() ...]
(5) [after_sweep()]
(6) Kick RUBY_INTERNAL_EVENT_GC_END
(7) [... run Ruby program (mutator), and go to (1) ...]
* ext/-test-/tracepoint/tracepoint.c,
test/-ext-/tracepoint/test_tracepoint.rb: modify a test.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40963 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r-- | ChangeLog | 17 | ||||
-rw-r--r-- | ext/-test-/tracepoint/tracepoint.c | 11 | ||||
-rw-r--r-- | gc.c | 2 | ||||
-rw-r--r-- | include/ruby/ruby.h | 3 | ||||
-rw-r--r-- | test/-ext-/tracepoint/test_tracepoint.rb | 9 |
5 files changed, 38 insertions, 4 deletions
@@ -1,3 +1,20 @@ +Tue May 28 00:34:23 2013 Koichi Sasada <ko1@atdot.net> + + * include/ruby/ruby.h, gc.c: add new internal event + RUBY_INTERNAL_EVENT_GC_END. This event invokes at the end of + after_sweep(). + Time chart with lazy sweep is here: + (1) Kick RUBY_INTERNAL_EVENT_GC_START + (2) [gc_marks()] + (3) [lazy_sweep()] + (4) [... run Ruby program (mutator) with lazy_sweep() ...] + (5) [after_sweep()] + (6) Kick RUBY_INTERNAL_EVENT_GC_END + (7) [... run Ruby program (mutator), and go to (1) ...] + + * ext/-test-/tracepoint/tracepoint.c, + test/-ext-/tracepoint/test_tracepoint.rb: modify a test. + Tue May 28 00:18:57 2013 Koichi Sasada <ko1@atdot.net> * vm_trace.c (rb_postponed_job_flush): remove a wrong comment. diff --git a/ext/-test-/tracepoint/tracepoint.c b/ext/-test-/tracepoint/tracepoint.c index 8164a633eb..2710f51747 100644 --- a/ext/-test-/tracepoint/tracepoint.c +++ b/ext/-test-/tracepoint/tracepoint.c @@ -4,6 +4,7 @@ static size_t newobj_count; static size_t free_count; static size_t gc_start_count; +static size_t gc_end_count; static size_t objects_count; static VALUE objects[10]; @@ -29,6 +30,11 @@ tracepoint_track_objspace_events_i(VALUE tpval, void *data) gc_start_count++; break; } + case RUBY_INTERNAL_EVENT_GC_END: + { + gc_end_count++; + break; + } default: rb_raise(rb_eRuntimeError, "unknown event"); } @@ -37,7 +43,9 @@ tracepoint_track_objspace_events_i(VALUE tpval, void *data) VALUE tracepoint_track_objspace_events(VALUE self) { - VALUE tpval = rb_tracepoint_new(0, RUBY_INTERNAL_EVENT_NEWOBJ | RUBY_INTERNAL_EVENT_FREEOBJ | RUBY_INTERNAL_EVENT_GC_START, tracepoint_track_objspace_events_i, 0); + VALUE tpval = rb_tracepoint_new(0, RUBY_INTERNAL_EVENT_NEWOBJ | RUBY_INTERNAL_EVENT_FREEOBJ | + RUBY_INTERNAL_EVENT_GC_START | RUBY_INTERNAL_EVENT_GC_END, + tracepoint_track_objspace_events_i, 0); VALUE result = rb_ary_new(); int i; @@ -50,6 +58,7 @@ tracepoint_track_objspace_events(VALUE self) rb_ary_push(result, SIZET2NUM(newobj_count)); rb_ary_push(result, SIZET2NUM(free_count)); rb_ary_push(result, SIZET2NUM(gc_start_count)); + rb_ary_push(result, SIZET2NUM(gc_end_count)); for (i=0; i<objects_count; i++) { rb_ary_push(result, objects[i]); } @@ -2328,6 +2328,8 @@ after_gc_sweep(rb_objspace_t *objspace) } free_unused_heaps(objspace); + + gc_event_hook(objspace, RUBY_INTERNAL_EVENT_GC_END, 0 /* TODO: pass minor/immediate flag? */); } static int diff --git a/include/ruby/ruby.h b/include/ruby/ruby.h index d632f57226..d13325f7c9 100644 --- a/include/ruby/ruby.h +++ b/include/ruby/ruby.h @@ -1731,7 +1731,8 @@ int ruby_native_thread_p(void); #define RUBY_INTERNAL_EVENT_NEWOBJ 0x100000 #define RUBY_INTERNAL_EVENT_FREEOBJ 0x200000 #define RUBY_INTERNAL_EVENT_GC_START 0x400000 -#define RUBY_INTERNAL_EVENT_OBJSPACE_MASK 0x700000 +#define RUBY_INTERNAL_EVENT_GC_END 0x800000 +#define RUBY_INTERNAL_EVENT_OBJSPACE_MASK 0xf00000 #define RUBY_INTERNAL_EVENT_MASK 0xfffe0000 typedef unsigned long rb_event_flag_t; diff --git a/test/-ext-/tracepoint/test_tracepoint.rb b/test/-ext-/tracepoint/test_tracepoint.rb index 058809471f..efbf40b460 100644 --- a/test/-ext-/tracepoint/test_tracepoint.rb +++ b/test/-ext-/tracepoint/test_tracepoint.rb @@ -17,7 +17,7 @@ class TestTracepointObj < Test::Unit::TestCase nil } - newobj_count, free_count, gc_start_count, *newobjs = *result + newobj_count, free_count, gc_start_count, gc_end_count, *newobjs = *result assert_equal 2, newobj_count assert_equal 2, newobjs.size assert_equal 'foobar', newobjs[0] @@ -31,10 +31,15 @@ class TestTracepointObj < Test::Unit::TestCase } GC.stat(stat2) - newobj_count, free_count, gc_start_count, *newobjs = *result + newobj_count, free_count, gc_start_count, gc_end_count, *newobjs = *result assert_operator stat2[:total_allocated_object] - stat1[:total_allocated_object], :>=, newobj_count + assert_operator 1_000_000, :<=, newobj_count + assert_operator stat2[:total_freed_object] - stat1[:total_freed_object], :>=, free_count assert_operator stat2[:count] - stat1[:count], :==, gc_start_count + + assert_operator gc_start_count, :>=, gc_end_count + assert_operator stat2[:count] - stat1[:count] - 1, :<=, gc_end_count end end |