MDEV-7728 - Improve xid cache scalability by using lock-free hash

This is an addition to original patch. Some platforms are strict about atomic
op argument signedness.
This commit is contained in:
Sergey Vojtovich 2015-03-16 22:54:43 +04:00
parent e6f67c64cd
commit fec94a6b44

View File

@ -5182,8 +5182,9 @@ void mark_transaction_to_rollback(THD *thd, bool all)
class XID_cache_element class XID_cache_element
{ {
/* /*
bits 1..31 are reference counter bits 1..30 are reference counter
bit 32 is UNINITIALIZED flag bit 31 is UNINITIALIZED flag
bit 32 is unused
Newly allocated and deleted elements have UNINITIALIZED flag set. Newly allocated and deleted elements have UNINITIALIZED flag set.
@ -5204,8 +5205,8 @@ class XID_cache_element
Currently m_state is only used to prevent elements from being deleted while Currently m_state is only used to prevent elements from being deleted while
XA RECOVER iterates xid cache. XA RECOVER iterates xid cache.
*/ */
uint32 m_state; int32 m_state;
static const uint32 UNINITIALIZED= 1 << 31; static const int32 UNINITIALIZED= 1 << 30;
public: public:
XID_STATE *m_xid_state; XID_STATE *m_xid_state;
bool lock() bool lock()
@ -5224,7 +5225,7 @@ public:
} }
void mark_uninitialized() void mark_uninitialized()
{ {
uint old= 0; int32 old= 0;
while (!my_atomic_cas32_weak_explicit(&m_state, &old, UNINITIALIZED, while (!my_atomic_cas32_weak_explicit(&m_state, &old, UNINITIALIZED,
MY_MEMORY_ORDER_RELAXED, MY_MEMORY_ORDER_RELAXED,
MY_MEMORY_ORDER_RELAXED)) MY_MEMORY_ORDER_RELAXED))