Trying to renew a lock is very rare, but memcache-lock.inc tries this first, before the more common scenario of acquiring a lock in the first place. Swapping the two, it's possible to save a dmemcache_get() for every call to lock_acquire(), this is going to be more noticeable in stats with #962422: Empty cache stampede protection enabled.

Patch passes tests, will run benchmarks in a bit.

CommentFileSizeAuthor
lock-get.patch3.35 KBcatch
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

catch’s picture

Before (stampede protection enabled):

STAT total_connections 11808
STAT cmd_get 177675
STAT cmd_set 114138
STAT get_hits 63367
STAT get_misses 114308
STAT incr_hits 0
STAT bytes_read 82037217
STAT bytes_written 167263678
STAT evictions 6609
STAT total_items 114078

Hit rate: 35.6600%
Miss rate: 64.3300%

HTTP return codes:  20x(11795) 30x(1309) 40x(2)  50x(0)
 200: 11795
 302: 1309

Pages per second: 20.70

After (stampede protection enabled):

STAT total_connections 11848
STAT cmd_get 120991
STAT cmd_set 114442
STAT get_hits 63634
STAT get_misses 57357
STAT incr_hits 0
STAT bytes_read 79129970
STAT bytes_written 167511255
STAT evictions 7325
STAT total_items 114388

Hit rate: 52.5900%
Miss rate: 47.4000%

HTTP return codes:  20x(11835) 30x(1311) 40x(2)  50x(0)
 200: 11835
 302: 1311

Pages per second: 20.80

After (stampede protection disabled):


STAT total_connections 12031
STAT cmd_get 121816
STAT cmd_set 57744
STAT get_hits 63962
STAT get_misses 57854
STAT incr_hits 0
STAT bytes_read 67765933
STAT bytes_written 169363710
STAT evictions 6180
STAT total_items 57744

Hit rate: 52.5000%
Miss rate: 47.4900%

HTTP return codes:  20x(12018) 30x(1325) 40x(2)  50x(0)
 200: 12018
 302: 1325

Pages per second: 21.11

If you compare the last two runs, the only difference is an extra memcache set (which corresponds very closely to get misses) - which is what I would have expected to be the case.

catch’s picture

Version: 6.x-1.x-dev » 7.x-1.x-dev
Status: Active » Patch (to be ported)

Since this is a straightforward change and has good results, I've committed to 6.x-1.x, marking for forward port.

catch’s picture

Status: Patch (to be ported) » Fixed

Committed.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.