Commit 66bca0df authored by Sergey Vojtovich's avatar Sergey Vojtovich

MDEV-17441 - InnoDB transition to C++11 atomics

zip_pad_info_t::pad transition to Atomic_counter.
parent c6a00544
...@@ -6821,6 +6821,7 @@ dict_index_zip_pad_update( ...@@ -6821,6 +6821,7 @@ dict_index_zip_pad_update(
ulint fail_pct; ulint fail_pct;
ut_ad(info); ut_ad(info);
ut_ad(info->pad % ZIP_PAD_INCR == 0);
total = info->success + info->failure; total = info->success + info->failure;
...@@ -6845,17 +6846,16 @@ dict_index_zip_pad_update( ...@@ -6845,17 +6846,16 @@ dict_index_zip_pad_update(
if (fail_pct > zip_threshold) { if (fail_pct > zip_threshold) {
/* Compression failures are more then user defined /* Compression failures are more then user defined
threshold. Increase the pad size to reduce chances of threshold. Increase the pad size to reduce chances of
compression failures. */ compression failures.
ut_ad(info->pad % ZIP_PAD_INCR == 0);
/* Only do increment if it won't increase padding Only do increment if it won't increase padding
beyond max pad size. */ beyond max pad size. */
if (info->pad + ZIP_PAD_INCR if (info->pad + ZIP_PAD_INCR
< (srv_page_size * zip_pad_max) / 100) { < (srv_page_size * zip_pad_max) / 100) {
/* Use atomics even though we have the mutex. /* Use atomics even though we have the mutex.
This is to ensure that we are able to read This is to ensure that we are able to read
info->pad atomically. */ info->pad atomically. */
my_atomic_addlint(&info->pad, ZIP_PAD_INCR); info->pad += ZIP_PAD_INCR;
MONITOR_INC(MONITOR_PAD_INCREMENTS); MONITOR_INC(MONITOR_PAD_INCREMENTS);
} }
...@@ -6873,11 +6873,10 @@ dict_index_zip_pad_update( ...@@ -6873,11 +6873,10 @@ dict_index_zip_pad_update(
if (info->n_rounds >= ZIP_PAD_SUCCESSFUL_ROUND_LIMIT if (info->n_rounds >= ZIP_PAD_SUCCESSFUL_ROUND_LIMIT
&& info->pad > 0) { && info->pad > 0) {
ut_ad(info->pad % ZIP_PAD_INCR == 0);
/* Use atomics even though we have the mutex. /* Use atomics even though we have the mutex.
This is to ensure that we are able to read This is to ensure that we are able to read
info->pad atomically. */ info->pad atomically. */
my_atomic_addlint(&info->pad, ulint(-ZIP_PAD_INCR)); info->pad -= ZIP_PAD_INCR;
info->n_rounds = 0; info->n_rounds = 0;
...@@ -6950,7 +6949,7 @@ dict_index_zip_pad_optimal_page_size( ...@@ -6950,7 +6949,7 @@ dict_index_zip_pad_optimal_page_size(
return(srv_page_size); return(srv_page_size);
} }
pad = my_atomic_loadlint(&index->zip_pad.pad); pad = index->zip_pad.pad;
ut_ad(pad < srv_page_size); ut_ad(pad < srv_page_size);
sz = srv_page_size - pad; sz = srv_page_size - pad;
......
...@@ -873,7 +873,8 @@ an uncompressed page should be left as padding to avoid compression ...@@ -873,7 +873,8 @@ an uncompressed page should be left as padding to avoid compression
failures. This estimate is based on a self-adapting heuristic. */ failures. This estimate is based on a self-adapting heuristic. */
struct zip_pad_info_t { struct zip_pad_info_t {
SysMutex* mutex; /*!< mutex protecting the info */ SysMutex* mutex; /*!< mutex protecting the info */
ulint pad; /*!< number of bytes used as pad */ Atomic_counter<ulint>
pad; /*!< number of bytes used as pad */
ulint success;/*!< successful compression ops during ulint success;/*!< successful compression ops during
current round */ current round */
ulint failure;/*!< failed compression ops during ulint failure;/*!< failed compression ops during
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment