SkipList: added a statistical measure
authorkhizmax <libcds.dev@gmail.com>
Sun, 25 Dec 2016 13:59:15 +0000 (16:59 +0300)
committerkhizmax <libcds.dev@gmail.com>
Sun, 25 Dec 2016 13:59:15 +0000 (16:59 +0300)
cds/intrusive/details/skip_list_base.h
cds/intrusive/impl/skip_list.h
cds/intrusive/skip_list_rcu.h
test/include/cds_test/stat_skiplist_out.h

index dbc3a27..97d30e3 100644 (file)
@@ -423,6 +423,7 @@ namespace cds { namespace intrusive {
             event_counter   m_nEraseWhileFind       ; ///< Count of erased item while searching
             event_counter   m_nExtractWhileFind     ; ///< Count of extracted item while searching (RCU only)
             event_counter   m_nMarkFailed           ; ///< Count of failed node marking (logical deletion mark)
+            event_counter   m_nEraseContention      ; ///< Count of key erasing contention encountered
 
             //@cond
             void onAddNode( unsigned int nHeight )
@@ -472,6 +473,7 @@ namespace cds { namespace intrusive {
             void onExtractMaxFailed()       { ++m_nExtractMaxFailed;  }
             void onExtractMaxRetry()        { ++m_nExtractMaxRetries; }
             void onMarkFailed()             { ++m_nMarkFailed;        }
+            void onEraseContention()        { ++m_nEraseContention;   }
             //@endcond
         };
 
@@ -516,6 +518,7 @@ namespace cds { namespace intrusive {
             void onExtractMaxFailed()       const {}
             void onExtractMaxRetry()        const {}
             void onMarkFailed()             const {}
+            void onEraseContention()        const {}
             //@endcond
         };
 
index db29138..c3b38f0 100644 (file)
@@ -1453,8 +1453,9 @@ namespace cds { namespace intrusive {
                     m_Stat.onFastErase();
                     return true;
                 }
-                else if ( p.bits() ) {
+                else if ( p.bits()) {
                     // Another thread is deleting pDel right now
+                    m_Stat.onEraseContention();
                     return false;
                 }
                 m_Stat.onEraseRetry();
index 52dccdd..24a12ce 100644 (file)
@@ -1720,6 +1720,7 @@ namespace cds { namespace intrusive {
                 }
                 else if ( p.bits() ) {
                     // Another thread is deleting pDel right now
+                    m_Stat.onEraseContention();
                     return false;
                 }
 
index 69f3894..d263130 100644 (file)
@@ -85,7 +85,8 @@ namespace cds_test {
             << CDSSTRESS_STAT_OUT( s, m_nSlowExtract )
             << CDSSTRESS_STAT_OUT( s, m_nEraseWhileFind )
             << CDSSTRESS_STAT_OUT( s, m_nExtractWhileFind )
-            << CDSSTRESS_STAT_OUT( s, m_nMarkFailed );
+            << CDSSTRESS_STAT_OUT( s, m_nMarkFailed )
+            << CDSSTRESS_STAT_OUT( s, m_nEraseContention );
     }
 
 } // namespace cds_test