On 18. aug.. 2009, at 10.52, [email protected] wrote:


Status: New
Owner: dsallings
Labels: Type-Defect Priority-Medium

New issue 75 by dsallings: Unnecessary stats locks around flushes.
http://code.google.com/p/memcached/issues/detail?id=75

Since stats are thread-local, there should be no reason to lock them. I've got a patch that updates them in my issue_whatever_number_this_is branch
(over issue_71).  Looks like this:

diff --git a/memcached.c b/memcached.c
index 6edc481..b6b5312 100644
--- a/memcached.c
+++ b/memcached.c
@@ -1764,9 +1764,7 @@ static void process_bin_flush(conn *c) {
    }
    item_flush_expired();

-    STATS_LOCK();
    c->thread->stats.flush_cmds++;
-    STATS_UNLOCK();

    write_bin_response(c, NULL, 0, 0, 0);
}
@@ -2778,9 +2776,7 @@ static void process_command(conn *c, char *command) {

        set_noreply_maybe(c, tokens, ntokens);

-        STATS_LOCK();
        c->thread->stats.flush_cmds++;
-        STATS_UNLOCK();

        if(ntokens == (c->noreply ? 3 : 2)) {
            settings.oldest_live = current_time - 1;


You should lock the thread-local stat instead. Look at get/set etc..

cheers,

Trond

Reply via email to