diff options
author | dormando <dormando@rydia.net> | 2015-01-09 23:34:41 -0800 |
---|---|---|
committer | dormando <dormando@rydia.net> | 2015-01-09 23:34:41 -0800 |
commit | 0aa1a82a4cb43a47a9d5d3db3a239969612a60a6 (patch) | |
tree | 11159218748a2b6b2b402e7fc7740e1a5ce9288c | |
parent | 87ff9dc09c1fabb2f4645ca42d2f3ae18f0f3306 (diff) | |
download | memcached-0aa1a82a4cb43a47a9d5d3db3a239969612a60a6.tar.gz |
spinlocks never seem to help in benchmarks
If a thread is allowed to go to sleep, it can be woken up early as soon as the
lock is freed. If we spinlock, the scheduler can't help us and threads will
randomly run out their timeslice until the thread actually holding the lock
finishes its work.
In my benchmarks killing the spinlock only makes things better.
-rw-r--r-- | memcached.h | 7 |
1 files changed, 1 insertions, 6 deletions
diff --git a/memcached.h b/memcached.h index 141f56d..58071ba 100644 --- a/memcached.h +++ b/memcached.h @@ -540,12 +540,7 @@ enum store_item_type do_store_item(item *item, int comm, conn* c, const uint32_t conn *conn_new(const int sfd, const enum conn_states init_state, const int event_flags, const int read_buffer_size, enum network_transport transport, struct event_base *base); extern int daemonize(int nochdir, int noclose); -static inline int mutex_lock(pthread_mutex_t *mutex) -{ - while (pthread_mutex_trylock(mutex)); - return 0; -} - +#define mutex_lock(x) pthread_mutex_lock(x) #define mutex_unlock(x) pthread_mutex_unlock(x) #include "stats.h" |