[Lldb-commits] [lldb] r370785 - [test] Addres TestConcurrentMany*.py flakiness on macOS

Jonas Devlieghere via lldb-commits lldb-commits at lists.llvm.org
Tue Sep 3 10:04:05 PDT 2019


Author: jdevlieghere
Date: Tue Sep  3 10:04:04 2019
New Revision: 370785

URL: http://llvm.org/viewvc/llvm-project?rev=370785&view=rev
Log:
[test] Addres  TestConcurrentMany*.py flakiness on macOS

On "fast" macOS machines, the TestConcurrentMany*.py tests would fail
randomly with different numbers of breakpoints, watchpoints, etc. This
seems to be avoidable by giving the threads a little time to breath
after the passing the synchronization barrier. This is far from a
structural fix but it reduces the flakiness.

Modified:
    lldb/trunk/packages/Python/lldbsuite/test/make/pseudo_barrier.h

Modified: lldb/trunk/packages/Python/lldbsuite/test/make/pseudo_barrier.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/make/pseudo_barrier.h?rev=370785&r1=370784&r2=370785&view=diff
==============================================================================
--- lldb/trunk/packages/Python/lldbsuite/test/make/pseudo_barrier.h (original)
+++ lldb/trunk/packages/Python/lldbsuite/test/make/pseudo_barrier.h Tue Sep  3 10:04:04 2019
@@ -1,20 +1,15 @@
 #include <atomic>
-
-// Note that although hogging the CPU while waiting for a variable to change
-// would be terrible in production code, it's great for testing since it
-// avoids a lot of messy context switching to get multiple threads synchronized.
+#include <thread>
 
 typedef std::atomic<int> pseudo_barrier_t;
-#define pseudo_barrier_wait(barrier)        \
-    do                                      \
-    {                                       \
-        --(barrier);                        \
-        while ((barrier).load() > 0)        \
-            ;                               \
-    } while (0)
 
-#define pseudo_barrier_init(barrier, count) \
-    do                                      \
-    {                                       \
-        (barrier) = (count);                \
-    } while (0)
+static inline void pseudo_barrier_wait(pseudo_barrier_t &barrier) {
+  --barrier;
+  while (barrier > 0)
+    std::this_thread::yield();
+  std::this_thread::sleep_for(std::chrono::milliseconds(100));
+}
+
+static inline void pseudo_barrier_init(pseudo_barrier_t &barrier, int count) {
+  barrier = count;
+}




More information about the lldb-commits mailing list