1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-30 16:24:05 +03:00

MDEV-7899: 10.1 is 3% slower than 10.0 in OLTP RO

- Remove ANALYZE's timing code off the the execution path of regular
  SELECTs.
- Improve the tracker that tracks counts/execution times of SELECTs or
  DML statements:
  = regular execution just increments counters
  = ANALYZE will also collect timings.
This commit is contained in:
Sergei Petrunia
2015-04-07 01:29:17 +03:00
parent 2936fb127d
commit 2af935c8ec
10 changed files with 105 additions and 70 deletions

View File

@ -20,6 +20,7 @@
*/
class Exec_time_tracker
{
protected:
ulonglong count;
ulonglong cycles;
ulonglong last_start;
@ -34,9 +35,8 @@ public:
void stop_tracking()
{
ulonglong last_end= my_timer_cycles();
count++;
cycles += last_end - last_start;
cycles += my_timer_cycles()- last_start;
}
// interface for getting the time
@ -48,3 +48,41 @@ public:
}
};
/*
A class for counting certain actions (in all queries), and optionally
collecting the timings (in ANALYZE queries).
*/
class Time_and_counter_tracker: public Exec_time_tracker
{
public:
const bool timed;
Time_and_counter_tracker(bool timed_arg) : timed(timed_arg)
{}
/* Loops are counted in both ANALYZE and regular queries, as this is cheap */
void incr_loops() { count++; }
/*
Unlike Exec_time_tracker::stop_tracking, we don't increase loops.
*/
void stop_tracking()
{
cycles += my_timer_cycles()- last_start;
}
};
#define ANALYZE_START_TRACKING(tracker) \
{ \
(tracker)->incr_loops(); \
if (unlikely((tracker)->timed)) \
{ (tracker)->start_tracking(); } \
}
#define ANALYZE_STOP_TRACKING(tracker) \
if (unlikely((tracker)->timed)) \
{ (tracker)->stop_tracking(); }