List:Commits« Previous MessageNext Message »
From:Davi Arnaut Date:August 21 2009 9:06pm
Subject:bzr commit into mysql-5.4 branch (davi:3546) Bug#46461
View as plain text  
# At a local mysql-5.4 repository of davi

 3546 Davi Arnaut	2009-08-21
      Bug#46461: Running test case archive_aio_posix with valgrind takes several minutes
      
      A busy wait (spin) inside the archive storage engine might cause
      a excessive slowdown when running the server with valgrind. The
      problem can also show up (to a lower extent) in single cpu systems.
      
      The busy wait could occur when the storage engine used asynchronous
      I/O, where it used busy waiting to repeatedly check if pending I/O
      for a table had been flushed.
      
      The solution is to replace the busy wait with a synchronized wait
      that sleeps on a condition variable waiting for the I/O thread to
      signal once pending I/O has been flushed.
     @ storage/archive/azio.c
        Replace busy wait with a pthread waiting mechanism.

    modified:
      storage/archive/azio.c
=== modified file 'storage/archive/azio.c'
--- a/storage/archive/azio.c	2009-03-17 20:07:27 +0000
+++ b/storage/archive/azio.c	2009-08-21 21:06:34 +0000
@@ -72,6 +72,7 @@ static pthread_handler_t run_task(void *
 
     pthread_mutex_lock(&s->container.thresh_mutex);
     s->container.ready= AZ_THREAD_FINISHED; 
+    pthread_cond_broadcast(&s->container.threshhold);
     pthread_mutex_unlock(&s->container.thresh_mutex);
   }
 
@@ -100,21 +101,20 @@ static size_t azio_return(azio_stream *s
   Don't be. In tests it never has spun more then 1 times.
 */
 
-static az_thread_type azio_ready(azio_stream *s)
+static void azio_ready(azio_stream *s)
 {
-  az_thread_type temp;
+  pthread_mutex_lock(&s->container.thresh_mutex);
 
   while (1)
   {
-    pthread_mutex_lock(&s->container.thresh_mutex);
-    temp= s->container.ready;
-    pthread_mutex_unlock(&s->container.thresh_mutex);
-
-    if (temp == AZ_THREAD_FINISHED || temp == AZ_THREAD_DEAD)
+    if (s->container.ready == AZ_THREAD_FINISHED ||
+        s->container.ready == AZ_THREAD_DEAD)
       break;
+
+    pthread_cond_wait(&s->container.threshhold, &s->container.thresh_mutex);
   }
 
-  return temp;
+  pthread_mutex_unlock(&s->container.thresh_mutex);
 }
 
 static int azio_start(azio_stream *s)


Attachment: [text/bzr-bundle] bzr/davi.arnaut@sun.com-20090821210634-0auvxywby18l0vpj.bundle
Thread
bzr commit into mysql-5.4 branch (davi:3546) Bug#46461Davi Arnaut21 Aug