diff options
author | Sergei Petrunia <psergey@askmonty.org> | 2015-04-07 01:29:17 +0300 |
---|---|---|
committer | Sergei Petrunia <psergey@askmonty.org> | 2015-04-07 01:29:17 +0300 |
commit | 2af935c8ec238f57d4ed909a8876031bd36dbb4d (patch) | |
tree | 5e802608372b90a9e7c28941aab8a7507d607458 /sql/sql_analyze_stmt.h | |
parent | 2936fb127d551a1abd6f30bdfd50a8a9bcf4e41b (diff) | |
download | mariadb-git-2af935c8ec238f57d4ed909a8876031bd36dbb4d.tar.gz |
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.
Diffstat (limited to 'sql/sql_analyze_stmt.h')
-rw-r--r-- | sql/sql_analyze_stmt.h | 42 |
1 files changed, 40 insertions, 2 deletions
diff --git a/sql/sql_analyze_stmt.h b/sql/sql_analyze_stmt.h index f83ae1a57a6..d7a7f1337e0 100644 --- a/sql/sql_analyze_stmt.h +++ b/sql/sql_analyze_stmt.h @@ -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(); } + + |