Bug #68880 buf_print_io stats language is inaccurate
Submitted: 7 Apr 2013 11:03 Modified: 7 Apr 2013 18:28
Reporter: Ted Nyman Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Logging Severity:S3 (Non-critical)
Version:5.1, 5.5, 5.6 OS:Any
Assigned to: CPU Architecture:Any
Tags: documentation, stats

[7 Apr 2013 11:03] Ted Nyman
Description:
The buf_print_io() function in 5.1 and buf_print_io_instance() in 5.5 and 5.6 (http://bazaar.launchpad.net/~mysql/mysql-server/5.5/view/head:/storage/innobase/buf/buf0bu...) are used prominently by SHOW INNODB STATUS to show data about the buffer cache. For example: 

Pages made young 764892283, not young 12854192
8.99 youngs/s, 48.95 non-youngs/s

The line "8.99 youngs/s, 48.95 non-youngs/s" would appear to be 8.99 young *per second*. But that does not seem to be the case in the implementation.

In buf_stats_get_pool_info(): 

pool_info->page_not_made_young_rate =
		 (buf_pool->stat.n_pages_not_made_young
		  - buf_pool->old_stat.n_pages_not_made_young) / time_elapsed;

And time_elapsed is:

time_elapsed = 0.001 + difftime(current_time,
					buf_pool->last_printout_time);

which appears to be based on the last_printout_time — implying that the time_elapsed will change depending on the last_printout_time, and therefore meaning that the rate printed out in the status reports depends on the last access time. Displaying the date as "/s" then is not accurate. 

General MySQL documentation in source and on the web manuals does not mention the use of time_elapsed or the fact the nature of this rate will change depending on it.

How to repeat:
View output of SHOW INNODB STATUS, read code, compare with documentation and stat description.

Suggested fix:
Improve wording to reflect the actual implementation. Update documentation to mention the the use of time_elapsed. Alternatively, change the implementation to use a constant per-second rate.
[7 Apr 2013 11:42] Ted Nyman
Related code:

Refreshes the statistics used to print per-second averages. */
UNIV_INTERN
void
buf_refresh_io_stats(void)
/*======================*/
{
	buf_pool->last_printout_time = time(NULL);
	buf_pool->old_stat = buf_pool->stat;
}
[7 Apr 2013 18:28] Ted Nyman
Closing in favor of #68882