|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r56751 - in sandbox/stm/branches/vbe: boost/stm boost/stm/contention_managers boost/stm/detail libs/stm/src
From: vicente.botet_at_[hidden]
Date: 2009-10-12 15:42:07
Author: viboes
Date: 2009-10-12 15:42:06 EDT (Mon, 12 Oct 2009)
New Revision: 56751
URL: http://svn.boost.org/trac/boost/changeset/56751
Log:
TBoost.Stm vbe
* Added new interface for contention manager to check a list of transactions with conflicts against a committing one
Text files modified:
sandbox/stm/branches/vbe/boost/stm/base_contention_manager.hpp | 5 ++
sandbox/stm/branches/vbe/boost/stm/contention_managers/except_and_back_off_on_abort_notice_cm.hpp | 1
sandbox/stm/branches/vbe/boost/stm/detail/transaction_impl.hpp | 36 ++++++++---------
sandbox/stm/branches/vbe/boost/stm/transaction.hpp | 7 ++
sandbox/stm/branches/vbe/libs/stm/src/except_and_back_off_on_abort_notice_cm.cpp | 82 ++++++++++++++++++++++++++++++++++++++++
5 files changed, 111 insertions(+), 20 deletions(-)
Modified: sandbox/stm/branches/vbe/boost/stm/base_contention_manager.hpp
==============================================================================
--- sandbox/stm/branches/vbe/boost/stm/base_contention_manager.hpp (original)
+++ sandbox/stm/branches/vbe/boost/stm/base_contention_manager.hpp 2009-10-12 15:42:06 EDT (Mon, 12 Oct 2009)
@@ -16,6 +16,7 @@
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
+#include <list>
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
#include <boost/stm/detail/config.hpp>
@@ -50,6 +51,10 @@
virtual bool permission_to_abort
(transaction const &lhs, transaction const &rhs) = 0;
+ virtual bool permission_to_abort
+ (transaction const &lhs, std::list<transaction*> &rhs)
+ { return true; }
+
virtual bool allow_lock_to_abort_tx(int const & lockWaitTime, int const &lockAborted,
bool txIsIrrevocable, transaction const &rhs) = 0;
Modified: sandbox/stm/branches/vbe/boost/stm/contention_managers/except_and_back_off_on_abort_notice_cm.hpp
==============================================================================
--- sandbox/stm/branches/vbe/boost/stm/contention_managers/except_and_back_off_on_abort_notice_cm.hpp (original)
+++ sandbox/stm/branches/vbe/boost/stm/contention_managers/except_and_back_off_on_abort_notice_cm.hpp 2009-10-12 15:42:06 EDT (Mon, 12 Oct 2009)
@@ -61,6 +61,7 @@
static bool abort_before_commit(transaction const &t);
static bool permission_to_abort(transaction const &lhs, transaction const &rhs);
+ static bool permission_to_abort(transaction const &lhs, std::list<transaction*> &rhs);
static bool allow_lock_to_abort_tx(int const & lockWaitTime, int const &lockAborted,
bool txTryingToAbortIsIrrevocable, transaction const &rhs);
Modified: sandbox/stm/branches/vbe/boost/stm/detail/transaction_impl.hpp
==============================================================================
--- sandbox/stm/branches/vbe/boost/stm/detail/transaction_impl.hpp (original)
+++ sandbox/stm/branches/vbe/boost/stm/detail/transaction_impl.hpp 2009-10-12 15:42:06 EDT (Mon, 12 Oct 2009)
@@ -2130,13 +2130,7 @@
("aborting committing transaction due to contention manager priority inversion");
}
#else
- if (cm_permission_to_abort(*this, *t)) aborted.push_front(t);
- else
- {
- force_to_abort();
- throw aborted_transaction_exception
- ("aborting committing transaction due to contention manager priority inversion");
- }
+ aborted.push_front(t);
#endif
}
}
@@ -2166,13 +2160,7 @@
("aborting committing transaction due to contention manager priority inversion");
}
#else
- if (cm_permission_to_abort(*this, *t)) aborted.push_front(t);
- else
- {
- force_to_abort();
- throw aborted_transaction_exception
- ("aborting committing transaction due to contention manager priority inversion");
- }
+ aborted.push_front(t);
#endif
}
#endif
@@ -2180,13 +2168,23 @@
if (!aborted.empty())
{
- // ok, forced to aborts are allowed, do them
- for (std::list<transaction*>::iterator k = aborted.begin(); k != aborted.end(); ++k)
+ if (cm_permission_to_abort(*this, aborted))
{
- (*k)->force_to_abort();
- }
+ // ok, forced to aborts are allowed, do them
+ for (std::list<transaction*>::iterator k = aborted.begin();
+ k != aborted.end(); ++k)
+ {
+ (*k)->force_to_abort();
+ }
- aborted.clear();
+ aborted.clear();
+ }
+ else
+ {
+ force_to_abort();
+ throw aborted_transaction_exception
+ ("aborting committing transaction by contention manager");
+ }
}
return true;
Modified: sandbox/stm/branches/vbe/boost/stm/transaction.hpp
==============================================================================
--- sandbox/stm/branches/vbe/boost/stm/transaction.hpp (original)
+++ sandbox/stm/branches/vbe/boost/stm/transaction.hpp 2009-10-12 15:42:06 EDT (Mon, 12 Oct 2009)
@@ -269,8 +269,13 @@
static bool cm_abort_before_commit(transaction const &t) {return contention_manager_type::abort_before_commit(t); }
static bool cm_permission_to_abort
- (transaction const &lhs, transaction const &rhs) {return contention_manager_type::permission_to_abort(lhs,rhs); }
+ (transaction const &lhs, transaction const &rhs)
+ {return contention_manager_type::permission_to_abort(lhs,rhs); }
+ static bool cm_permission_to_abort
+ (transaction const &lhs, std::list<transaction*> &rhs)
+ {return contention_manager_type::permission_to_abort(lhs,rhs); }
+
static bool cm_allow_lock_to_abort_tx(int const & lockWaitTime, int const &lockAborted,
bool txIsIrrevocable, transaction const &rhs) {
return contention_manager_type::allow_lock_to_abort_tx(lockWaitTime,lockAborted,txIsIrrevocable,rhs); }
Modified: sandbox/stm/branches/vbe/libs/stm/src/except_and_back_off_on_abort_notice_cm.cpp
==============================================================================
--- sandbox/stm/branches/vbe/libs/stm/src/except_and_back_off_on_abort_notice_cm.cpp (original)
+++ sandbox/stm/branches/vbe/libs/stm/src/except_and_back_off_on_abort_notice_cm.cpp 2009-10-12 15:42:06 EDT (Mon, 12 Oct 2009)
@@ -100,8 +100,90 @@
#endif
//return lhs.writes() * lhs.priority() >= rhs.writes() * rhs.priority();
//return lhs.writes() + lhs.reads() >= rhs.writes() + rhs.reads();
+ return true;
}
+ bool except_and_back_off_on_abort_notice_cm::permission_to_abort(transaction const &lhs, std::list<transaction*> &rhs)
+ {
+#ifdef JUST_PRIORITY
+ int setSize = (lhs.writes() * lhs.priority()) +
+ (lhs.reads() * lhs.priority());
+ double abortSetSize = 0;
+ double abortPriority = 0;
+ double decrementing = 1.0;
+
+ double highestPriority = 0;
+
+ bool hasLargestReadSet = true;
+
+ for (std::list<core::transaction*>::iterator iter = rhs.begin();
+ iter != rhs.end(); ++iter)
+ {
+ if ((*iter)->priority() > highestPriority)
+ {
+ highestPriority = (*iter)->priority();
+ }
+
+ if ((*iter)->reads() > lhs.reads()) hasLargestReadSet = false;
+ if ((*iter)->writes() > 0) return true;
+
+ abortSetSize += (double)(*iter)->reads() / decrementing;
+ abortPriority += (double)(*iter)->priority() / decrementing;
+ decrementing += 0.5;
+ }
+
+ if (lhs.priority() >= highestPriority) return true;
+
+ if (hasLargestReadSet) return true;
+
+ if (setSize >= abortPriority + abortSetSize)
+ {
+ return true;
+ }
+ else
+ {
+ return false;
+ }
+
+#else
+ double setSize = (lhs.writes() * lhs.priority()) +
+ (lhs.reads() * lhs.priority());
+ double abortSetSize = 0;
+ double abortPriority = 0;
+ bool hasLargestReadSet = true;
+
+ int mem = lhs.reads() + (lhs.writes() * 10);
+
+ double decrementing = 1.0;
+ for (std::list<boost::stm::transaction*>::iterator iter = rhs.begin();
+ iter != rhs.end(); ++iter)
+ {
+ if ((*iter)->reads() > mem) hasLargestReadSet = false;
+
+ if ((*iter)->writes() > 0) return true;
+
+ if (lhs.reads() < (*iter)->reads() / 8 &&
+ lhs.priority() * 100 < (*iter)->priority()) return false;
+
+ abortSetSize += (double)(*iter)->reads() / decrementing;
+ abortPriority += (double)(*iter)->priority() / decrementing;
+ decrementing += 0.5;
+ }
+
+ if (hasLargestReadSet) return true;
+
+ if (setSize >=
+ (abortPriority / setSize) + (abortSetSize / setSize))
+ {
+ return true;
+ }
+ else
+ {
+ return false;
+ }
+#endif
+ }
+
bool except_and_back_off_on_abort_notice_cm::allow_lock_to_abort_tx
(int const & lockWaitTime, int const &lockAborted, bool txTryingToAbortIsIrrevocable, transaction const &rhs)
{
Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk