[test case] terrible performance with select()

Evan Martin martine@danga.com
Sun, 10 Aug 2003 12:06:37 -0700


--Apple-Mail-12-630818559
Content-Transfer-Encoding: 7bit
Content-Type: text/plain;
	charset=US-ASCII;
	format=flowed

As a few people (including me) have found out, memcache is suspiciously 
slow when using libevent backends other than epoll.  (I think?  I guess 
I've only seen the behavior myself with select().)

FWIW, it appears the problem that event_hander is taking up to five 
seconds to get called, but only after repeat commands.  Why that 
happens is a more difficult problem, because it works fine with epoll 
so it must be some behavior that's inconsistent underneath libevent.

Attached is a test case that exhibits the behavior.  Of note is the 
perfectly round numbers that come up when it's being slow.  Is 
something timing out here?
(The "delay" here is the delay between subsequent requests.)

lulu:~/projects/memcached/api/python% ./slow.py 1
Trying get()s with 1.00s delay
get took 0.13 seconds
get took 0.30 seconds
get took 4.00 seconds
get took 4.00 seconds
get took 4.00 seconds
get took 4.00 seconds
lulu:~/projects/memcached/api/python% ./slow.py 0.9
Trying get()s with 0.90s delay
get took 0.18 seconds
get took 1.38 seconds
get took 4.10 seconds
get took 4.10 seconds
get took 4.10 seconds
get took 4.10 seconds



--Apple-Mail-12-630818559
Content-Disposition: attachment;
	filename=slow.py
Content-Transfer-Encoding: 7bit
Content-Type: application/octet-stream;
	x-unix-mode=0755;
	name="slow.py"

#!/usr/bin/env python

import sys
import memcache
import time

sleeptime = 1
if len(sys.argv) > 1:
    sleeptime = float(sys.argv[1])

mc = memcache.Client(['127.0.0.1:11211'])
print "Trying get()s with %0.2fs delay" % sleeptime
try:
    while 1:
        t1 = time.time()
        mc.get("hi")
        t2 = time.time()
        print "get took %0.2f seconds" % (t2-t1)
        time.sleep(sleeptime)
except KeyboardInterrupt:
    pass


--Apple-Mail-12-630818559--