Bug #101283 Is single_scan_itr.start() reasonable?
Submitted: 23 Oct 2020 10:13 Modified: 23 Oct 2020 11:54
Reporter: songlei wang Email Updates:
Status: Verified Impact on me:
None 
Category:MySQL Server: InnoDB storage engine Severity:S5 (Performance)
Version:8.0 OS:Any
Assigned to: CPU Architecture:Any

[23 Oct 2020 10:13] songlei wang
Description:
In function `buf_flush_single_page_from_LRU`, the first page scanned is buf_pool->single_scan_itr.start().

The function single_scan_itr.start() isimplemented as follows

/** Selects from where to start a scan. If we have scanned too deep into
the LRU list it resets the value to the tail of the LRU list.
@return buf_page_t from where to start scan. */

buf_page_t *LRUItr::start() {
  ut_ad(mutex_own(m_mutex));

  if (!m_hp || m_hp->old) {
    m_hp = UT_LIST_GET_LAST(m_buf_pool->LRU);
  }

  return (m_hp);
}

The comments said 'If we have scanned too deep into the LRU list it resets the value to the tail of the LRU list'. But 'if (!m_hp || m_hp->old)' will make it start from the tail of the LRU list every time, almost all the pages scanned by func 'buf_flush_single_page_from_LRU' are the old pages. 

Is it expected? Is 'if (!m_hp || !m_hp->old)' more reasonable?

How to repeat:
empry
[23 Oct 2020 11:54] MySQL Verification Team
Hi Mr. wang,

Thank you for your bug report.

We consider your report a welcome performance improvement request.

Verified as reported.