Commit 27ff972b authored by Marko Mäkelä's avatar Marko Mäkelä

MDEV-26827 fixup: Do not hog buf_pool.mutex

buf_flush_LRU_list_batch(): When evicting clean pages,
release and reacquire the buf_pool.mutex after every 32 pages.
Also, eliminate some conditional branches.
parent 0cda0e4e
...@@ -1255,6 +1255,11 @@ static void buf_flush_LRU_list_batch(ulint max, bool evict, ...@@ -1255,6 +1255,11 @@ static void buf_flush_LRU_list_batch(ulint max, bool evict,
++n->evicted; ++n->evicted;
/* fall through */ /* fall through */
case 1: case 1:
if (UNIV_LIKELY(scanned & 31))
continue;
mysql_mutex_unlock(&buf_pool.mutex);
reacquire_mutex:
mysql_mutex_lock(&buf_pool.mutex);
continue; continue;
} }
...@@ -1290,32 +1295,37 @@ static void buf_flush_LRU_list_batch(ulint max, bool evict, ...@@ -1290,32 +1295,37 @@ static void buf_flush_LRU_list_batch(ulint max, bool evict,
auto p= buf_flush_space(space_id); auto p= buf_flush_space(space_id);
space= p.first; space= p.first;
last_space_id= space_id; last_space_id= space_id;
if (!space)
{
mysql_mutex_lock(&buf_pool.mutex);
goto no_space;
}
mysql_mutex_lock(&buf_pool.mutex); mysql_mutex_lock(&buf_pool.mutex);
if (p.second)
buf_pool.stat.n_pages_written+= p.second; buf_pool.stat.n_pages_written+= p.second;
} }
else else
{
ut_ad(!space); ut_ad(!space);
goto no_space;
}
} }
else if (space->is_stopping()) else if (space->is_stopping())
{ {
space->release(); space->release();
space= nullptr; space= nullptr;
} no_space:
if (!space)
{
mysql_mutex_lock(&buf_pool.flush_list_mutex); mysql_mutex_lock(&buf_pool.flush_list_mutex);
buf_flush_discard_page(bpage); buf_flush_discard_page(bpage);
continue;
} }
else if (neighbors && space->is_rotational())
if (neighbors && space->is_rotational())
{ {
mysql_mutex_unlock(&buf_pool.mutex); mysql_mutex_unlock(&buf_pool.mutex);
n->flushed+= buf_flush_try_neighbors(space, page_id, bpage, n->flushed+= buf_flush_try_neighbors(space, page_id, bpage,
neighbors == 1, neighbors == 1,
do_evict, n->flushed, max); do_evict, n->flushed, max);
reacquire_mutex: goto reacquire_mutex;
mysql_mutex_lock(&buf_pool.mutex);
} }
else if (n->flushed >= max && !recv_recovery_is_on()) else if (n->flushed >= max && !recv_recovery_is_on())
{ {
......
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