[前][次][番号順一覧][スレッド一覧]

ruby-changes:64195

From: Koichi <ko1@a...>
Date: Wed, 16 Dec 2020 10:38:26 +0900 (JST)
Subject: [ruby-changes:64195] 0b678cc9e5 (master): add vm_sync debug counters

https://git.ruby-lang.org/ruby.git/commit/?id=0b678cc9e5

From 0b678cc9e5a5149e40765562142ed1dc05d09b53 Mon Sep 17 00:00:00 2001
From: Koichi Sasada <ko1@a...>
Date: Wed, 16 Dec 2020 10:10:05 +0900
Subject: add vm_sync debug counters

* vm_sync_lock
* vm_sync_lock_enter
* vm_sync_lock_enter_nb
* vm_sync_lock_enter_cr
* vm_sync_barrier

diff --git a/common.mk b/common.mk
index 220089c..1dd2667 100644
--- a/common.mk
+++ b/common.mk
@@ -4464,6 +4464,7 @@ encoding.$(OBJEXT): {$(VPATH)}backward/2/long_long.h https://github.com/ruby/ruby/blob/trunk/common.mk#L4464
 encoding.$(OBJEXT): {$(VPATH)}backward/2/stdalign.h
 encoding.$(OBJEXT): {$(VPATH)}backward/2/stdarg.h
 encoding.$(OBJEXT): {$(VPATH)}config.h
+encoding.$(OBJEXT): {$(VPATH)}debug_counter.h
 encoding.$(OBJEXT): {$(VPATH)}defines.h
 encoding.$(OBJEXT): {$(VPATH)}encindex.h
 encoding.$(OBJEXT): {$(VPATH)}encoding.c
@@ -4639,6 +4640,7 @@ enum.$(OBJEXT): $(top_srcdir)/internal/numeric.h https://github.com/ruby/ruby/blob/trunk/common.mk#L4640
 enum.$(OBJEXT): $(top_srcdir)/internal/object.h
 enum.$(OBJEXT): $(top_srcdir)/internal/proc.h
 enum.$(OBJEXT): $(top_srcdir)/internal/rational.h
+enum.$(OBJEXT): $(top_srcdir)/internal/re.h
 enum.$(OBJEXT): $(top_srcdir)/internal/serial.h
 enum.$(OBJEXT): $(top_srcdir)/internal/static_assert.h
 enum.$(OBJEXT): $(top_srcdir)/internal/vm.h
@@ -13824,6 +13826,7 @@ symbol.$(OBJEXT): {$(VPATH)}backward/2/long_long.h https://github.com/ruby/ruby/blob/trunk/common.mk#L13826
 symbol.$(OBJEXT): {$(VPATH)}backward/2/stdalign.h
 symbol.$(OBJEXT): {$(VPATH)}backward/2/stdarg.h
 symbol.$(OBJEXT): {$(VPATH)}config.h
+symbol.$(OBJEXT): {$(VPATH)}debug_counter.h
 symbol.$(OBJEXT): {$(VPATH)}defines.h
 symbol.$(OBJEXT): {$(VPATH)}encoding.h
 symbol.$(OBJEXT): {$(VPATH)}gc.h
@@ -15953,6 +15956,7 @@ vm_sync.$(OBJEXT): {$(VPATH)}backward/2/stdalign.h https://github.com/ruby/ruby/blob/trunk/common.mk#L15956
 vm_sync.$(OBJEXT): {$(VPATH)}backward/2/stdarg.h
 vm_sync.$(OBJEXT): {$(VPATH)}config.h
 vm_sync.$(OBJEXT): {$(VPATH)}constant.h
+vm_sync.$(OBJEXT): {$(VPATH)}debug_counter.h
 vm_sync.$(OBJEXT): {$(VPATH)}defines.h
 vm_sync.$(OBJEXT): {$(VPATH)}gc.h
 vm_sync.$(OBJEXT): {$(VPATH)}id.h
diff --git a/debug_counter.h b/debug_counter.h
index 0e13464..593d2f7 100644
--- a/debug_counter.h
+++ b/debug_counter.h
@@ -322,6 +322,13 @@ RB_DEBUG_COUNTER(theap_alloc) https://github.com/ruby/ruby/blob/trunk/debug_counter.h#L322
 RB_DEBUG_COUNTER(theap_alloc_fail)
 RB_DEBUG_COUNTER(theap_evacuate)
 
+// VM sync
+RB_DEBUG_COUNTER(vm_sync_lock)
+RB_DEBUG_COUNTER(vm_sync_lock_enter)
+RB_DEBUG_COUNTER(vm_sync_lock_enter_nb)
+RB_DEBUG_COUNTER(vm_sync_lock_enter_cr)
+RB_DEBUG_COUNTER(vm_sync_barrier)
+
 /* mjit_exec() counts */
 RB_DEBUG_COUNTER(mjit_exec)
 RB_DEBUG_COUNTER(mjit_exec_not_added)
diff --git a/vm_sync.c b/vm_sync.c
index 22c2299..d2ce727 100644
--- a/vm_sync.c
+++ b/vm_sync.c
@@ -228,6 +228,8 @@ vm_barrier_finish_p(rb_vm_t *vm) https://github.com/ruby/ruby/blob/trunk/vm_sync.c#L228
 void
 rb_vm_barrier(void)
 {
+    RB_DEBUG_COUNTER_INC(vm_sync_barrier);
+
     if (!rb_multi_ractor_p()) {
         // no other ractors
         return;
diff --git a/vm_sync.h b/vm_sync.h
index 8712e1a..b8ebb3b 100644
--- a/vm_sync.h
+++ b/vm_sync.h
@@ -3,6 +3,7 @@ https://github.com/ruby/ruby/blob/trunk/vm_sync.h#L3
 #define RUBY_VM_SYNC_H
 
 #include "vm_debug.h"
+#include "debug_counter.h"
 
 #if USE_RUBY_DEBUG_LOG
 #define LOCATION_ARGS const char *file, int line
@@ -51,6 +52,8 @@ rb_multi_ractor_p(void) https://github.com/ruby/ruby/blob/trunk/vm_sync.h#L52
 static inline void
 rb_vm_lock(const char *file, int line)
 {
+    RB_DEBUG_COUNTER_INC(vm_sync_lock);
+
     if (rb_multi_ractor_p()) {
         rb_vm_lock_body(LOCATION_PARAMS);
     }
@@ -67,6 +70,8 @@ rb_vm_unlock(const char *file, int line) https://github.com/ruby/ruby/blob/trunk/vm_sync.h#L70
 static inline void
 rb_vm_lock_enter(unsigned int *lev, const char *file, int line)
 {
+    RB_DEBUG_COUNTER_INC(vm_sync_lock_enter);
+
     if (rb_multi_ractor_p()) {
         rb_vm_lock_enter_body(lev APPEND_LOCATION_PARAMS);
     }
@@ -75,6 +80,8 @@ rb_vm_lock_enter(unsigned int *lev, const char *file, int line) https://github.com/ruby/ruby/blob/trunk/vm_sync.h#L80
 static inline void
 rb_vm_lock_enter_nb(unsigned int *lev, const char *file, int line)
 {
+    RB_DEBUG_COUNTER_INC(vm_sync_lock_enter_nb);
+
     if (rb_multi_ractor_p()) {
         rb_vm_lock_enter_body_nb(lev APPEND_LOCATION_PARAMS);
     }
@@ -91,6 +98,7 @@ rb_vm_lock_leave(unsigned int *lev, const char *file, int line) https://github.com/ruby/ruby/blob/trunk/vm_sync.h#L98
 static inline void
 rb_vm_lock_enter_cr(struct rb_ractor_struct *cr, unsigned int *levp, const char *file, int line)
 {
+    RB_DEBUG_COUNTER_INC(vm_sync_lock_enter_cr);
     rb_vm_lock_enter_body_cr(cr, levp APPEND_LOCATION_PARAMS);
 }
 
-- 
cgit v0.10.2


--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]