diff options
author | Daniel Black <daniel@mariadb.org> | 2023-02-04 20:32:26 +1100 |
---|---|---|
committer | Daniel Black <daniel@mariadb.org> | 2023-04-27 14:42:04 +1000 |
commit | 7020887e3edb8a681375b5e0cdd7cb59d3dfe1c0 (patch) | |
tree | 3067ed16c46f14d370bfdd01faec2fb5c57c7187 | |
parent | 55cf4194f91262234eda1fabd380484894b1a5a7 (diff) | |
download | mariadb-git-7020887e3edb8a681375b5e0cdd7cb59d3dfe1c0.tar.gz |
MDEV-30411: main.explain_json_format_partitions fails on Debian arm{el,hf}
Extend the portability of ANALYZE FORMAT=JSON by using the microsecond
timer if cycles isn't available.
Reviewer: Sergei Petrunia <sergey@mariadb.com>
-rw-r--r-- | sql/sql_analyze_stmt.h | 29 |
1 files changed, 23 insertions, 6 deletions
diff --git a/sql/sql_analyze_stmt.h b/sql/sql_analyze_stmt.h index d033e79168a..30706889eff 100644 --- a/sql/sql_analyze_stmt.h +++ b/sql/sql_analyze_stmt.h @@ -38,6 +38,16 @@ $stmt"). */ +/* fake microseconds as cycles if cycles isn't available */ +static inline double timer_tracker_frequency() +{ +#if (MY_TIMER_ROUTINE_CYCLES) + return static_cast<double>(sys_timer_info.cycles.frequency); +#else + return static_cast<double>(sys_timer_info.microseconds.frequency); +#endif +} + class Gap_time_tracker; void attach_gap_time_tracker(THD *thd, Gap_time_tracker *gap_tracker, ulonglong timeval); void process_gap_time_tracker(THD *thd, ulonglong timeval); @@ -52,9 +62,18 @@ protected: ulonglong cycles; ulonglong last_start; + ulonglong measure() const + { +#if (MY_TIMER_ROUTINE_CYCLES) + return my_timer_cycles(); +#else + return my_timer_microseconds(); +#endif + } + void cycles_stop_tracking(THD *thd) { - ulonglong end= my_timer_cycles(); + ulonglong end= measure(); cycles += end - last_start; if (unlikely(end < last_start)) cycles += ULONGLONG_MAX; @@ -80,7 +99,7 @@ public: // interface for collecting time void start_tracking(THD *thd) { - last_start= my_timer_cycles(); + last_start= measure(); process_gap_time_tracker(thd, last_start); } @@ -96,7 +115,7 @@ public: { // convert 'cycles' to milliseconds. return 1000.0 * static_cast<double>(cycles) / - static_cast<double>(sys_timer_info.cycles.frequency); + timer_tracker_frequency(); } bool has_timed_statistics() const { return cycles > 0; } @@ -122,13 +141,11 @@ public: double get_time_ms() const { // convert 'cycles' to milliseconds. - return 1000.0 * static_cast<double>(cycles) / - static_cast<double>(sys_timer_info.cycles.frequency); + return 1000.0 * static_cast<double>(cycles) / timer_tracker_frequency(); } }; - /* A class for counting certain actions (in all queries), and optionally collecting the timings (in ANALYZE queries). |