apr-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Aaron Bannert <aa...@clove.org>
Subject Re: [proposal] apr_thread_setconcurrency()
Date Sun, 16 Sep 2001 00:05:56 GMT
On Fri, Sep 14, 2001 at 08:16:03PM -0700, Ian Holsman wrote:
> > +1 IF the number you set it to is a hint, and solaris can changes the
> > concurrency afterwards according to the load on the system/internal
> > guidelines.

This is how it appears to work according to the source. I'll try fooling
with worker and make sure it works the way I'm expecting.

> > I ran the the testlockperf code on the 8-way box, with
> > the pthread_setconcurrency calls commented out, and with
> > the concurrency calls put in (setting them to 8).
> > results are as follows
> > 
> > (without setconcurrency)
> > APR Lock Performance Test
> > ==============
> > 
> > apr_lock(INTRAPROCESS, MUTEX) Lock Tests
> > microseconds: 9373710 usec
> > apr_thread_mutex_t Tests
> > microseconds: 7304314 usec
> > apr_lock(INTRAPROCESS, READWRITE) Lock Tests
> > microseconds: 11247506 usec
> > apr_thread_mutex_t Tests
> > microseconds: 8148914 usec
> > 
> > (with pthread_setconcurrency(8) where you put the comments)
> > APR Lock Performance Test
> > ==============
> > 
> > apr_lock(INTRAPROCESS, MUTEX) Lock Tests
> > microseconds: 20054346 usec
> > apr_thread_mutex_t Tests
> > microseconds: 16979410 usec
> > apr_lock(INTRAPROCESS, READWRITE) Lock Tests
> microseconds: 247538114 usec
> apr_thread_mutex_t Tests
> microseconds: 250328270 usec

This is a perfect example of what happens when you *don't* set
the concurrency level (on solaris). What's really happening here
is the threads are not being interleaved, but instead they just
run their entire 1-million iteration loop, mutex locking and unlocking
included, without any concurrency. Try this patch and you'll
see what I mean:

[This patch is for illustrative purposes only, not for CVS]

Index: testlockperf.c
===================================================================
RCS file: /home/cvspublic/apr/test/testlockperf.c,v
retrieving revision 1.2
diff -u -r1.2 testlockperf.c
--- testlockperf.c	2001/09/15 05:23:55	1.2
+++ testlockperf.c	2001/09/15 23:55:28
@@ -103,11 +103,13 @@
 {
     int i;
 
+    printf("thread %p started\n", thd);
     for (i = 0; i < MAX_COUNTER; i++) {
         apr_lock_acquire(inter_lock);
         mutex_counter++;
         apr_lock_release(inter_lock);
     }
+    printf("thread %p done\n", thd);
     return NULL;
 }
 
@@ -115,11 +117,13 @@
 {
     int i;
 
+    printf("thread %p started\n", thd);
     for (i = 0; i < MAX_COUNTER; i++) {
         apr_thread_mutex_lock(thread_lock);
         mutex_counter++;
         apr_thread_mutex_unlock(thread_lock);
     }
+    printf("thread %p done\n", thd);
     return NULL;
 }
 
@@ -127,11 +131,13 @@
 {
     int i;
 
+    printf("thread %p started\n", thd);
     for (i = 0; i < MAX_COUNTER; i++) {
         apr_lock_acquire_rw(inter_rwlock, APR_WRITER);
         mutex_counter++;
         apr_lock_release(inter_rwlock);
     }
+    printf("thread %p done\n", thd);
     return NULL;
 }
 
@@ -139,11 +145,13 @@
 {
     int i;
 
+    printf("thread %p started\n", thd);
     for (i = 0; i < MAX_COUNTER; i++) {
         apr_thread_rwlock_wrlock(thread_rwlock);
         mutex_counter++;
         apr_thread_rwlock_unlock(thread_rwlock);
     }
+    printf("thread %p done\n", thd);
     return NULL;
 }
 

-aaron

Mime
View raw message