[compiler-rt] 36ca9a2 - [scudo] Use getMonotonicTimeFast for tryLock.

Christopher Ferris via llvm-commits llvm-commits at lists.llvm.org
Thu Jun 29 13:07:20 PDT 2023


Author: Christopher Ferris
Date: 2023-06-29T13:07:08-07:00
New Revision: 36ca9a29025a2f678096e9545fa2ec44e8432592

URL: https://github.com/llvm/llvm-project/commit/36ca9a29025a2f678096e9545fa2ec44e8432592
DIFF: https://github.com/llvm/llvm-project/commit/36ca9a29025a2f678096e9545fa2ec44e8432592.diff

LOG: [scudo] Use getMonotonicTimeFast for tryLock.

In tryLock, the Precedence value is set using the fast time function
now. This should speed up tryLock calls slightly.

This should be okay even though the value is used as a kind of random
value in getTSDAndLockSlow. The fast time call still sets enough bits
to avoid getting the same TSD on every call.

Reviewed By: Chia-hungDuan

Differential Revision: https://reviews.llvm.org/D154039

Added: 
    

Modified: 
    compiler-rt/lib/scudo/standalone/tsd.h

Removed: 
    


################################################################################
diff  --git a/compiler-rt/lib/scudo/standalone/tsd.h b/compiler-rt/lib/scudo/standalone/tsd.h
index c5ed6ddfa124eb..f4fa545de5e046 100644
--- a/compiler-rt/lib/scudo/standalone/tsd.h
+++ b/compiler-rt/lib/scudo/standalone/tsd.h
@@ -41,9 +41,9 @@ template <class Allocator> struct alignas(SCUDO_CACHE_LINE_SIZE) TSD {
       return true;
     }
     if (atomic_load_relaxed(&Precedence) == 0)
-      atomic_store_relaxed(
-          &Precedence,
-          static_cast<uptr>(getMonotonicTime() >> FIRST_32_SECOND_64(16, 0)));
+      atomic_store_relaxed(&Precedence,
+                           static_cast<uptr>(getMonotonicTimeFast() >>
+                                             FIRST_32_SECOND_64(16, 0)));
     return false;
   }
   inline void lock() NO_THREAD_SAFETY_ANALYSIS {


        


More information about the llvm-commits mailing list