diff options
author | Sergey Vojtovich <svoj@mariadb.org> | 2014-12-02 14:02:48 +0400 |
---|---|---|
committer | Sergey Vojtovich <svoj@mariadb.org> | 2014-12-05 11:01:49 +0400 |
commit | faf169d245d05a835ec8ebcf1defb556c85f2766 (patch) | |
tree | 1c38b302f755db087679775d52cfafc640b036f1 /sql/table_cache.cc | |
parent | 732d2daf448077a7d3ac88afaf1104f0ba4a9ba5 (diff) | |
download | mariadb-git-faf169d245d05a835ec8ebcf1defb556c85f2766.tar.gz |
MDEV-6906 - Relaxed memory order for counters
Let some atomic counters use relaxed memory order.
Diffstat (limited to 'sql/table_cache.cc')
-rw-r--r-- | sql/table_cache.cc | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/sql/table_cache.cc b/sql/table_cache.cc index 097f37d26d8..9e2246a5846 100644 --- a/sql/table_cache.cc +++ b/sql/table_cache.cc @@ -139,7 +139,7 @@ uint tc_records(void) { uint count; my_atomic_rwlock_rdlock(&LOCK_tdc_atomics); - count= my_atomic_load32(&tc_count); + count= my_atomic_load32_explicit(&tc_count, MY_MEMORY_ORDER_RELAXED); my_atomic_rwlock_rdunlock(&LOCK_tdc_atomics); return count; } @@ -155,7 +155,7 @@ uint tc_records(void) static void tc_remove_table(TABLE *table) { my_atomic_rwlock_wrlock(&LOCK_tdc_atomics); - my_atomic_add32(&tc_count, -1); + my_atomic_add32_explicit(&tc_count, -1, MY_MEMORY_ORDER_RELAXED); my_atomic_rwlock_wrunlock(&LOCK_tdc_atomics); table->s->tdc.all_tables.remove(table); } @@ -259,7 +259,8 @@ void tc_add_table(THD *thd, TABLE *table) /* If we have too many TABLE instances around, try to get rid of them */ my_atomic_rwlock_wrlock(&LOCK_tdc_atomics); - need_purge= my_atomic_add32(&tc_count, 1) >= (int32) tc_size; + need_purge= my_atomic_add32_explicit(&tc_count, 1, MY_MEMORY_ORDER_RELAXED) >= + (int32) tc_size; my_atomic_rwlock_wrunlock(&LOCK_tdc_atomics); if (need_purge) @@ -1101,7 +1102,7 @@ int tdc_wait_for_old_version(THD *thd, const char *db, const char *table_name, ulong tdc_refresh_version(void) { my_atomic_rwlock_rdlock(&LOCK_tdc_atomics); - ulong v= my_atomic_load64(&tdc_version); + ulong v= my_atomic_load64_explicit(&tdc_version, MY_MEMORY_ORDER_RELAXED); my_atomic_rwlock_rdunlock(&LOCK_tdc_atomics); return v; } @@ -1110,7 +1111,7 @@ ulong tdc_refresh_version(void) ulong tdc_increment_refresh_version(void) { my_atomic_rwlock_wrlock(&LOCK_tdc_atomics); - ulong v= my_atomic_add64(&tdc_version, 1); + ulong v= my_atomic_add64_explicit(&tdc_version, 1, MY_MEMORY_ORDER_RELAXED); my_atomic_rwlock_wrunlock(&LOCK_tdc_atomics); DBUG_PRINT("tcache", ("incremented global refresh_version to: %lu", v)); return v + 1; @@ -1210,7 +1211,7 @@ void tdc_assign_new_table_id(TABLE_SHARE *share) do { my_atomic_rwlock_wrlock(&LOCK_tdc_atomics); - tid= my_atomic_add64(&last_table_id, 1); + tid= my_atomic_add64_explicit(&last_table_id, 1, MY_MEMORY_ORDER_RELAXED); my_atomic_rwlock_wrunlock(&LOCK_tdc_atomics); } while (unlikely(tid == ~0UL)); |