Bug #38318 is call thd->end_time() in log_slow_statement needed if slow logs are disabled ?
Submitted: 23 Jul 2008 17:09 Modified: 17 Aug 2011 13:15
Reporter: Shane Bester (Platinum Quality Contributor) Email Updates:
Status: Can't repeat Impact on me:
None 
Category:MySQL Server: Logging Severity:S5 (Performance)
Version:5.0.66a OS:Any
Assigned to: CPU Architecture:Any

[23 Jul 2008 17:09] Shane Bester
Description:
is call thd->end_time() in log_slow_statement needed if slow logs are disabled ?
it seems calls to time() or gtime() on solaris are made many times.
since i don't log slow statements, this leads to alot of extra calls.

gtime() was one of the highest system calls made in some simple tests

<cut>
lwp_sigmask                            931463
pwrite64                               980081
gtime                                  1912818
llseek                                 16034893
read                                   33489876

mysql> show global variables like 'log_slow_queries';
+------------------+-------+
| Variable_name    | Value |
+------------------+-------+
| log_slow_queries | OFF   |
+------------------+-------+
1 row in set (0.00 sec)

this seems fixed in 5.1-bzr due to the microseconds logging.
http://developers.sun.com/solaris/articles/mysql_perf_tune.html#2

How to repeat:
read the source code of log_slow_statement() in sql_parse.cc

dstrace can show the number of these calls on solaris - just run few thousand queries against mysqld and monitor mysqld like this:

dtrace -n 'syscall::gtime:entry /execname == "mysqld"/ { @[ustack()] = count();}'

Suggested fix:
in function void log_slow_statement(THD *thd)
put these two lines :

start_of_query= thd->start_time;
thd->end_time(); // Set start time

inside the block:

if (thd->enable_slow_log && !thd->user_time)
{

}
[27 Oct 2008 22:04] Konstantin Osipov
The bug is not present in 6.0
[27 Oct 2008 22:05] Konstantin Osipov
Nor it is present in 5.1