libevent and epoll

Perrin Harkins perrin@elem.com
28 Sep 2003 14:36:56 -0400


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