wasphin commented on code in PR #3247:
URL: https://github.com/apache/brpc/pull/3247#discussion_r3587612637
##########
src/butil/time.cpp:
##########
@@ -152,7 +152,17 @@ int64_t read_invariant_cpu_frequency() {
return freq;
}
-int64_t invariant_cpu_freq = -1;
+static int64_t init_invariant_cpu_freq() {
+ int64_t base_freq_hz = -1;
+#if defined(__aarch64__)
+ __asm__ __volatile__("mrs %0, CNTFRQ_EL0" : "=r"(base_freq_hz));
+#else
+ base_freq_hz = detail::read_invariant_cpu_frequency();
+#endif
Review Comment:
Would it be better to just implement inside function
`read_invariant_cpu_frequency`?
##########
src/butil/time.h:
##########
@@ -279,7 +279,7 @@ extern int64_t invariant_cpu_freq;
// note: Inlining shortens time cost per-call for 15ns in a loop of many
// calls to this function.
inline int64_t cpuwide_time_ns() {
-#if !defined(BAIDU_INTERNAL)
+#if !defined(BAIDU_INTERNAL) && !defined(__aarch64__)
Review Comment:
`BAIDU_INTERNAL` and `__aarch64__` are options at different dimensions. It
is not recommended to combine them in a single conditional directive simply
because the same code could be reused.
In addition, please also consider whether BAIDU_INTERNAL still needs to be
retained. cc @wwbmmm
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]