From 84c60905008131ff35b93b9f8b64923e267f92a6 Mon Sep 17 00:00:00 2001 From: Mythri Alle Date: Tue, 28 Jan 2025 05:31:12 -0800 Subject: Revert^2 "Use nanoseconds for v2 method tracing" This reverts commit e8ea3a17d66636e6cc6a395b967e22aac8761e67. Reason for revert: Upload after potential fix for the failures. We used to use 32-bit entries for storing threadcpu time. With nanosecond precision this overflows in about 4 seconds. On gcstress configuration this was potentially overflowing causing the failures. The fix now uses 64-bit entries for threadcpu time. Wall clock time was already using 64-bit entries. Change-Id: I819fe45e0a465e5a5b037248a4cd7107acb5130d --- runtime/thread.cc | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'runtime/thread.cc') diff --git a/runtime/thread.cc b/runtime/thread.cc index 50f6bfc499..89465979da 100644 --- a/runtime/thread.cc +++ b/runtime/thread.cc @@ -1484,13 +1484,22 @@ void Thread::GetThreadName(std::string& name) const { } uint64_t Thread::GetCpuMicroTime() const { +#if defined(__linux__) + return Thread::GetCpuNanoTime() / 1000; +#else // __APPLE__ + UNIMPLEMENTED(WARNING); + return -1; +#endif +} + +uint64_t Thread::GetCpuNanoTime() const { #if defined(__linux__) clockid_t cpu_clock_id; pthread_getcpuclockid(tlsPtr_.pthread_self, &cpu_clock_id); timespec now; clock_gettime(cpu_clock_id, &now); - return static_cast(now.tv_sec) * UINT64_C(1000000) + - static_cast(now.tv_nsec) / UINT64_C(1000); + return static_cast(now.tv_sec) * UINT64_C(1000000000) + + static_cast(now.tv_nsec); #else // __APPLE__ UNIMPLEMENTED(WARNING); return -1; -- cgit v1.2.3-59-g8ed1b