From: ori@eigenstate.org
To: 9fans@9fans.net
Subject: [9fans] little pipe speedtest
Date: Sat, 04 Jun 2022 11:15:31 -0400 [thread overview]
Message-ID: <14C2F3A5573654C099879213DE65733F@eigenstate.org> (raw)
inspired by:
https://mazzo.li/posts/fast-pipes.html
I was curious to see how things stacked up on plan 9.
The machines are apples to oranges (my 9front box
is a 2015-ish era Zbox with a Intel Core i5-7300HQ
processor, and my work machine is a Linux with a
12 core Ryzen 9 3900X).
Transferring 128 gigs instead of the 10 in the initial
benchmark, here are the results:
# 9front 595684fd8a2f08e12d5df48152d93fb8ab800fe3 amd64
% time rc -c '6.write | 6.read'
0.33u 23.28s 11.64r rc -c 6.write | 6.read
# Linux 5.13.0-40-generic #45~20.04.1-Ubuntu SMP
$ time sh -c './write | ./read'
real 0m32.039s
user 0m0.231s
sys 0m34.576s
here's the plan 9 version of the program:
write.c:
#include <u.h>
#include <libc.h>
void
main(void)
{
usize sz;
char* buf;
sz = 1 << 18;
buf = malloc(sz);
memset((void*)buf, 'X', sz);
while(1){
n = write(1, buf, sz) != sz)
break;
exits(nil);
}
read.c:
#include <u.h>
#include <libc.h>
enum {
KiB = 1024ULL,
MiB = 1024*KiB,
GiB = 1024*MiB,
};
void
main(void)
{
vlong sz, r, n;
char* buf;
r = 0;
sz = 1 << 18;
buf = malloc(sz);
while(r <= 128ULL*GiB){
n = read(0, buf, sz);
if(n <= 0)
break;
r += n;
}
exits(nil);
}
And the linux version:
write.c:
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
int
main(int argc, char **argv)
{
size_t sz;
char* buf;
sz = 1 << 18;
buf = malloc(sz);
memset(buf, 'X', sz);
while(1)
if(write(1, buf, sz) != sz)
break;
return 0;
}
read.c:
#include <stdlib.h>
#include <unistd.h>
enum {
KiB = 1024ULL,
MiB = 1024*KiB,
GiB = 1024*MiB,
};
int
main(int argc, char **argv)
{
ssize_t sz, r, n;
char* buf;
r = 0;
sz = 1 << 18;
buf = malloc(sz);
while(r <= 128ULL*GiB){
n = read(0, buf, sz);
if(n <= 0)
break;
r += n;
}
return 0;
}
------------------------------------------
9fans: 9fans
Permalink: https://9fans.topicbox.com/groups/9fans/Td13d120eca9d5ee7-M40cecbefc1f455f5c2c25358
Delivery options: https://9fans.topicbox.com/groups/9fans/subscription
reply other threads:[~2022-06-04 15:15 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=14C2F3A5573654C099879213DE65733F@eigenstate.org \
--to=ori@eigenstate.org \
--cc=9fans@9fans.net \
/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;
as well as URLs for NNTP newsgroup(s).