ruby-changes:35446
From: ko1 <ko1@a...>
Date: Thu, 11 Sep 2014 17:47:11 +0900 (JST)
Subject: [ruby-changes:35446] ko1:r47528 (trunk): * include/ruby/ruby.h, gc.c: add new internal events
ko1 2014-09-11 17:46:59 +0900 (Thu, 11 Sep 2014) New Revision: 47528 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=47528 Log: * include/ruby/ruby.h, gc.c: add new internal events RUBY_INTERNAL_EVENT_GC_ENTER and RUBY_INTERNAL_EVENT_GC_EXIT. When invoking GC process, GC_ENTER event is called. When exiting from GC process, GC_EXIT event is called. Incremental GC (incremental marking and lazy sweep) can call these events many times. For example (minor marking): (1) GC_ENTER - (2) GC_START (minor GC) (minor marking) - (3) GC_END_MARK (start lazy sweep) (4) GC_EXIT (ruby process) (5) GC_ENTER (lazy sweep) (6) GC_EXIT (ruby process) (... repeat (5), (6)) (7) GC_ENTER (finish lazy sweep) - (8) GC_END_SWEEP (9) GC_EXIT 2nd example (incremental major marking): (1) GC_ENTER - (2) GC_START (minor GC) (start incremental marking) (3) GC_EXIT (ruby process) (4) GC_ENTER (incremental marking) (5) GC_EXIT (ruby process) (... repeat (4), (5)) (6) GC_ENTER (finish incremental marking) - (7) GC_END_MARK (start lazy sweep) (8) GC_EXIT (ruby process) (9) GC_ENTER (lazy sweep) (10) GC_EXIT (ruby process) (... repeat (9), (10)) (11) GC_ENTER (finish lazy marking) - (12) GC_STOP_SWEEP (13) GC_EXIT Thease internal events enable to measure GC pause time completely. Modified files: trunk/ChangeLog trunk/gc.c trunk/include/ruby/ruby.h Index: include/ruby/ruby.h =================================================================== --- include/ruby/ruby.h (revision 47527) +++ include/ruby/ruby.h (revision 47528) @@ -1683,7 +1683,9 @@ int ruby_native_thread_p(void); https://github.com/ruby/ruby/blob/trunk/include/ruby/ruby.h#L1683 #define RUBY_INTERNAL_EVENT_GC_START 0x400000 #define RUBY_INTERNAL_EVENT_GC_END_MARK 0x800000 #define RUBY_INTERNAL_EVENT_GC_END_SWEEP 0x1000000 -#define RUBY_INTERNAL_EVENT_OBJSPACE_MASK 0x1f00000 +#define RUBY_INTERNAL_EVENT_GC_ENTER 0x2000000 +#define RUBY_INTERNAL_EVENT_GC_EXIT 0x4000000 +#define RUBY_INTERNAL_EVENT_OBJSPACE_MASK 0x7f00000 #define RUBY_INTERNAL_EVENT_MASK 0xfffe0000 typedef unsigned long rb_event_flag_t; Index: ChangeLog =================================================================== --- ChangeLog (revision 47527) +++ ChangeLog (revision 47528) @@ -1,3 +1,62 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1 +Thu Sep 11 17:25:31 2014 Koichi Sasada <ko1@a...> + + * include/ruby/ruby.h, gc.c: add new internal events + RUBY_INTERNAL_EVENT_GC_ENTER and + RUBY_INTERNAL_EVENT_GC_EXIT. + + When invoking GC process, GC_ENTER event is called. + When exiting from GC process, GC_EXIT event is called. + + Incremental GC (incremental marking and lazy sweep) can call + these events many times. + + For example (minor marking): + (1) GC_ENTER + - (2) GC_START (minor GC) + (minor marking) + - (3) GC_END_MARK + (start lazy sweep) + (4) GC_EXIT + (ruby process) + (5) GC_ENTER + (lazy sweep) + (6) GC_EXIT + (ruby process) + (... repeat (5), (6)) + (7) GC_ENTER + (finish lazy sweep) + - (8) GC_END_SWEEP + (9) GC_EXIT + + 2nd example (incremental major marking): + (1) GC_ENTER + - (2) GC_START (minor GC) + (start incremental marking) + (3) GC_EXIT + (ruby process) + (4) GC_ENTER + (incremental marking) + (5) GC_EXIT + (ruby process) + (... repeat (4), (5)) + (6) GC_ENTER + (finish incremental marking) + - (7) GC_END_MARK + (start lazy sweep) + (8) GC_EXIT + (ruby process) + (9) GC_ENTER + (lazy sweep) + (10) GC_EXIT + (ruby process) + (... repeat (9), (10)) + (11) GC_ENTER + (finish lazy marking) + - (12) GC_STOP_SWEEP + (13) GC_EXIT + + Thease internal events enable to measure GC pause time completely. + Thu Sep 11 17:04:54 2014 Eric Wong <e@8...> * lib/benchmark.rb: remove CLOCK_MONOTONIC_RAW support Index: gc.c =================================================================== --- gc.c (revision 47527) +++ gc.c (revision 47528) @@ -5966,6 +5966,7 @@ gc_enter(rb_objspace_t *objspace, const https://github.com/ruby/ruby/blob/trunk/gc.c#L5966 during_gc = TRUE; gc_report(1, objspace, "gc_entr: %s [%s]\n", event, gc_current_status(objspace)); gc_record(objspace, 0, event); + gc_event_hook(objspace, RUBY_INTERNAL_EVENT_GC_ENTER, 0); /* TODO: which parameter should be passed? */ } static inline void @@ -5973,6 +5974,7 @@ gc_exit(rb_objspace_t *objspace, const c https://github.com/ruby/ruby/blob/trunk/gc.c#L5974 { if (RGENGC_CHECK_MODE) assert(during_gc != 0); + gc_event_hook(objspace, RUBY_INTERNAL_EVENT_GC_EXIT, 0); /* TODO: which parameter should be passsed? */ gc_record(objspace, 1, event); gc_report(1, objspace, "gc_exit: %s [%s]\n", event, gc_current_status(objspace)); during_gc = FALSE; -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/