libevent and epoll
Brad Fitzpatrick
brad@danga.com
Sun, 28 Sep 2003 23:56:08 -0700 (PDT)
Perrin,
I tuned Memcached's Perl library, removing the dependence on the slow
IO::Socket library. Checking it into CVS now.
Memcached is now twice as fast (wall clock) as your unrealistic DBD
benchmark:
bradfitz@apfel:~/benchmark$ ./bench.pl
Benchmark: timing 100 iterations of DBD::mysql, MemCachedClient...
DBD::mysql: 24 wallclock secs ( 6.34 usr + 3.06 sys = 9.40 CPU) @ 10.64/s (n=100)
MemCachedClient: 11 wallclock secs ( 5.90 usr + 1.78 sys = 7.68 CPU) @ 13.02/s (n=100)
Rate DBD::mysql MemCachedClient
DBD::mysql 10.6/s -- -18%
MemCachedClient 13.0/s 22% --
What are you doing all this benchmark work for, anyway?
- Brad
On Sun, 28 Sep 2003, Perrin Harkins wrote:
> On Tue, 2003-09-23 at 00:28, Brad Fitzpatrick wrote:
> > And use our binary, which is built with a libevent with epoll support,
> > including epoll bugfixes which aren't in 0.7a (the latest libevent version
> > on the site).
> >
> > http://www.danga.com/memcached/dist/binaries/linux-x86/memcached-1.1.9-snapshot-dbg.gz
> >
> > Test it with:
> >
> > $ EVENT_SHOW_METHOD=1 ./memcached
> >
> > It should say "Using: epoll" or similar.
>
> Thanks for the help. I got this working (on linux kernel 2.4.21), but
> I'm getting pretty poor performance so I think I must have a mistake in
> my code somewhere. At the moment, MySQL, IPC::MM, and BerkeleyDB are
> all much faster than memcached in my tests.
>
> I'm starting the server with this command:
>
> ./memcached-1.1.9-snapshot-dbg -d -m 128 -l 127.0.0.1 -p 11211
>
> Here's the client code I use. IPC::SharedHash is an asbtraction layer
> that allows me to test all forms of storage with the same API.
>
> package IPC::SharedHash::MemCachedClient;
>
> use strict;
> use warnings;
>
> use MemCachedClient;
>
> sub new {
> my $class = shift;
> my $self = {};
> my $memc = MemCachedClient->new(
> {
> 'servers' => ['127.0.0.1:11211'],
> 'debug' => 0,
> 'compress_threshold' => 10_000,
> }
> );
>
> $self->{'backend'} = $memc;
> bless $self, $class;
> return $self;
> }
>
> sub fetch {
> my $self = shift;
> my ($key) = @_;
> my $value = $self->{'backend'}->get($key);
> return $value;
> }
>
> sub store {
> my $self = shift;
> my ( $key, $value ) = @_;
> $self->{'backend'}->set( $key, $value );
> }
>
> 1;
>
> Does anyone see any problems here? By the way, lines 305 and 306 of the
> Perl client API were giving warnings, but neither turning off warnings
> nor fixing the problem made a significant difference to performance.
> Here's the output of my benchmark script:
>
> Rate MemCachedClient DBD::mysql IPC::MM
> MemCachedClient 16.4/s -- -53% -85%
> DBD::mysql 35.0/s 114% -- -68%
> IPC::MM 109/s 564% 210% --
>
> - Perrin
>
>