lkml.org 
[lkml]   [1999]   [Jun]   [10]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectMore new schedule() results ...
Hi guys,

as requested by mingo I post the switching speed results of
my new schedule() implementation.
More tests has been done and these are the benchmarks on my
PII 400MHz ( using the program posted with my first annouce ):

Test time = 60s

N.Threads 2.3.5 MyPatch Diff

2 700000 600000 -15 %
10 280000 365000 +25 %
450 6100 8900 +45 %

The 450 threads test has given, some times, values of about 10800
with improvement near to 80 %.
The results of these tests is clear.
When You have 2 threads You have no switching overload on Your system
and my implementation must pay the cost of the slot insertion.
But with only 10 threads You have a switching speed increased of about 25 %
that linear grow up to 60-80 %.

Since some guys has asked my the patch because they lose the first post,
I include it with this mail as long as the test program ( THX to Willy Terreau).

Cheers,
Davide.

--
"Debian, the Freedom in Freedom."

[unhandled content-type:application/octet-stream]

/*
Tester for the kernel's speed in scheduling.
(C) 1999 / Willy Tarreau <willy@meta-x.org>

Modified by Davide Libenzi <davidel@maticad.it>


You can do whatever you want with this program, but I'm not
responsible for any misuse. Be aware that it can heavily load
a host. As it is multithreaded, it might take advantages of SMP.

It basically creates a growing amount of threads and measures
their cumulative work (i.e. loop iterations/second). The output
is easily useable by gnuplot.

To compile, you need libpthread :

gcc -O2 -fomit-frame-pointer -o threads threads.c -lpthread

Output on stdout is :
<nb_threads> <average_work> <zero_work_threads> <std_deviation>

*/

#include <stdio.h>
#include <pthread.h>
#include <signal.h>
#include <unistd.h>
#include <time.h>



#define MAXTHREADS 450
#define MEASURE_TIME 60



pthread_t thr[MAXTHREADS];
int nbthreads = MAXTHREADS;
int measure_time = MEASURE_TIME;
volatile actthreads = 0;

long long int totalwork[MAXTHREADS];
volatile int stop = 0,
start = 0,
count = 0;

void oneatwork(int thr)
{
int i;
while (!start) /* don't disturb pthread_create() */
usleep(10000);

actthreads++;
while (!stop)
{
if (count)
totalwork[thr]++;

syscall(158); /* sys_sched_yield() */
}
actthreads--;
pthread_exit(0);
}

main(int argc, char **argv)
{

int i,
err,
avgwork,
thrzero;
long long int value,
avgvalue;
double sqrdev;
time_t ts,
te;

if (argc < 3)
{
printf("usage: %s threads time\n", argv[0]);
exit(1);
}

nbthreads = atoi(argv[1]);
measure_time = atoi(argv[2]);


start = 0;
count = 0;
stop = 0;
actthreads = 0;
thrzero = 0;
value = 0;
sqrdev = 0.0;

fprintf(stderr, "\nCreating %d threads ...", nbthreads);
for (i = 0; i < nbthreads; i++)
{
if ((err = pthread_create(&thr[i], NULL, (void *) &oneatwork, (void *) i)) != 0)
{
fprintf(stderr, "thread %d pthread_create=%d -> ", i, err);
perror("");
exit(1);
}
pthread_detach(thr[i]);
}

for (i = 0; i < nbthreads; i++)
totalwork[i] = 0;

fprintf(stderr, " OK !\nWaiting for all threads to start ...");

start = 1;
while (actthreads != nbthreads)
usleep(10000); /* waiting for a bit of stability */

fprintf(stderr, "Go !\n");

count = 1;
time(&ts);

sleep(measure_time);

count = 0;
stop = 1;
time(&te);


for (i = 0; i < nbthreads; i++)
{
value += totalwork[i];
if (totalwork[i] == 0)
++thrzero;
}
avgvalue = value / nbthreads;
value /= (int) difftime(te, ts);
avgwork = (int) (value / nbthreads);

for (i = 0; i < nbthreads; i++)
{
double difvv = (double) (totalwork[i] - avgvalue);

sqrdev += difvv * difvv;
}

while (actthreads > 0)
usleep(10000);

printf("%d\t\t%lld\t\t%d\t\t%d\t\t%f\n", nbthreads, value, avgwork, thrzero,
sqrdev / ((double) nbthreads * avgvalue * avgvalue));

exit(0);

}

\
 
 \ /
  Last update: 2005-03-22 13:52    [W:0.050 / U:0.456 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site