Lecture Notes for Client-Server Interfaces

7 March 2004 - Process vs Threads Performance


Thread vs. Process Concurrency


The Contenders


The Results

cl g++ -o forktime forktime.cc -lthread

cl ./forktime
Time per fork() call for 2000 calls: 9076.9 usec.
pthread_create() time for 2000 calls: 138.4 usec.

cl CC -o forktime -mt forktime.cc

cl ./forktime
Time per fork() call for 2000 calls: 5706.1 usec.
pthread_create() time for 2000 calls: 137.7 usec.

cl g++ -O -o forktime forktime.cc -lthread

cl ./forktime
Time per fork() call for 2000 calls: 9000.7 usec.
pthread_create() time for 2000 calls: 127.0 usec.

cl g++ -O3 -o forktime forktime.cc -lthread

cl ./forktime
Time per fork() call for 2000 calls: 9299.2 usec.
pthread_create() time for 2000 calls: 163.4 usec.

cl 


Rockhopper


ro dmesg
Linux version 2.4.20-30.9smp
(gcc version 3.2.2 (Red Hat Linux 3.2.2-5))
Memory: 1,310,712k available
Processors: 2
Detected 728.493 MHz processor.
CPU: L1 I cache: 16K, L1 D cache: 16K
CPU: L2 cache: 256K

ro g++ -o forktime  forktime.cc -lpthread

ro ./forktime
Time per fork() call for 2000 calls: 721.7 usec.
pthread_create() time for 2000 calls: 12.2 usec.

ro ./forktime
Time per fork() call for 2000 calls: 709.4 usec.
pthread_create() time for 2000 calls: 11.9 usec.

ro 


Cslab

cs uname -a
SunOS cslab00 5.9 Generic_112233-11 
sun4u sparc SUNW,UltraAX-i2 Solaris

cs g++ -o forktime forktime.cc -lpthread

cs ./forktime
Time per fork() call for 2000 calls: 7297.5 usec.
pthread_create() time for 2000 calls: 87.0 usec.

cs CC -o forktime -mt forktime.cc

cs ./forktime
Time per fork() call for 2000 calls: 5812.5 usec.
pthread_create() time for 2000 calls: 88.7 usec.

cs 


Linux-Lab Machines

cs dmesg
Linux version 2.4.2-openmosix1 (root@hope)
(gcc version 3.2.2 (Red Hat Linux 3.2.2-5))
Memory: 515,520k available
CPU: Trace cache: 12K uops, L1 D cache: 8K
CPU: L2 cache: 512K
CPU: Intel(R) Pentium(R) 4 CPU 2.6GHz 

cs g++ -o forktime forktime.cc -lpthread

cs ./forktime
Time per fork() call for 2000 calls: 307.3 usec.
pthread_create() time for 2000 calls: 67.8 usec.

cs g++ -O3 -o forktime forktime.cc -lpthread

cs ./forktime
Time per fork() call for 2000 calls: 327.9 usec.
pthread_create() time for 2000 calls: 68.9 usec.

cs 


Conclusions


This page last modified on 3 March 2004.