Author: Tobias Weber <tobias_webe...@gmx.de>
Branch: c8-overheads-instrumentation
Changeset: r2030:8ef2322269a5
Date: 2017-03-13 14:02 +0100
http://bitbucket.org/pypy/stmgc/changeset/8ef2322269a5/

Log:    Instrument all contributors to transaction management overhead in an
        initial coarse grained manner

diff --git a/c8/stm/core.c b/c8/stm/core.c
--- a/c8/stm/core.c
+++ b/c8/stm/core.c
@@ -156,6 +156,8 @@
 
 static bool _stm_validate(void)
 {
+    start_timer();
+
     /* returns true if we reached a valid state, or false if
        we need to abort now */
     dprintf(("_stm_validate() at cl=%p, rev=%lu\n", 
STM_PSEGMENT->last_commit_log_entry,
@@ -338,6 +340,8 @@
         release_privatization_lock(my_segnum);
     }
 
+    stop_timer_and_publish(STM_DURATION_VALIDATION);
+
     return !needs_abort;
 }
 
@@ -817,6 +821,8 @@
 
 static void write_slowpath_common(object_t *obj, bool mark_card)
 {
+    start_timer();
+
     assert(_seems_to_be_running_transaction());
     assert(!_is_in_nursery(obj));
     assert(obj->stm_flags & GCFLAG_WRITE_BARRIER);
@@ -826,6 +832,8 @@
            part again: */
         assert(!(obj->stm_flags & GCFLAG_WB_EXECUTED));
         write_slowpath_overflow_obj(obj, mark_card);
+
+        stop_timer_and_publish(STM_DURATION_WRITE_GC_ONLY);
         return;
     }
 
@@ -893,6 +901,8 @@
     }
 
     DEBUG_EXPECT_SEGFAULT(true);
+
+    stop_timer_and_publish(STM_DURATION_WRITE_SLOWPATH);
 }
 
 
@@ -959,9 +969,7 @@
 
 __attribute__((flatten))
 void _stm_write_slowpath(object_t *obj) {
-    start_timer()
     write_slowpath_common(obj,  /* mark_card */ false);
-    stop_timer_and_publish(STM_DURATION_WRITE_SLOWPATH)
 }
 
 
@@ -1208,6 +1216,8 @@
 
 static void _core_commit_transaction(bool external)
 {
+    start_timer();
+
     exec_local_finalizers();
 
     assert(!_has_mutex());
@@ -1226,11 +1236,17 @@
     assert(STM_SEGMENT->running_thread->wait_event_emitted == 0);
 
     dprintf(("> stm_commit_transaction(external=%d)\n", (int)external));
+
+    pause_timer();
     minor_collection(/*commit=*/ true, external);
+    continue_timer();
+
     if (!external && is_major_collection_requested()) {
         s_mutex_lock();
         if (is_major_collection_requested()) {   /* if still true */
+            pause_timer();
             major_collection_with_mutex();
+            continue_timer();
         }
         s_mutex_unlock();
     }
@@ -1246,7 +1262,10 @@
        stm_validate() at the start of a new transaction is happy even
        if there is an inevitable tx running) */
     bool was_inev = STM_PSEGMENT->transaction_state == TS_INEVITABLE;
+
+    pause_timer();
     _validate_and_add_to_commit_log();
+    continue_timer();
 
     if (external) {
         /* from this point on, unlink the original 'stm_thread_local_t *'
@@ -1295,6 +1314,8 @@
 
     s_mutex_unlock();
 
+    stop_timer_and_publish(STM_DURATION_COMMIT_EXCEPT_GC);
+
     /* between transactions, call finalizers. this will execute
        a transaction itself */
     if (tl != NULL)
diff --git a/c8/stm/gcpage.c b/c8/stm/gcpage.c
--- a/c8/stm/gcpage.c
+++ b/c8/stm/gcpage.c
@@ -750,6 +750,8 @@
     /* first, force a minor collection in each of the other segments */
     major_do_validation_and_minor_collections();
 
+    start_timer();
+
     dprintf((" | used before collection: %ld\n",
              (long)pages_ctl.total_allocated));
     dprintf((" | commit log entries before: %ld\n",
@@ -782,6 +784,8 @@
         if (must_abort())
             abort_with_mutex();
 
+        stop_timer_and_publish(STM_DURATION_MAJOR_GC_LOG_ONLY);
+        
         return;
 #endif
     }
@@ -838,4 +842,6 @@
     dprintf(("must abort?:%d\n", (int)must_abort()));
     if (must_abort())
         abort_with_mutex();
+
+    stop_timer_and_publish(STM_DURATION_MAJOR_GC_FULL);
 }
diff --git a/c8/stm/nursery.c b/c8/stm/nursery.c
--- a/c8/stm/nursery.c
+++ b/c8/stm/nursery.c
@@ -534,6 +534,8 @@
 
 static void _do_minor_collection(bool commit)
 {
+    start_timer();
+
     dprintf(("minor_collection commit=%d\n", (int)commit));
     assert(!STM_SEGMENT->no_safe_point_here);
 
@@ -578,6 +580,8 @@
     throw_away_nursery(get_priv_segment(STM_SEGMENT->segment_num));
 
     assert(MINOR_NOTHING_TO_DO(STM_PSEGMENT));
+
+    stop_timer_and_publish(STM_DURATION_MINOR_GC);
 }
 
 static void minor_collection(bool commit, bool external)
_______________________________________________
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to