From: Rusty Russell <rusty@rustcorp.com.au>
To: Davide Libenzi <davidel@xmailserver.org>
Cc: kravetz@us.ibm.com, mingo@elte.hu, torvalds@transmeta.com,
linux-kernel@vger.kernel.org, george@mvista.com
Subject: Re: [patch] O(1) scheduler, -D1, 2.5.2-pre9, 2.4.17
Date: Wed, 9 Jan 2002 14:32:42 +1100 [thread overview]
Message-ID: <20020109143242.013a0a31.rusty@rustcorp.com.au> (raw)
In-Reply-To: <Pine.LNX.4.40.0201082057560.936-100000@blue1.dev.mcafeelabs.com>
In-Reply-To: <20020108193904.A1068@w-mikek2.beaverton.ibm.com> <Pine.LNX.4.40.0201082057560.936-100000@blue1.dev.mcafeelabs.com>
On Tue, 8 Jan 2002 21:05:23 -0800 (PST)
Davide Libenzi <davidel@xmailserver.org> wrote:
> Mike can you try the patch listed below on custom pre-10 ?
> I've got 30-70% better performances with the chat_s/c test.
I'd encourage you to use hackbench, which is basically "the part of chat_c/s
that is interesting".
And I'd encourage you to come up with a better name, too 8)
Cheers,
Rusty.
/* Simple scheduler test. */
#include <unistd.h>
#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/wait.h>
#include <sys/time.h>
#include <sys/poll.h>
static int use_pipes = 0;
static void barf(const char *msg)
{
fprintf(stderr, "%s (error: %s)\n", msg, strerror(errno));
exit(1);
}
static void fdpair(int fds[2])
{
if (use_pipes) {
if (pipe(fds) == 0)
return;
} else {
if (socketpair(AF_UNIX, SOCK_STREAM, 0, fds) == 0)
return;
}
barf("Creating fdpair");
}
/* Block until we're ready to go */
static void ready(int ready_out, int wakefd)
{
char dummy;
struct pollfd pollfd = { .fd = wakefd, .events = POLLIN };
/* Tell them we're ready. */
if (write(ready_out, &dummy, 1) != 1)
barf("CLIENT: ready write");
/* Wait for "GO" signal */
if (poll(&pollfd, 1, -1) != 1)
barf("poll");
}
static void reader(int ready_out, int wakefd, unsigned int loops, int fd)
{
char dummy;
unsigned int i;
ready(ready_out, wakefd);
for (i = 0; i < loops; i++) {
if (read(fd, &dummy, 1) != 1)
barf("READER: read");
}
}
/* Start the server */
static void server(int ready_out, int wakefd,
unsigned int loops, unsigned int num_fds)
{
unsigned int i;
int write_fds[num_fds];
unsigned int counters[num_fds];
for (i = 0; i < num_fds; i++) {
int fds[2];
fdpair(fds);
switch (fork()) {
case -1: barf("fork()");
case 0:
close(fds[1]);
reader(ready_out, wakefd, loops, fds[0]);
exit(0);
}
close(fds[0]);
write_fds[i] = fds[1];
if (fcntl(write_fds[i], F_SETFL, O_NONBLOCK) != 0)
barf("fcntl NONBLOCK");
counters[i] = 0;
}
ready(ready_out, wakefd);
for (i = 0; i < loops * num_fds;) {
unsigned int j;
char dummy;
for (j = 0; j < num_fds; j++) {
if (counters[j] < loops) {
if (write(write_fds[j], &dummy, 1) == 1) {
counters[j]++;
i++;
} else if (errno != EAGAIN)
barf("write");
}
}
}
/* Reap them all */
for (i = 0; i < num_fds; i++) {
int status;
wait(&status);
if (!WIFEXITED(status))
exit(1);
}
exit(0);
}
int main(int argc, char *argv[])
{
unsigned int i;
struct timeval start, stop, diff;
unsigned int num_fds;
int readyfds[2], wakefds[2];
char dummy;
int status;
if (argv[1] && strcmp(argv[1], "-pipe") == 0) {
use_pipes = 1;
argc--;
argv++;
}
if (argc != 2 || (num_fds = atoi(argv[1])) == 0)
barf("Usage: hackbench2 [-pipe] <num pipes>\n");
fdpair(readyfds);
fdpair(wakefds);
switch (fork()) {
case -1: barf("fork()");
case 0:
server(readyfds[1], wakefds[0], 10000, num_fds);
exit(0);
}
/* Wait for everyone to be ready */
for (i = 0; i < num_fds+1; i++)
if (read(readyfds[0], &dummy, 1) != 1)
barf("Reading for readyfds");
gettimeofday(&start, NULL);
/* Kick them off */
if (write(wakefds[1], &dummy, 1) != 1)
barf("Writing to start them");
/* Reap server */
wait(&status);
if (!WIFEXITED(status))
exit(1);
gettimeofday(&stop, NULL);
/* Print time... */
timersub(&stop, &start, &diff);
printf("Time: %lu.%03lu\n", diff.tv_sec, diff.tv_usec/1000);
exit(0);
}
--
Anyone who quotes me in their sig is an idiot. -- Rusty Russell.
next prev parent reply other threads:[~2002-01-09 5:35 UTC|newest]
Thread overview: 40+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-01-07 20:24 [patch] O(1) scheduler, -D1, 2.5.2-pre9, 2.4.17 Ingo Molnar
2002-01-07 19:03 ` Brian Gerst
2002-01-07 21:19 ` Ingo Molnar
2002-01-09 3:39 ` Mike Kravetz
2002-01-09 5:05 ` Davide Libenzi
2002-01-09 3:32 ` Rusty Russell [this message]
2002-01-09 18:02 ` Davide Libenzi
2002-01-09 11:37 ` Ingo Molnar
2002-01-09 11:19 ` Rene Rebe
2002-01-09 15:34 ` Ryan Cumming
2002-01-09 18:24 ` Davide Libenzi
2002-01-09 21:24 ` Ingo Molnar
2002-01-09 19:38 ` Mike Kravetz
2002-01-10 18:21 ` Mike Kravetz
2002-01-10 19:08 ` Davide Libenzi
2002-01-10 19:09 ` Linus Torvalds
2002-01-10 21:08 ` Davide Libenzi
2002-01-10 19:15 ` Mike Kravetz
2002-01-10 20:05 ` Davide Libenzi
2002-01-09 22:34 ` Mark Hahn
2002-01-10 14:04 ` Ingo Molnar
2002-01-09 20:15 ` Linus Torvalds
2002-01-09 23:02 ` Ingo Molnar
2002-01-09 6:29 ` Brian
2002-01-09 6:40 ` Jeffrey W. Baker
2002-01-09 6:45 ` Ryan Cumming
2002-01-09 6:48 ` Ryan Cumming
2002-01-09 10:25 ` Ingo Molnar
2002-01-09 17:40 ` Mike Kravetz
[not found] <200201071922.g07JMN106760@penguin.transmeta.com>
2002-01-07 21:36 ` Ingo Molnar
2002-01-08 8:49 ` FD Cami
2002-01-08 18:44 ` J Sloan
2002-01-08 11:32 ` Anton Blanchard
2002-01-08 11:43 ` Anton Blanchard
2002-01-08 14:34 ` Ingo Molnar
2002-01-09 23:15 ` Anton Blanchard
2002-01-10 1:09 ` Richard Henderson
2002-01-10 17:04 ` Ivan Kokshaysky
2002-01-10 20:42 ` george anzinger
2002-01-10 23:56 ` Ingo Molnar
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20020109143242.013a0a31.rusty@rustcorp.com.au \
--to=rusty@rustcorp.com.au \
--cc=davidel@xmailserver.org \
--cc=george@mvista.com \
--cc=kravetz@us.ibm.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=torvalds@transmeta.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox