Skip to content

Instantly share code, notes, and snippets.

#! /usr/bin/perl
use strict;
use warnings;
use HTTP::Parser::XS qw(parse_http_request);
use IO::Socket::INET;
my $max_req_size = 131072;
$ diff -u lib/Sys/Sendfile.xs.orig lib/Sys/Sendfile.xs
--- lib/Sys/Sendfile.xs.orig 2009-09-14 13:16:26.000000000 +0900
+++ lib/Sys/Sendfile.xs 2009-09-15 22:12:08.000000000 +0900
@@ -12,7 +12,7 @@
#if defined linux || defined solaris
#include <sys/sendfile.h>
-#elif defined __FreeBSD__
+#elif defined (__FreeBSD__) || defined (__APPLE__)
#include <sys/types.h>
diff --git a/lib/Plack/Impl/Standalone.pm b/lib/Plack/Impl/Standalone.pm
index 33feba1..dab1f30 100644
--- a/lib/Plack/Impl/Standalone.pm
+++ b/lib/Plack/Impl/Standalone.pm
@@ -5,7 +5,9 @@ use warnings;
use Plack::HTTPParser qw( parse_http_request );
use IO::Socket::INET;
use HTTP::Status;
+use List::Util qw(sum);
use Plack::Util;
benchmarks/ab.pl
app: eg/dot-psgi/Hello.psgi
ab: ab -n 100 -c 10 -k
-- impl_class: AnyEvent
Accepting requests at http://0.0.0.0:10001/
Requests per second: 714.71 [#/sec] (mean)
-- impl_class: Standalone
Accepting connections at http://0:10001/
Requests per second: 3734.27 [#/sec] (mean)
-- impl_class: ServerSimple
diff -u ../IO-AIO-3.3.orig/libeio/libeio.m4 libeio/libeio.m4
--- ../IO-AIO-3.3.orig/libeio/libeio.m4 2008-10-23 02:54:19.000000000 +0900
+++ libeio/libeio.m4 2009-09-16 11:05:46.000000000 +0900
@@ -67,6 +67,11 @@
#elif __freebsd
# include <sys/socket.h>
# include <sys/uio.h>
+#elif __APPLE__
+# include <sys/socket.h>
+# include <sys/types.h>
Accepting connections at http://127.0.0.1:10001/
# has errors
ok 38
Accepting connections at http://127.0.0.1:10001/
# status line
ok 39
ok 40
Accepting connections at http://127.0.0.1:10001/
# multi headers
ok 41
$ wget -O /dev/null http://localhost:8080/
--22:26:19-- http://localhost:8080/
Resolving localhost... 127.0.0.1
Connecting to localhost|127.0.0.1|:8080... connected.
HTTP request sent, awaiting response... 200 OK
Length: 2397701 (2.3M) [image/jpeg]
Saving to: `/dev/null'
2% [=> ] 57,344 2.35K/s eta 16m 13s
write(8, "3\3!e=\275)\201d;F\244)\347\30<`\325m\354[\7\5\216N\10"..., 4096) = 4096
read(9, "\327\2621\214j.\304\220\314\207\201\221\306\321\307\25"..., 4096) = 4096
epoll_ctl(5, EPOLL_CTL_ADD, 9, {EPOLLIN, {u32=9, u64=4294967305}}) = -1 EPERM (Operation not permitted)
clock_gettime(CLOCK_MONOTONIC, {3582407, 186987576}) = 0
epoll_wait(5, {}, 64, 0) = 0
clock_gettime(CLOCK_MONOTONIC, {3582407, 187237385}) = 0
write(8, "\327\2621\214j.\304\220\314\207\201\221\306\321\307\25"..., 4096) = 4096
read(9, "8,W\234\320\3H\307C\311\347\3\277\265\5H\4\367\350G\240"..., 4096) = 4096
epoll_ctl(5, EPOLL_CTL_ADD, 9, {EPOLLIN, {u32=9, u64=4294967305}}) = -1 EPERM (Operation not permitted)
clock_gettime(CLOCK_MONOTONIC, {3582407, 187962349}) = 0
Ubuntu 8.04.2?; x86_64; perl 5.8.8; Core 2 Quad @ 3GHz
$ benchmarks/ab.pl -app=eg/dot-psgi/Hello.psgi --bench='ab -n 10000 -c 10 -k' 2> /dev/null
app: eg/dot-psgi/Hello.psgi
ab: ab -n 10000 -c 10 -k
-- impl_class: AnyEvent
Requests per second: 3531.13 [#/sec] (mean)
-- impl_class: Coro
Requests per second: 4811.16 [#/sec] (mean)
-- impl_class: Mojo::Prefork
34931 lsof CALL open(0x2809a8dc,0,0x1)
34931 lsof NAMI "/dev/kmem"
34931 lsof RET open 4
34931 lsof CALL fcntl(0x4,0x2,0x1)
...
34931 lsof CALL lseek(0x4,0,0xc251d264,0,0)
34931 lsof RET lseek -1034825116/0xc251d264
34931 lsof CALL read(0x4,0xbfbfe220,0x34)
34931 lsof GIO fd 4 read 52 bytes
0x0000 0000 0000 8863 2ec2 60f6 46c2 1cbe 4ec3 |.....c..`.F...N.|