@@ -25,7 +25,6 @@ The database buffer buf_pool flush algorithm
25
25
Created 11/11/1995 Heikki Tuuri
26
26
*******************************************************/
27
27
28
- #include < iomanip>
29
28
#include " univ.i"
30
29
#include < my_service_manager.h>
31
30
#include < mysql/service_thd_wait.h>
@@ -1375,9 +1374,10 @@ static void buf_flush_LRU_list_batch(ulint max, flush_counters_t *n) noexcept
1375
1374
break ;
1376
1375
}
1377
1376
1378
- bool reached_half= UT_LIST_GET_LEN (buf_pool.free ) >= free_limit / 2 ;
1379
-
1380
- if (reached_half && neighbors && space->is_rotational ())
1377
+ if (neighbors && space->is_rotational () &&
1378
+ /* Skip neighbourhood flush from LRU list if we haven't yet reached
1379
+ half of the free page target. */
1380
+ UT_LIST_GET_LEN (buf_pool.free ) * 2 >= free_limit)
1381
1381
n->flushed += buf_flush_try_neighbors (space, page_id, bpage,
1382
1382
neighbors == 1 ,
1383
1383
n->flushed , max);
@@ -2343,9 +2343,9 @@ static void buf_flush_page_cleaner() noexcept
2343
2343
{
2344
2344
std::this_thread::sleep_for (std::chrono::seconds (1 ));
2345
2345
/* Cover the logging code in debug mode. */
2346
- print_flush_info (stderr );
2346
+ buf_pool. print_flush_info ();
2347
2347
buf_dblwr.lock ();
2348
- buf_dblwr.print_info (stderr );
2348
+ buf_dblwr.print_info ();
2349
2349
buf_dblwr.unlock ();
2350
2350
});
2351
2351
lsn_limit= buf_flush_sync_lsn;
@@ -2553,7 +2553,8 @@ static void buf_flush_page_cleaner() noexcept
2553
2553
n= n >= n_flushed ? n - n_flushed : 0 ;
2554
2554
/* It is critical to generate free pages to keep the system alive. Make
2555
2555
sure we are not hindered by dirty pages in LRU tail. */
2556
- n= std::max (n, std::min (srv_max_io_capacity, buf_pool.LRU_scan_depth ));
2556
+ n= std::max<ulint>(n, std::min<ulint>(srv_max_io_capacity,
2557
+ buf_pool.LRU_scan_depth ));
2557
2558
goto LRU_flush;
2558
2559
}
2559
2560
@@ -2595,7 +2596,7 @@ ATTRIBUTE_COLD void buf_pool_t::LRU_warn() noexcept
2595
2596
{
2596
2597
sql_print_warning (" InnoDB: Could not free any blocks in the buffer pool!"
2597
2598
" Consider increasing innodb_buffer_pool_size." );
2598
- print_flush_info (stderr );
2599
+ buf_pool. print_flush_info ();
2599
2600
}
2600
2601
}
2601
2602
@@ -2676,48 +2677,51 @@ void buf_flush_sync() noexcept
2676
2677
thd_wait_end (nullptr );
2677
2678
}
2678
2679
2679
- void print_flush_info (FILE* file)
2680
+ ATTRIBUTE_COLD void buf_pool_t:: print_flush_info () const noexcept
2680
2681
{
2681
2682
/* We do dirty read of UT_LIST count variable. */
2682
- ulint lru_size= UT_LIST_GET_LEN (buf_pool. LRU );
2683
- ulint dirty_size= UT_LIST_GET_LEN (buf_pool. flush_list );
2684
- ulint free_size= UT_LIST_GET_LEN (buf_pool. free );
2683
+ ulint lru_size= UT_LIST_GET_LEN (LRU);
2684
+ ulint dirty_size= UT_LIST_GET_LEN (flush_list);
2685
+ ulint free_size= UT_LIST_GET_LEN (free);
2685
2686
ulint dirty_pct= lru_size ? dirty_size * 100 / (lru_size + free_size) : 0 ;
2687
+ sql_print_information (" Innodb: Buffer Pool pages \n "
2688
+ " -------------------\n "
2689
+ " LRU Pages: %lu\n "
2690
+ " Free Pages: %lu\n "
2691
+ " Dirty Pages: %lu : %lu%%\n "
2692
+ " -------------------" ,
2693
+ lru_size, free_size, dirty_size, dirty_pct);
2686
2694
2687
2695
lsn_t lsn= log_sys.get_lsn ();
2688
2696
lsn_t clsn= log_sys.last_checkpoint_lsn ;
2697
+ sql_print_information (" Innodb: LSN flush parameters\n "
2698
+ " -------------------\n "
2699
+ " System LSN : %" PRIu64 " \n "
2700
+ " Checkpoint LSN: %" PRIu64 " \n "
2701
+ " Flush ASync LSN: %" PRIu64 " \n "
2702
+ " Flush Sync LSN: %" PRIu64 " \n "
2703
+ " -------------------" ,
2704
+ lsn, clsn, buf_flush_async_lsn, buf_flush_sync_lsn);
2705
+
2689
2706
lsn_t age= lsn - clsn;
2690
2707
lsn_t age_pct= log_sys.max_checkpoint_age
2691
2708
? age * 100 / log_sys.max_checkpoint_age : 0 ;
2692
-
2693
- std::ostringstream log_strm;
2694
- log_strm
2695
- << " -------------------\n "
2696
- << " Innodb: Buffer Pool\n "
2697
- << " -------------------\n "
2698
- << " LRU Pages : " << lru_size << " \n "
2699
- << " Free Pages: " << free_size << " \n "
2700
- << " DirtyPages: " << dirty_size << " : " << dirty_pct << " %\n "
2701
- << " ----------------------------\n "
2702
- << " Innodb: Flush LSN Parameter \n "
2703
- << " ----------------------------\n "
2704
- << " System LSN : " << lsn << " \n "
2705
- << " Checkpoint LSN : " << clsn << " \n "
2706
- << " Flush ASync LSN: " << buf_flush_async_lsn << " \n "
2707
- << " Flush Sync LSN : " << buf_flush_sync_lsn << " \n "
2708
- << " --------------------------\n "
2709
- << " Innodb: LSN Age Parameters\n "
2710
- << " --------------------------\n "
2711
- << " Current Age : " << age << " : " << age_pct << " %\n "
2712
- << " Max Age(Async): " << log_sys.max_modified_age_async << " \n "
2713
- << " Max Age(Sync) : " << log_sys.max_checkpoint_age << " \n "
2714
- << " Capacity : " << log_sys.log_capacity << " \n "
2715
- << " --------------------------\n "
2716
- << " Innodb: Pending IO count \n "
2717
- << " -------------------------\n "
2718
- << " Pending Read: " << os_aio_pending_reads_approx () << " \n "
2719
- << " Pending Write: " << os_aio_pending_writes_approx () << " \n " ;
2720
- fputs (log_strm.str ().c_str (), file);
2709
+ sql_print_information (" Innodb: LSN age parameters\n "
2710
+ " -------------------\n "
2711
+ " Current Age : %" PRIu64 " : %" PRIu64 " %%\n "
2712
+ " Max Age(Async): %" PRIu64 " \n "
2713
+ " Max Age(Sync) : %" PRIu64 " \n "
2714
+ " Capacity : %" PRIu64 " \n "
2715
+ " -------------------" ,
2716
+ age, age_pct, log_sys.max_modified_age_async , log_sys.max_checkpoint_age ,
2717
+ log_sys.log_capacity );
2718
+
2719
+ sql_print_information (" Innodb: Pending IO count\n "
2720
+ " -------------------\n "
2721
+ " Pending Read: %zu\n "
2722
+ " Pending Write: %zu\n "
2723
+ " -------------------" ,
2724
+ os_aio_pending_reads_approx (), os_aio_pending_writes_approx ());
2721
2725
}
2722
2726
2723
2727
#ifdef UNIV_DEBUG
0 commit comments