You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@impala.apache.org by jo...@apache.org on 2026/10/20 18:27:06 UTC
(impala) 02/02: IMPALA-15585: Detect fast CLOCK_MONOTONIC on ARM
This is an automated email from the ASF dual-hosted git repository.
asf-gitbox-commits pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/impala.git
commit 64a7b8b8b9ab0676e37ade0663473fc6e854b2d4
Author: Joe McDonnell <jo...@cloudera.com>
AuthorDate: Sun Oct 18 22:09:06 2026 -0700
IMPALA-15585: Detect fast CLOCK_MONOTONIC on ARM
In IMPALA-2407, Impala added logic to detect whether clock_gettime's
CLOCK_MONOTONIC has a fast implementation. At the time, some clock
implementations like Xen were very slow. To avoid the performance
penalty, it uses CLOCK_MONOTONIC_COARSE when the clock source
is not known to be fast.
ARM has a fast clock source for CLOCK_MONOTONIC, but it is not being
detected properly because it has a different name than x86_64.
ARM currently uses CLOCK_MONOTONIC_COARSE, which makes profile
time counters considerably less useful.
This adds detection for the ARM fast time counter (arch_sys_counter)
in addition to the x86_64 version (tsc).
Testing:
- Ran a perf-AB-test on ARM and verified that the profiles have
more exact time values (without performance regression)
Change-Id: I6512e5dbbb11c4816716deccce3c0e212f73cf33
Reviewed-on: http://gerrit.cloudera.org:8080/25149
Tested-by: Impala Public Jenkins <im...@cloudera.com>
Reviewed-by: Yida Wu <wy...@gmail.com>
Reviewed-by: Jason Fehr <jf...@cloudera.com>
---
be/src/util/os-info.cc | 13 ++++++++++---
1 file changed, 10 insertions(+), 3 deletions(-)
diff --git a/be/src/util/os-info.cc b/be/src/util/os-info.cc
index 0811248c9..f7aaa52ae 100644
--- a/be/src/util/os-info.cc
+++ b/be/src/util/os-info.cc
@@ -21,6 +21,7 @@
#include <string.h>
#include <fstream>
#include <sstream>
+#include <string_view>
#include <unistd.h>
#include <sys/stat.h>
@@ -87,17 +88,23 @@ void OsInfo::Init() {
if (os_version.good()) getline(os_version, os_version_);
if (os_version.is_open()) os_version.close();
- // Read the current clocksource to see if CLOCK_MONOTONIC is known to be fast. "tsc" is
- // fast, while "xen" is slow (40 times slower than "tsc" on EC2). If CLOCK_MONOTONIC is
+ // Read the current clocksource to see if CLOCK_MONOTONIC is known to be fast.
+ // On X86_64, "tsc" is fast, while "xen" is slow (40 times slower than "tsc"
+ // on EC2). On ARM, "arch_sys_counter" is the fast clocksource. If CLOCK_MONOTONIC is
// known to be slow, we use CLOCK_MONOTONIC_COARSE, which uses jiffies, with a
// resolution measured in milliseconds, rather than nanoseconds.
+#ifdef __aarch64__
+ constexpr std::string_view FAST_CLOCK_SOURCE = "arch_sys_counter";
+#else
+ constexpr std::string_view FAST_CLOCK_SOURCE = "tsc";
+#endif
std::ifstream clocksource_file(
"/sys/devices/system/clocksource/clocksource0/current_clocksource");
if (clocksource_file.good()) {
std::string clocksource;
clocksource_file >> clocksource;
clock_name_ = "clocksource: '" + clocksource + "', clockid_t: ";
- if (HAVE_CLOCK_MONOTONIC_COARSE && clocksource != "tsc") {
+ if (HAVE_CLOCK_MONOTONIC_COARSE && clocksource != FAST_CLOCK_SOURCE) {
clock_name_ += "CLOCK_MONOTONIC_COARSE";
fast_clock_ = CLOCK_MONOTONIC_COARSE;
} else {