From 3bc84990e83d348f5e7b37e3d19204191a724d0c Mon Sep 17 00:00:00 2001 From: khizmax Date: Sun, 25 Dec 2016 16:59:15 +0300 Subject: [PATCH] SkipList: added a statistical measure --- cds/intrusive/details/skip_list_base.h | 3 +++ cds/intrusive/impl/skip_list.h | 3 ++- cds/intrusive/skip_list_rcu.h | 1 + test/include/cds_test/stat_skiplist_out.h | 3 ++- 4 files changed, 8 insertions(+), 2 deletions(-) diff --git a/cds/intrusive/details/skip_list_base.h b/cds/intrusive/details/skip_list_base.h index dbc3a272..97d30e30 100644 --- a/cds/intrusive/details/skip_list_base.h +++ b/cds/intrusive/details/skip_list_base.h @@ -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 }; diff --git a/cds/intrusive/impl/skip_list.h b/cds/intrusive/impl/skip_list.h index db291380..c3b38f0e 100644 --- a/cds/intrusive/impl/skip_list.h +++ b/cds/intrusive/impl/skip_list.h @@ -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(); diff --git a/cds/intrusive/skip_list_rcu.h b/cds/intrusive/skip_list_rcu.h index 52dccdd7..24a12cee 100644 --- a/cds/intrusive/skip_list_rcu.h +++ b/cds/intrusive/skip_list_rcu.h @@ -1720,6 +1720,7 @@ namespace cds { namespace intrusive { } else if ( p.bits() ) { // Another thread is deleting pDel right now + m_Stat.onEraseContention(); return false; } diff --git a/test/include/cds_test/stat_skiplist_out.h b/test/include/cds_test/stat_skiplist_out.h index 69f3894c..d263130a 100644 --- a/test/include/cds_test/stat_skiplist_out.h +++ b/test/include/cds_test/stat_skiplist_out.h @@ -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 -- 2.34.1