Comment #1 on issue 2657 by [email protected]: cctest/test-thread-termination/TerminateMultipleV8ThreadsDefaultIsolate timeout on MIPS-sim and ARM-sim
http://code.google.com/p/v8/issues/detail?id=2657

We checked it on mac and ubuntu linux x64, on the same mac hardware. On mac there was no slowdown, even when in idle. On Ubuntu:
run 19
real 0m39.501s
user 0m39.680s
sys 0m0.176s

run 20
real 0m11.172s
user 0m11.184s
sys 0m0.072s

run 21
real 0m0.033s
user 0m0.028s
sys 0m0.004s

As you can see, while not as severe as for the simulators, it can still get into a locked state. During run 21 a firefox instance was started, and the test finished almost instantly. So this looks like an issue with the the process scheduler of the linux kernel. It looks like it affects a lot of kernel versions (we tested on Ubuntu lucid - 2.6.32, and also on the latest Ubuntu - 3.8)

I made a pthread_setaffinity_np test. If all the 3 threads which acquires the mutex of the default isolate are forced to run on the same core then the test terminates very quickly (time reports 0m0.0x sec runtimes). If test threads are on core 1 and the main/starter/waiter thread is on core 2 then I got similar runtimes as without forcing the cores. Starting other programs (disk usage, new process activity - core usage?) also speeds up pending tests.

The pthread_setaffinity_np patch I used:
diff --git a/test/cctest/test-thread-termination.cc b/test/cctest/test-thread-termination.cc
index 190fc7b..14d656a 100644
--- a/test/cctest/test-thread-termination.cc
+++ b/test/cctest/test-thread-termination.cc
@@ -29,6 +29,17 @@
 #include "platform.h"
 #include "cctest.h"

+#include <pthread.h>
+
+static int _setCpuAffinity(int core_id) {
+  cpu_set_t cpuset;
+  CPU_ZERO(&cpuset);
+  CPU_SET(core_id, &cpuset);
+
+  pthread_t current_thread = pthread_self();
+ int res = pthread_setaffinity_np(current_thread, sizeof(cpu_set_t), &cpuset);
+  return res;
+}

 v8::internal::Semaphore* semaphore = NULL;

@@ -202,6 +213,7 @@ class LoopingThread : public v8::internal::Thread {
  public:
   LoopingThread() : Thread("LoopingThread") { }
   void Run() {
+    _setCpuAffinity(1);
     v8::Locker locker(CcTest::default_isolate());
     v8::HandleScope scope(CcTest::default_isolate());
     v8_thread_id_ = v8::V8::GetCurrentThreadId();
@@ -233,6 +245,7 @@ TEST(TerminateMultipleV8ThreadsDefaultIsolate) {
     v8::Locker::StartPreemption(1);
     semaphore = v8::internal::OS::CreateSemaphore(0);
   }
+  _setCpuAffinity(1);
   const int kThreads = 2;
   i::List<LoopingThread*> threads(kThreads);
   for (int i = 0; i < kThreads; i++) {

--
You received this message because this project is configured to send all issue notifications to this address.
You may adjust your notification preferences at:
https://code.google.com/hosting/settings

--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
--- You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to